Skip Menu |

This queue is for tickets about the Net-NationalRail-LiveDepartureBoards CPAN distribution.

Report information
The Basics
Id: 53629
Status: resolved
Priority: 0/
Queue: Net-NationalRail-LiveDepartureBoards

People
Owner: Nobody in particular
Requestors: DASHI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Added CRS filters as per webservice [ listed as a TODO in module source :-) ]
The Live Departure SOAP calls all have a filter parameter filterCRS to specify a station + a filterType parameter to specify 'from' or 'to'. Attached patch adds the filter params to the soap call if they're specified - as with the webservice, filtertype defaults to 'to' if a filter CRS is supplied but no filtertype is chosen.
Subject: add_filters.patch
*** /usr/local/share/perl/5.10.0/Net/NationalRail/LiveDepartureBoards.pm 2009-01-08 20:21:28.000000000 +0000 --- /tmp/buffer-content-10236jW5 2010-01-05 19:40:19.000000000 +0000 *************** *** 71,93 **** } sub _station_board_request { ! my $method = shift; ! my $self = shift; ! my %arg = @_; ! ! my $result = _soap_request( ! $method, ! URI_PREFIX . 'types', ! SOAP::Data->name(numRows => $arg{'rows'}), ! SOAP::Data->name(crs => $arg{'crs'}), ! # TODO: add filters. ! ); ! ! if ($result->fault) { ! die join ', ', $result->faultcode, $result->faultstring; ! } else { ! return $result->result(); ! } } sub _soap_request { --- 71,103 ---- } sub _station_board_request { ! my $method = shift; ! my $self = shift; ! my %arg = @_; ! ! my @opt_args; ! if(exists($arg{filtercrs})) { ! push(@opt_args, SOAP::Data->name(filterCrs => $arg{filtercrs})); ! if(exists($arg{filtertype})) { ! push(@opt_args,SOAP::Data->name(filterType => $arg{filtertype})); ! } else { ! push(@opt_args,SOAP::Data->name(filterType => 'to')); ! } ! } ! ! my $result = Net::NationalRail::LiveDepartureBoards::_soap_request( ! $method, ! URI_PREFIX . 'types', ! SOAP::Data->name(numRows => $arg{'rows'}), ! SOAP::Data->name(crs => $arg{'crs'}), ! @opt_args ! ); ! ! if ($result->fault) { ! die join ', ', $result->faultcode, $result->faultstring; ! } else { ! return $result->result(); ! } } sub _soap_request {
Subject: example.pl
use strict; use warnings; use Data::Dumper; use Net::NationalRail::LiveDepartureBoards; my $results; eval { my $ldb = Net::NationalRail::LiveDepartureBoards->new(); $results = $ldb->departures( rows => 10, crs => 'CDF', filtercrs=> 'BRI', filtertype => 'to' ); }; if($@) { die "Error calling webservice: %s",$@; } print Dumper($results),"\n";
On Tue Jan 12 17:21:31 2010, DASHI wrote: Show quoted text
> The Live Departure SOAP calls all have a filter parameter filterCRS to > specify a station + a filterType parameter to specify 'from' or 'to'. > > Attached patch adds the filter params to the soap call if they're > specified - as with the webservice, filtertype defaults to 'to' if a > filter CRS is supplied but no filtertype is chosen.
Awesome. :) I've released 0.02 with a refactored version of your patch - please give it a spin once it hits the mirrors and check that I've not messed it up. Thanks, Tim