Incorrect search filter: invalid characters - *.p[ml]
API-DeutscheBahn-Fahrplan

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN

OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>

META.json  view on Meta::CPAN

            "HTTP::Tiny" : "0.076",
            "JSON::XS" : "3.04",
            "Moose" : "2.20",
            "URI" : "1.74",
            "URI::Encode" : "v1.1.1",
            "URI::QueryParam" : "1.74",
            "namespace::autoclean" : "0",
            "perl" : "5.008001"
         }
      },
      "test" : {
         "requires" : {
            "Test::Most" : "0.35"
         }
      }
   },
   "provides" : {
      "API::DeutscheBahn::Fahrplan" : {
         "file" : "lib/API/DeutscheBahn/Fahrplan.pm",
         "version" : "0.02"
      }

cpanfile  view on Meta::CPAN


requires 'Carp', '1.50';
requires 'HTTP::Tiny', '0.076';
requires 'JSON::XS', '3.04';
requires 'Moose', '2.20';
requires 'URI', '1.74';
requires 'URI::Encode', '1.1.1';
requires 'URI::QueryParam', '1.74';
requires 'namespace::autoclean', '0';

on 'test' => sub {
    requires 'Test::Most', '0.35';
};

t/00_compile.t  view on Meta::CPAN

use strict;
use Test::Most;

use_ok $_ for qw(
    API::DeutscheBahn::Fahrplan
);

done_testing;

t/01_main.t  view on Meta::CPAN

use strict;
use warnings;

use Test::Most;
use API::DeutscheBahn::Fahrplan;


# SETUP

note 'basic object tests';

my $fahrplan_free = API::DeutscheBahn::Fahrplan->new;
isa_ok $fahrplan_free, 'API::DeutscheBahn::Fahrplan';

my $fahrplan_plus = API::DeutscheBahn::Fahrplan->new( access_token => '123' );
isa_ok $fahrplan_plus, 'API::DeutscheBahn::Fahrplan';


# construct the user agent string
my $user_agent = sprintf 'Perl-API::DeutscheBahn::Fahrplan::%s',

t/01_main.t  view on Meta::CPAN


cmp_deeply $fahrplan_plus->_client->default_headers,
    {
    Accept        => 'application/json',
    'User-Agent'  => $user_agent,
    Authorization => 'Bearer 123',
    },
    'set correct headers for Fahrplan plus';


note 'testing uri generation';


my @uri_tests = (

    # Successful

    {    #
        method => 'location',
        params => { name => 'Berlin' },
        regex  => qr!/location/Berlin$!,
    },
    {    #
        method => 'arrival_board',

t/01_main.t  view on Meta::CPAN

        throws_regex => qr/Missing path parameter: name/,
    },
    {    #
        method       => 'departure_board',
        params       => { id => '8596008' },
        throws       => 1,
        throws_regex => qr/Missing query parameter: date/,
    }
);

for (@uri_tests) {

    my ( $method, %params ) = ( $_->{method}, %{ $_->{params} } );

    if ( $_->{throws} ) {
        throws_ok { $fahrplan_free->_create_uri( $method, %params ) }
        $_->{throws_regex}, 'error thrown successfully'
            and next;
    }

    my ( undef, $uri ) = $fahrplan_free->_create_uri( $method, %params );

    is $uri->scheme, 'https', 'uri scheme set to https';
    is $uri->host, 'api.deutschebahn.com', 'uri host set';

    like $uri->path_query, $_->{regex},
        sprintf 'successfully created uri for %s', $method;
}

done_testing;



( run in 0.273 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )