Commit ef1ace49 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

IRIS.pm: make iris_base URL configurable

parent e09d5370
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -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<iris_base> => I<url>

IRIS base url, defaults to C<< http://iris.noncd.db.de/iris-tts/timetable >>.

=item B<station> => I<stationcode>

Mandatory: Which station to return departures for. Note that this is not a