diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-11-04 21:54:19 +0100 |
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-11-04 21:54:19 +0100 |
| commit | 2546f12d874e065119bfbf479cac823d3163f296 (patch) | |
| tree | 9222e1018a8e7dcf5165f9adb5fed0ce2b4a473d /lib/DBInfoscreen/Helper/DBRIS.pm | |
| parent | da32f810310aba14f1a388efd257be273924dbfa (diff) | |
Diffstat (limited to 'lib/DBInfoscreen/Helper/DBRIS.pm')
| -rw-r--r-- | lib/DBInfoscreen/Helper/DBRIS.pm | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/lib/DBInfoscreen/Helper/DBRIS.pm b/lib/DBInfoscreen/Helper/DBRIS.pm index e780213..593dc90 100644 --- a/lib/DBInfoscreen/Helper/DBRIS.pm +++ b/lib/DBInfoscreen/Helper/DBRIS.pm @@ -29,8 +29,8 @@ sub new { } -sub get_journey_p { - my ( $self, %opt ) = @_; +sub get_agent { + my ($self) = @_; my $agent = $self->{user_agent}; @@ -40,11 +40,17 @@ sub get_journey_p { $agent->proxy->https($proxy); } + return $agent; +} + +sub get_journey_p { + my ( $self, %opt ) = @_; + return Travel::Status::DE::DBRIS->new_p( journey => $opt{id}, cache => $self->{realtime_cache}, promise => 'Mojo::Promise', - user_agent => $agent->request_timeout(10) + user_agent => $self->get_agent->request_timeout(10) ); } @@ -56,20 +62,12 @@ sub get_polyline_p { my $trip_id = $opt{id}; my $promise = Mojo::Promise->new; - my $agent = $self->{user_agent}; - - if ( my $proxy = $ENV{DBFAKEDISPLAY_DBRIS_PROXY} ) { - $agent = Mojo::UserAgent->new; - $agent->proxy->http($proxy); - $agent->proxy->https($proxy); - } - Travel::Status::DE::DBRIS->new_p( journey => $trip_id, with_polyline => 1, cache => $self->{realtime_cache}, promise => 'Mojo::Promise', - user_agent => $agent->request_timeout(10) + user_agent => $self->get_agent->request_timeout(10) )->then( sub { my ($dbris) = @_; @@ -90,4 +88,25 @@ sub get_polyline_p { return $promise; } +sub get_wagonorder_p { + my ( $self, %opt ) = @_; + + $self->{log} + ->debug("get_wagonorder_p($opt{train_type} $opt{train_no} @ $opt{eva})"); + + return Travel::Status::DE::DBRIS->new_p( + cache => $self->{main_cache}, + failure_cache => $self->{realtime_cache}, + promise => 'Mojo::Promise', + user_agent => $self->get_agent->request_timeout(10), + formation => { + departure => $opt{datetime}, + eva => $opt{eva}, + train_type => $opt{train_type}, + train_number => $opt{train_no} + }, + developer_mode => $self->{log}->is_level('debug') ? 1 : 0, + ); +} + 1; |
