summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-03-26 12:06:35 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2024-03-26 12:06:35 +0100
commit9ef75520eeaf1a568650f7368782ac63b80c09b2 (patch)
tree0a933ef6dec6a6d90178e97022b14f9fe8b45bf5 /lib/Travel/Status/DE/HAFAS.pm
parent20b537ca899215ef0d4989f350547159426c5f32 (diff)
Preliminary support for stop-specific operators / operator changes (#10)
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS.pm')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index 0489901..cbd23cc 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -18,6 +18,7 @@ use Travel::Status::DE::HAFAS::Journey;
use Travel::Status::DE::HAFAS::Location;
use Travel::Status::DE::HAFAS::Message;
use Travel::Status::DE::HAFAS::Polyline qw(decode_polyline);
+use Travel::Status::DE::HAFAS::Product;
use Travel::Status::DE::HAFAS::StopFinder;
our $VERSION = '5.05';
@@ -702,6 +703,20 @@ sub add_message {
return $message;
}
+sub parse_prodL {
+ my ($self) = @_;
+
+ my $common = $self->{raw_json}{svcResL}[0]{res}{common};
+ return [
+ map {
+ Travel::Status::DE::HAFAS::Product->new(
+ common => $common,
+ product => $_
+ )
+ } @{ $common->{prodL} }
+ ];
+}
+
sub parse_search {
my ($self) = @_;
@@ -730,6 +745,8 @@ sub parse_journey {
return $self;
}
+ my $prodL = $self->parse_prodL;
+
my @locL = map { Travel::Status::DE::HAFAS::Location->new( loc => $_ ) }
@{ $self->{raw_json}{svcResL}[0]{res}{common}{locL} // [] };
my $journey = $self->{raw_json}{svcResL}[0]{res}{journey};
@@ -748,6 +765,7 @@ sub parse_journey {
$self->{result} = Travel::Status::DE::HAFAS::Journey->new(
common => $self->{raw_json}{svcResL}[0]{res}{common},
+ prodL => $prodL,
locL => \@locL,
journey => $journey,
polyline => \@polyline,
@@ -766,6 +784,8 @@ sub parse_journey_match {
return $self;
}
+ my $prodL = $self->parse_prodL;
+
my @locL = map { Travel::Status::DE::HAFAS::Location->new( loc => $_ ) }
@{ $self->{raw_json}{svcResL}[0]{res}{common}{locL} // [] };
@@ -776,6 +796,7 @@ sub parse_journey_match {
@{ $self->{results} },
Travel::Status::DE::HAFAS::Journey->new(
common => $self->{raw_json}{svcResL}[0]{res}{common},
+ prodL => $prodL,
locL => \@locL,
journey => $result,
hafas => $self,
@@ -794,6 +815,8 @@ sub parse_board {
return $self;
}
+ my $prodL = $self->parse_prodL;
+
my @locL = map { Travel::Status::DE::HAFAS::Location->new( loc => $_ ) }
@{ $self->{raw_json}{svcResL}[0]{res}{common}{locL} // [] };
my @jnyL = @{ $self->{raw_json}{svcResL}[0]{res}{jnyL} // [] };
@@ -803,6 +826,7 @@ sub parse_board {
@{ $self->{results} },
Travel::Status::DE::HAFAS::Journey->new(
common => $self->{raw_json}{svcResL}[0]{res}{common},
+ prodL => $prodL,
locL => \@locL,
journey => $result,
hafas => $self,