summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE/DBRIS/Offer.pm
blob: 47bf5437070b23ec6d6fc0783e3e0a23895f1ea2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Travel::Routing::DE::DBRIS::Offer;

use strict;
use warnings;
use 5.020;
use utf8;

use parent 'Class::Accessor';

our $VERSION = '0.03';

Travel::Routing::DE::DBRIS::Offer->mk_ro_accessors(
	qw(class name price price_unit));

sub new {
	my ( $obj, %opt ) = @_;

	my $json = $opt{json};

	my $ref = {
		class      => $json->{klasse} =~ s{KLASSE_}{}r,
		name       => $json->{name},
		price      => $json->{preis}{betrag},
		price_unit => $json->{preis}{waehrung},
		conditions => $json->{konditionsAnzeigen},
	};

	bless( $ref, $obj );

	return $ref;
}

sub conditions {
	my ($self) = @_;

	return @{ $self->{conditions} // [] };
}

1;