diff options
author | dakkar <dakkar@thenautilus.net> | 2023-12-09 13:19:26 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2023-12-09 13:19:26 +0000 |
commit | 5c48b7da4780bcdac4757ad5c23e74e3f6744c42 (patch) | |
tree | 7b81b6523b99e85c05798667ab908ef62da39340 /lib/WebService/TFL/TubeStatus/Response.pm | |
parent | new bus api (diff) | |
download | HomePanel-5c48b7da4780bcdac4757ad5c23e74e3f6744c42.tar.gz HomePanel-5c48b7da4780bcdac4757ad5c23e74e3f6744c42.tar.bz2 HomePanel-5c48b7da4780bcdac4757ad5c23e74e3f6744c42.zip |
new tube api
Diffstat (limited to 'lib/WebService/TFL/TubeStatus/Response.pm')
-rw-r--r-- | lib/WebService/TFL/TubeStatus/Response.pm | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/WebService/TFL/TubeStatus/Response.pm b/lib/WebService/TFL/TubeStatus/Response.pm index 191abe7..4fe6524 100644 --- a/lib/WebService/TFL/TubeStatus/Response.pm +++ b/lib/WebService/TFL/TubeStatus/Response.pm @@ -1,30 +1,25 @@ package WebService::TFL::TubeStatus::Response; use Moo; -use WebService::TFL::TubeStatus::Types -all; use WebService::TFL::TubeStatus::Response::Line; use Types::Standard -all; use namespace::autoclean; has lines => ( is => 'ro', - isa => ArrayRef[LineT], + isa => ArrayRef[InstanceOf['WebService::TFL::TubeStatus::Response::Line']], required => 1, ); -sub new_from_xml { - my ($class,$doc,$xpath) = @_; +sub new_from_response { + my ($class,$response_data) = @_; - my @lines; - - for my $ls ($xpath->findnodes(q{/ws:ArrayOfLineStatus/ws:LineStatus},$doc)) { - my ($line)=$xpath->findnodes(q{ws:Line},$ls); - - my $line_object = WebService::TFL::TubeStatus::Response::Line->new_from_xml($line,$ls,$xpath); - - push @lines,$line_object; - } - - return $class->new({lines=>\@lines}); + return $class->new({ + lines=> [ + map { WebService::TFL::TubeStatus::Response::Line->new_from_response($_) } + grep { $_->{'$type'} =~ /\bLine\b/ } + $response_data->@* + ], + }); } 1; |