summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx/Helper')
-rw-r--r--lib/Travelynx/Helper/DBDB.pm21
-rw-r--r--lib/Travelynx/Helper/MOTIS.pm20
-rw-r--r--lib/Travelynx/Helper/Traewelling.pm18
3 files changed, 32 insertions, 27 deletions
diff --git a/lib/Travelynx/Helper/DBDB.pm b/lib/Travelynx/Helper/DBDB.pm
index 79e9c0b..a310aa3 100644
--- a/lib/Travelynx/Helper/DBDB.pm
+++ b/lib/Travelynx/Helper/DBDB.pm
@@ -61,7 +61,8 @@ sub has_wagonorder_p {
}
}
- $self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} )
+ $self->{user_agent}->request_timeout(5)
+ ->get_p( $url => $self->{header} )
->then(
sub {
my ($tx) = @_;
@@ -81,7 +82,7 @@ sub has_wagonorder_p {
}
return;
}
- )->catch(
+ )->catch(
sub {
my ($err) = @_;
$self->{log}->debug("${debug_prefix}: n ($err)");
@@ -89,7 +90,7 @@ sub has_wagonorder_p {
$promise->reject;
return;
}
- )->wait;
+ )->wait;
return $promise;
}
@@ -120,7 +121,8 @@ sub get_wagonorder_p {
return $promise;
}
- $self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} )
+ $self->{user_agent}->request_timeout(5)
+ ->get_p( $url => $self->{header} )
->then(
sub {
my ($tx) = @_;
@@ -139,14 +141,14 @@ sub get_wagonorder_p {
}
return;
}
- )->catch(
+ )->catch(
sub {
my ($err) = @_;
$self->{log}->debug("${debug_prefix}: error ${err}");
$promise->reject($err);
return;
}
- )->wait;
+ )->wait;
return $promise;
}
@@ -163,7 +165,8 @@ sub get_stationinfo_p {
return $promise->resolve($content);
}
- $self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} )
+ $self->{user_agent}->request_timeout(5)
+ ->get_p( $url => $self->{header} )
->then(
sub {
my ($tx) = @_;
@@ -183,7 +186,7 @@ sub get_stationinfo_p {
$promise->resolve($json);
return;
}
- )->catch(
+ )->catch(
sub {
my ($err) = @_;
$self->{log}->debug("get_stationinfo_p(${eva}): Error ${err}");
@@ -191,7 +194,7 @@ sub get_stationinfo_p {
$promise->reject($err);
return;
}
- )->wait;
+ )->wait;
return $promise;
}
diff --git a/lib/Travelynx/Helper/MOTIS.pm b/lib/Travelynx/Helper/MOTIS.pm
index ee2b10b..d4e1777 100644
--- a/lib/Travelynx/Helper/MOTIS.pm
+++ b/lib/Travelynx/Helper/MOTIS.pm
@@ -50,10 +50,10 @@ sub get_station_by_query_p {
my $promise = Mojo::Promise->new;
Travel::Status::MOTIS->new_p(
- cache => $self->{cache},
- promise => 'Mojo::Promise',
- user_agent => Mojo::UserAgent->new,
- lwp_options => {
+ cache => $self->{cache},
+ promise => 'Mojo::Promise',
+ user_agent => Mojo::UserAgent->new,
+ lwp_options => {
timeout => 10,
agent => $self->{header}{'User-Agent'},
},
@@ -106,10 +106,10 @@ sub get_departures_p {
agent => $self->{header}{'User-Agent'},
},
- service => $opt{service},
- timestamp => $timestamp,
- stop_id => $opt{station_id},
- results => 60,
+ service => $opt{service},
+ timestamp => $timestamp,
+ stop_id => $opt{station_id},
+ results => 60,
);
}
@@ -126,8 +126,8 @@ sub get_trip_p {
promise => 'Mojo::Promise',
user_agent => Mojo::UserAgent->new,
- service => $opt{service},
- trip_id => $opt{trip_id},
+ service => $opt{service},
+ trip_id => $opt{trip_id},
)->then(
sub {
my ($motis) = @_;
diff --git a/lib/Travelynx/Helper/Traewelling.pm b/lib/Travelynx/Helper/Traewelling.pm
index 100a799..66f2a29 100644
--- a/lib/Travelynx/Helper/Traewelling.pm
+++ b/lib/Travelynx/Helper/Traewelling.pm
@@ -78,7 +78,8 @@ sub get_status_p {
$self->{user_agent}->request_timeout(20)
->get_p(
"https://traewelling.de/api/v1/user/${username}/statuses?limit=1" =>
- $header )->then(
+ $header )
+ ->then(
sub {
my ($tx) = @_;
if ( my $err = $tx->error ) {
@@ -150,13 +151,13 @@ sub get_status_p {
}
}
}
- )->catch(
+ )->catch(
sub {
my ($err) = @_;
$promise->reject( { text => "v1/${username}/statuses: $err" } );
return;
}
- )->wait;
+ )->wait;
return $promise;
}
@@ -238,13 +239,13 @@ sub logout_p {
return;
}
}
- )->catch(
+ )->catch(
sub {
my ($err) = @_;
$promise->reject("v1/auth/logout: $err");
return;
}
- )->wait;
+ )->wait;
return $promise;
}
@@ -322,7 +323,8 @@ sub checkin_p {
$self->{user_agent}->request_timeout(20)
->post_p(
"https://traewelling.de/api/v1/trains/checkin" => $header => json =>
- $request )->then(
+ $request )
+ ->then(
sub {
my ($tx) = @_;
if ( my $err = $tx->error ) {
@@ -368,7 +370,7 @@ sub checkin_p {
# on the user status page
return;
}
- )->catch(
+ )->catch(
sub {
my ($err) = @_;
$self->{log}->debug("... $debug_prefix error: $err");
@@ -381,7 +383,7 @@ sub checkin_p {
$promise->reject( { connection => $err } );
return;
}
- )->wait;
+ )->wait;
return $promise;
}