Unverified Commit 5075461a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

expose connection price offers

parent bfdedd4d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -219,13 +219,15 @@ for my $connection ( $ris->connections ) {

	say q{};
	printf(
		"%s  (%02d:%02d)  %s  %s%s\n\n",
		$connection->dep
		? $connection->dep->strftime('%d.%m. %H:%M')
		"%s  (%02d:%02d)  %s  %s%s%s\n\n",
		$connection->dep ? $connection->dep->strftime('%d.%m. %H:%M')
		: q{??.??. ??:??},
		$connection->duration->in_units( 'hours', 'minutes' ),
		$connection->arr ? $connection->arr->strftime('%H:%M') : q{??:??},
		format_occupancy($connection),
		defined $connection->price
		? sprintf( '  %s %s', $connection->price, $connection->price_unit )
		: q{},
		$header,
	);
	for my $segment ( $connection->segments ) {
+10 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package Travel::Routing::DE::DBRIS::Connection;
use strict;
use warnings;
use 5.020;
use utf8;

use parent 'Class::Accessor';

@@ -16,7 +17,9 @@ Travel::Routing::DE::DBRIS::Connection->mk_ro_accessors(
	  duration sched_duration rt_duration
	  sched_dep rt_dep dep
	  sched_arr rt_arr arr
	  occupancy occupancy_first occupancy_second)
	  occupancy occupancy_first occupancy_second
	  price price_unit
	)
);

sub new {
@@ -29,9 +32,15 @@ sub new {
	my $ref = {
		changes      => $json->{umstiegsAnzahl},
		id           => $json->{tripId},
		price        => $json->{angebotsPreis}{betrag},
		price_unit   => $json->{angebotsPreis}{waehrung},
		strptime_obj => $strptime,
	};

	if ( $ref->{price_unit} and $ref->{price_unit} eq 'EUR' ) {
		$ref->{price_unit} = '';
	}

	if ( my $d = $json->{verbindungsDauerInSeconds} ) {
		$ref->{sched_duration} = DateTime::Duration->new(
			hours   => int( $d / 3600 ),