diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-03-27 21:26:42 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-03-27 21:26:42 +0100 |
commit | 68086be3a8c996486d9cbdec0b7f5e3d2dc01750 (patch) | |
tree | 62aec91c474349963ca24384c73be087963703d2 | |
parent | 3dbdefa8bdfb7029bb8c508f148554fd4fa6038d (diff) |
API: Add DBRIS support2.11.6
-rwxr-xr-x | lib/Travelynx/Controller/Api.pm | 12 | ||||
-rw-r--r-- | templates/api_documentation.html.ep | 9 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index f31195a..9fe72b2 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -21,6 +21,9 @@ sub sanitize { if ( not defined $value ) { return undef; } + if ( not defined $type ) { + return $value ? ( '' . $value ) : undef; + } if ( $type eq '' ) { return '' . $value; } @@ -184,8 +187,12 @@ sub travel_v1 { my $from_station = sanitize( q{}, $payload->{fromStation} ); my $to_station = sanitize( q{}, $payload->{toStation} ); my $train_id; + my $dbris = sanitize( undef, $payload->{dbris} ); my $hafas = sanitize( undef, $payload->{hafas} ); - $hafas //= exists $payload->{train}{journeyID} ? 'DB' : undef; + + if ( not $hafas and exists $payload->{train}{journeyID} ) { + $dbris //= 'bahn.de'; + } if ( not( @@ -209,6 +216,7 @@ sub travel_v1 { } if ( not $hafas + and not $dbris and not $self->stations->search( $from_station, backend_id => 1 ) ) { $self->render( @@ -225,6 +233,7 @@ sub travel_v1 { if ( $to_station and not $hafas + and not $dbris and not $self->stations->search( $to_station, backend_id => 1 ) ) { $self->render( @@ -288,6 +297,7 @@ sub travel_v1 { train_id => $train_id, uid => $uid, hafas => $hafas, + dbris => $dbris, ); } )->then( diff --git a/templates/api_documentation.html.ep b/templates/api_documentation.html.ep index 4453286..099474c 100644 --- a/templates/api_documentation.html.ep +++ b/templates/api_documentation.html.ep @@ -129,12 +129,13 @@ {<br/> "token" : "<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>",<br/> "action" : "checkin",<br/> - "hafas" : "DB", (HAFAS-Instanz – Default: Deutsche Bahn)<br/> + "dbris" : "bahn.de", (DBRIS-Instanz – Default: bahn.de)<br/> + "hafas" : null, (HAFAS-Instanz, falls verwendet, sonste null)<br/> "train" : {<br/> - "journeyID" : "1|1426396|4|80|19082023",<br/> + "journeyID" : "2|#VN#1#ST#1742845592#PI#0#ZI#315136#TA#0#DA#270325#1S#8000080#1T#1841#LS#8006486#LT#2024#PU#80#RT#1#CA#RE#ZE#10773#ZB#RE10773#PC#3#FR#8000080#FT#1841#TO#8006486#TT#2024#",<br/> }<br/> - "fromStation" : 651806, (Name oder EVA-Nummer)<br/> - "toStation" : 654645, (optional, Name oder EVA-Nummer)<br/> + "fromStation" : 8000080, (Name oder EVA-Nummer – bei bahn.de nur EVA-Nummer)<br/> + "toStation" : 8006486, (optional, Name oder EVA-Nummer – bei bahn.de nur EVA-Nummer)<br/> "comment" : "Beliebiger Text" (optional, überschreibt vorherigen Kommentar)<br/> } </p> |