summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Travel/Status/DE/DBWagenreihung/Carriage.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/DBWagenreihung/Carriage.pm b/lib/Travel/Status/DE/DBWagenreihung/Carriage.pm
index 8c93fed..df8b1d7 100644
--- a/lib/Travel/Status/DE/DBWagenreihung/Carriage.pm
+++ b/lib/Travel/Status/DE/DBWagenreihung/Carriage.pm
@@ -13,9 +13,24 @@ Travel::Status::DE::DBWagenreihung::Carriage->mk_ro_accessors(
qw(class_type is_closed is_dosto is_locomotive is_powercar
number model section uic_id type
start_meters end_meters length_meters start_percent end_percent length_percent
+ has_priority_seats has_ac has_quiet_zone has_bahn_comfort has_wheelchair_space
+ has_wheelchair_toilet has_family_zone has_infant_cabin has_info has_bistro
+ has_first_class has_second_class
)
);
+my %type_map = (
+ SEATS_SEVERELY_DISABLE => 'priority_seats',
+ AIR_CONDITION => 'ac',
+ ZONE_QUIET => 'quiet_zone',
+ SEATS_BAHN_COMFORT => 'bahn_comfort',
+ INFO => 'info',
+ TOILET_WHEELCHAIR => 'wheelchair_toilet',
+ WHEELCHAIR_SPACE => 'wheelchair_space',
+ ZONE_FAMILY => 'family_zone',
+ CABIN_INFANT => 'infant_cabin',
+);
+
sub new {
my ( $obj, %opt ) = @_;
my $ref = {};
@@ -40,6 +55,14 @@ sub new {
$self->parse_type;
+ for my $amenity ( @{ $json{amenities} // [] } ) {
+ my $type = $amenity->{type};
+ if ( $type_map{$type} ) {
+ my $key = 'has_' . $type_map{$type};
+ $self->{$key} = 1;
+ }
+ }
+
if ( $json{status} and $json{status} eq 'CLOSED' ) {
$ref->{is_closed} = 1;
}
@@ -54,6 +77,9 @@ sub new {
$ref->{is_powercar} = 1;
}
+ $ref->{has_first_class} = $json{type}{hasFirstClass};
+ $ref->{has_second_class} = $json{type}{hasEconomyClass};
+
if ( $ref->{type} =~ m{AB} ) {
$ref->{class_type} = 12;
}