| 1 | package Travel::Status::MOTIS::Stop; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use 5.020; | ||
| 6 | |||
| 7 | use parent 'Class::Accessor'; | ||
| 8 | |||
| 9 | our $VERSION = '0.07'; | ||
| 10 | |||
| 11 | Travel::Status::MOTIS::Stop->mk_ro_accessors( | ||
| 12 | qw( | ||
| 13 | id | ||
| 14 | parent_id | ||
| 15 | name | ||
| 16 | type | ||
| 17 | lat | ||
| 18 | lon | ||
| 19 | ) | ||
| 20 | ); | ||
| 21 | |||
| 22 | sub from_match { | ||
| 23 | my ( $obj, %opt ) = @_; | ||
| 24 | |||
| 25 | my $json = $opt{json}; | ||
| 26 | |||
| 27 | my $ref = { | ||
| 28 | id => $json->{id}, | ||
| 29 | name => $json->{name}, | ||
| 30 | lat => $json->{lat}, | ||
| 31 | lon => $json->{lon}, | ||
| 32 | }; | ||
| 33 | |||
| 34 | bless( $ref, $obj ); | ||
| 35 | |||
| 36 | return $ref; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub from_stopover { | ||
| 40 | my ( $obj, %opt ) = @_; | ||
| 41 | |||
| 42 | my $json = $opt{json}; | ||
| 43 | |||
| 44 | my $ref = { | ||
| 45 | id => $json->{stopId}, | ||
| 46 | parent_id => $json->{parentId}, | ||
| 47 | name => $json->{name}, | ||
| 48 | lat => $json->{lat}, | ||
| 49 | lon => $json->{lon}, | ||
| 50 | }; | ||
| 51 | |||
| 52 | bless( $ref, $obj ); | ||
| 53 | |||
| 54 | return $ref; | ||
| 55 | } | ||
| 56 | |||
| 57 | sub TO_JSON { | ||
| 58 | my ($self) = @_; | ||
| 59 | |||
| 60 | return { %{$self} }; | ||
| 61 | } | ||
| 62 | |||
| 63 | 1; |