summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-10-02 22:08:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2022-10-02 22:08:16 +0200
commit642f7bcb1d7bad80aa60fa1d19c51ef5943e8b62 (patch)
tree490c2cc730b99c72ba0c776376ab3dc8ab135ebc /lib/Travel/Status/DE/HAFAS.pm
parent464b6b1583c0a5fa3bf38a9711bce9f200a22378 (diff)
NASA: switch to mgate
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS.pm')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index 3a90353..eb767f7 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -72,10 +72,25 @@ my %hafas_instance = (
},
},
NASA => {
- url => 'https://reiseauskunft.insa.de/bin/stboard.exe',
+ mgate => 'https://reiseauskunft.insa.de/bin/mgate.exe',
stopfinder => 'https://reiseauskunft.insa.de/bin/ajax-getstop.exe',
name => 'Nahverkehrsservice Sachsen-Anhalt',
productbits => [qw[ice ice regio regio regio tram bus ondemand]],
+ request => {
+ client => {
+ id => 'NASA',
+ v => '4000200',
+ type => 'IPH',
+ name => 'nasaPROD',
+ os => 'iPhone OS 13.1.2',
+ },
+ ver => '1.18',
+ auth => {
+ type => 'AID',
+ aid => 'nasa-' . 'apps',
+ },
+ lang => 'deu',
+ },
},
NVV => {
url => 'https://auskunft.nvv.de/auskunft/bin/jp/stboard.exe',
@@ -402,12 +417,14 @@ sub check_input_error {
sub check_mgate {
my ($self) = @_;
- if ( $self->{raw_json}{err} ) {
- $self->{errstr} = 'error code is ' . $self->{raw_json}{err};
+ if ( $self->{raw_json}{err} and $self->{raw_json}{err} ne 'OK' ) {
+ $self->{errstr} = $self->{raw_json}{errTxt}
+ // 'error code is ' . $self->{raw_json}{err};
$self->{errcode} = $self->{raw_json}{err};
}
elsif ( defined $self->{raw_json}{cInfo}{code}
- and $self->{raw_json}{cInfo}{code} ne 'OK' )
+ and $self->{raw_json}{cInfo}{code} ne 'OK'
+ and $self->{raw_json}{cInfo}{code} ne 'VH' )
{
$self->{errstr} = 'cInfo code is ' . $self->{raw_json}{cInfo}{code};
$self->{errcode} = $self->{raw_json}{cInfo}{code};
@@ -614,9 +631,11 @@ sub parse_mgate {
my $train_type = $product->{prodCtx}{catOutS};
my $line_no = $product->{prodCtx}{line};
- my $operator = $opL[ $product->{oprX} ];
- if ($operator) {
- $operator = $operator->{name};
+ my $operator;
+ if ( defined $product->{oprX} ) {
+ if ( my $opref = $opL[ $product->{oprX} ] ) {
+ $operator = $opref->{name};
+ }
}
push(