lass::Accessor';
use DateTime;
use DateTime::Format::Strptime;
use Encode qw(decode encode);
use JSON;
use LWP::UserAgent;
use IO::Uncompress::Gunzip;
use Travel::Status::DE::DBRIS;
use Travel::Routi
n',
);
my $json = $self->{json} = JSON->new->utf8->canonical;
if ( $conf{async} ) {
$self->{req} = $req;
return $self;
}
if ( $conf{json} ) {
$self->{raw_json} = $conf{json};
}
else {
my $req_str = $json->encode($req);
if ( $self->{developer_mode} ) {
say "requesting $req_str";
}
my ( $raw_content, $error )
= $self->post_with_cache( $req_url, $req_str );
if ($err
my $json = $opt{json};
my $ref = {
class => $json->{klasse} =~ s{KLASSE_}{}r,
name => $json->{name},
price => $json->{preis}{betrag},
price_unit => $json->{pre
ons => $json->{konditionsAnzeigen},
is_upsell => exists $json->{upsellInfos} ? 1 : 0,
is_cross_sell => exists $json->{crosssellInfos} ? 1 : 0,
};
for my $relation ( @{ $json->{angebot
@_;
my $json = $opt{json};
my $strptime = $opt{strptime_obj};
my $ref = {
arr_eva => $json->{ankunftsOrtExtId},
arr_name => $json->{ankunftsOrt},
dep_eva => $json->{abfahrts
$json->{abfahrtsOrt},
train => $json->{verkehrsmittel}{name},
train_short => $json->{verkehrsmittel}{kurzText},
train_mid => $json->{verkehrsmittel}{mittelText},
train_long => $json-
ion => $json->{verkehrsmittel}{richtung},
distance_m => $json->{distanz},
feasibility => $json->{anschlussBewertungCode},
journey_id => $json->{journeyId},
};
if ( my $ts = $json->{abfahr
) = @_;
my $json = $opt{json};
my $strpdate = $opt{strpdate_obj};
my $strptime = $opt{strptime_obj};
my $ref = {
changes => $json->{umstiegsAnzahl},
feasibility => $json->{ereignisZu
ed => $json->{isAlternativeVerbindung},
id => $json->{tripId},
recon => $json->{ctxRecon},
price => $json->{angebotsPreis}{betrag},
price_unit => $json->{ange
{price_unit} and $ref->{price_unit} eq 'EUR' ) {
$ref->{price_unit} = '€';
}
if ( my $d = $json->{verbindungsDauerInSeconds} ) {
$ref->{sched_duration} = DateTime::Duration->new(
hours =