diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-03-27 13:27:15 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-03-27 13:27:15 +0100 |
commit | aa9e55128f287b2e264df22997ec282b13f16fbe (patch) | |
tree | c7900bae91466f01fc280bf4f577460f8e281df9 /lib/DBInfoscreen/Helper | |
parent | 67c7349906ce6c9c93cc45f23046853f3ad07fbc (diff) |
request EFA occupancy data (works for some VRR trains)
Diffstat (limited to 'lib/DBInfoscreen/Helper')
-rw-r--r-- | lib/DBInfoscreen/Helper/Marudor.pm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/Marudor.pm index dad9dc7..dce22cf 100644 --- a/lib/DBInfoscreen/Helper/Marudor.pm +++ b/lib/DBInfoscreen/Helper/Marudor.pm @@ -80,6 +80,35 @@ sub get_json_p { return $promise; } +sub get_efa_occupancy { + my ( $self, %opt ) = @_; + + my $eva = $opt{eva}; + my $train_no = $opt{train_no}; + my $promise = Mojo::Promise->new; + + $self->get_json_p( $self->{realtime_cache}, + "https://vrrf.finalrewind.org/_eva/${eva}.json" )->then( + sub { + my ($utilization_json) = @_; + + if ( $utilization_json->{$train_no}{occupancy} ) { + $promise->resolve( $utilization_json->{$train_no}{occupancy} ); + return; + } + $promise->reject; + return; + } + )->catch( + sub { + $promise->reject; + return; + } + )->wait; + + return $promise; +} + sub get_train_utilization { my ( $self, %opt ) = @_; |