diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index e5978d4..8437686 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -527,7 +527,8 @@ sub startup { my ($journey) = @_; my $found; for my $stop ( $journey->route ) { - if ( $stop->eva == $station ) { + if ( $stop->name eq $station or $stop->eva == $station ) + { $found = $stop; last; } diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 8ff98de..7f72a53 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -176,12 +176,14 @@ sub travel_v1 { my $from_station = sanitize( q{}, $payload->{fromStation} ); my $to_station = sanitize( q{}, $payload->{toStation} ); my $train_id; + my $hafas = exists $payload->{train}{journeyID} ? 1 : 0; if ( not( $from_station - and ( ( $payload->{train}{type} and $payload->{train}{no} ) - or $payload->{train}{id} ) + and ( ( $payload->{train}{type} and $payload->{train}{no} ) + or $payload->{train}{id} + or $payload->{train}{journeyID} ) ) ) { @@ -196,7 +198,7 @@ sub travel_v1 { return; } - if ( not $self->stations->search($from_station) ) { + if ( not $hafas and not $self->stations->search($from_station) ) { $self->render( json => { success => \0, @@ -208,7 +210,10 @@ sub travel_v1 { return; } - if ( $to_station and not $self->stations->search($to_station) ) { + if ( $to_station + and not $hafas + and not $self->stations->search($to_station) ) + { $self->render( json => { success => \0, @@ -222,7 +227,11 @@ sub travel_v1 { my $train_p; - if ( exists $payload->{train}{id} ) { + if ( exists $payload->{train}{journeyID} ) { + $train_p = Mojo::Promise->resolve( + sanitize( q{}, $payload->{train}{journeyID} ) ); + } + elsif ( exists $payload->{train}{id} ) { $train_p = Mojo::Promise->resolve( sanitize( 0, $payload->{train}{id} ) ); } diff --git a/templates/api_documentation.html.ep b/templates/api_documentation.html.ep index ab90dec..0847139 100644 --- a/templates/api_documentation.html.ep +++ b/templates/api_documentation.html.ep @@ -102,7 +102,7 @@
curl -X POST -H "Content-Type: application/json" -d '{"token":"<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>"}' <%= $api_root %>/travel
-Payload zum Einchecken, optional mit Zielwahl:
+Payload zum Einchecken per IRIS-Backend (Schienenverkehr DE/DB), optional mit Zielwahl:
{
"token" : "<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>",
@@ -116,6 +116,19 @@
"comment" : "Beliebiger Text" (optional, überschreibt vorherigen Kommentar)
}
Payload zum Einchecken per HAFAS-Backend (Nahverkehr und außerhalb DE/DB), optional mit Zielwahl. fromStation und toStation müssen mit den Unterwegshalten übereinstimmen, z.B. "Hauptbahnhof (U Gleis 2+4), Essen (Ruhr)" statt "Essen Hbf".
+
+ {
+ "token" : "<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>",
+ "action" : "checkin",
+ "train" : {
+ "journeyID" : "1|1426396|4|80|19082023",
+ }
+ "fromStation" : 651806, (Name oder EVA-Nummer)
+ "toStation" : 654645, (optional, Name oder EVA-Nummer)
+ "comment" : "Beliebiger Text" (optional, überschreibt vorherigen Kommentar)
+ }
+
Payload zur Wahl eines neuen Ziels, wenn bereits eingecheckt:
{