From ef1ace49d1ac93f198172752e182d6e00a56910f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 10 Jan 2014 08:22:02 +0100 Subject: IRIS.pm: make iris_base URL configurable --- lib/Travel/Status/DE/IRIS.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/Travel') diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index e496f88..e20d758 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -28,6 +28,8 @@ sub new { my $self = { datetime => $opt{datetime} // DateTime->now( time_zone => 'Europe/Berlin' ), + iris_base => $opt{iris_base} + // 'http://iris.noncd.db.de/iris-tts/timetable', station => $opt{station}, user_agent => $ua, }; @@ -36,8 +38,7 @@ sub new { $ua->env_proxy; - my $res_st = $ua->get( - 'http://iris.noncd.db.de/iris-tts/timetable/station/' . $opt{station} ); + my $res_st = $ua->get( $self->{iris_base} . '/station/' . $opt{station} ); if ( $res_st->is_error ) { $self->{errstr} = $res_st->status_line; @@ -123,9 +124,7 @@ sub get_timetable { my $ua = $self->{user_agent}; my $res = $ua->get( - $dt->strftime( - "http://iris.noncd.db.de/iris-tts/timetable/plan/${eva}/%y%m%d/%H") - ); + $dt->strftime( $self->{iris_base} . "/plan/${eva}/%y%m%d/%H" ) ); if ( $res->is_error ) { $self->{errstr} = $res->status_line; @@ -150,8 +149,7 @@ sub get_realtime { my ($self) = @_; my $eva = $self->{nodes}{station}->getAttribute('eva'); - my $res = $self->{user_agent} - ->get("http://iris.noncd.db.de/iris-tts/timetable/fchg/${eva}"); + my $res = $self->{user_agent}->get( $self->{iris_base} . "/fchg/${eva}" ); if ( $res->is_error ) { $self->{errstr} = $res->status_line; @@ -292,6 +290,10 @@ Arguments: A DateTime(3pm) object specifying the point in time. Optional, defaults to the current date and time. +=item B => I + +IRIS base url, defaults to C<< http://iris.noncd.db.de/iris-tts/timetable >>. + =item B => I Mandatory: Which station to return departures for. Note that this is not a -- cgit v1.2.3