API-DeutscheBahn-Fahrplan
view release on metacpan or search on metacpan
lib/API/DeutscheBahn/Fahrplan.pm view on Meta::CPAN
package API::DeutscheBahn::Fahrplan;
use Moose;
use namespace::autoclean;
# VERSION
our $VERSION = '0.02';
# IMPORTS
use Carp;
use HTTP::Tiny ();
use JSON::XS ();
use URI ();
use URI::Encode qw(uri_encode);
use URI::QueryParam ();
=encoding utf-8
=head1 NAME
API::DeutscheBahn::Fahrplan - Deutsche Bahn Fahrplan API Client
=head1 SYNOPSIS
my $fahrplan_free = API::DeutscheBahn::Fahrplan->new;
my $fahrplan_plus = API::DeutscheBahn::Fahrplan->new( access_token => $access_token );
$data = $fahrplan->location( name => 'Berlin' );
$data = $fahrplan->arrival_board( id => 8503000, date => '2018-09-24T11:00:00' );
$data = $fahrplan->departure_board( id => 8503000, date => '2018-09-24T11:00:00' );
$data = $fahrplan->journey_details( id => '87510%2F49419%2F965692%2F453678%2F80%3fstation_evaId%3D850300' );
=head1 DESCRIPTION
API::DeutscheBahn::Fahrplan provides a simple interface to the Deutsche Bahn Fahrplan
API. See L<https://developer.deutschebahn.com/> for further information.
=head1 ATTRIBUTES
=over
=item fahrplan_free_url
URL endpoint for DB Fahrplan free version. Defaults to I<https://api.deutschebahn.com/freeplan/v1>.
=item fahrplan_plus_url
URL endpoint for DB Fahrplan subscribed version. Defaults to I<https://api.deutschebahn.com/fahrplan-plus/v1>.
=item access_token
Access token to sign requests. If provided the client will use the C<fahrplan_plus_url> endpoint.
=back
=cut
has 'fahrplan_free_url' => (
is => 'ro',
isa => 'Str',
default => 'https://api.deutschebahn.com/freeplan/v1',
);
has 'fahrplan_plus_url' => (
is => 'ro',
isa => 'Str',
default => 'https://api.deutschebahn.com/fahrplan-plus/v1',
);
has 'access_token' => (
is => 'ro',
isa => 'Str',
);
has '_client' => (
is => 'ro',
( run in 0.673 second using v1.01-cache-2.11-cpan-39bf76dae61 )