diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-12-17 20:09:02 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-12-17 20:09:02 +0100 |
commit | 934a9ac21a2747db10840a94aa3ed095063021d2 (patch) | |
tree | 04ec3e390d8761950f551a6859d10d15991b503d /lib/Travelynx/Controller/Api.pm | |
parent | ae21896982b5f53c0a011740f58a97be40bf0b30 (diff) |
api/import: More helpful errors, fix "lax" support
Diffstat (limited to 'lib/Travelynx/Controller/Api.pm')
-rwxr-xr-x | lib/Travelynx/Controller/Api.pm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 54908fc..834317c 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -389,6 +389,21 @@ sub import_v1 { my %opt; eval { + + if ( not $payload->{fromStation}{name} + or not $payload->{toStation}{name} ) + { + die("Missing fromStation/toStation name\n"); + } + if ( not $payload->{train}{type} or not $payload->{train}{no} ) { + die("Missing train data\n"); + } + if ( not $payload->{fromStation}{scheduledTime} + or not $payload->{toStation}{scheduledTime} ) + { + die("Missing fromStation/toStation scheduledTime\n"); + } + %opt = ( uid => $uid, train_type => sanitize( q{}, $payload->{train}{type} ), @@ -412,6 +427,7 @@ sub import_v1 { // $payload->{toStation}{scheduledTime} ), comment => sanitize( q{}, $payload->{comment} ), + lax => $payload->{lax} ? 1 : 0, ); if ( $payload->{route} and ref( $payload->{route} ) eq 'ARRAY' ) { |