| 1 | 6 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package OpenGbg::Service::StyrOchStall; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Entry point to the StyrOchStall bike rental service | ||||||||||||||||||||||||||||
| 8 | 6 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | 6 | our $VERSION = '0.1402'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use OpenGbg::Elk; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | with 'OpenGbg::Service::Getter'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use Types::Standard qw/Str/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use OpenGbg::Service::StyrOchStall::GetBikeStation; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use OpenGbg::Service::StyrOchStall::GetBikeStations; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 6 | has handler => ( | |||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||
| 22 | required => 1, | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | 6 | has service_base => ( | |||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||
| 26 | isa => Str, | ||||||||||||||||||||||||||||
| 27 | default => 'StyrOchStall/v0.1/', | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub get_bike_station { | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_bike_station: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 0 | my $id = shift; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my $url = "GetBikeStation/$id/%s?"; | |||||||||||||||||||||||||||
| 35 | 0 | my $response = $self->getter($url, 'get_bike_station'); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | return OpenGbg::Service::StyrOchStall::GetBikeStation->new(xml => $response); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | sub get_bike_stations { | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_bike_stations: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | my $geo = ''; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | if(exists $args{'lat'} && exists $args{'long'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $args{"lat"} and exists $args{"long"}
MC/DC0%0/2
exists $args{"lat"} and exists $args{"long"}
exists $args{"lat"}
exists $args{"long"}
Truth table0%0/3
A and B
A= exists $args{"lat"}B= exists $args{"long"}
| |||||||||||||||||||||||||||||
| 46 | 0 | my %hash = ( latitude => $args{'lat'}, longitude => $args{'long'}, radius => $args{'radius'} ); | |||||||||||||||||||||||||||
| 47 | 0 | $geo = join '&' => map { "$_=$hash{ $_ }" } keys %hash; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | my $url = "GetBikeStations/%s?$geo&"; | |||||||||||||||||||||||||||
| 51 | 0 | my $response = $self->getter($url, 'get_bike_stations'); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | return OpenGbg::Service::StyrOchStall::GetBikeStations->new(xml => $response); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 6 | 1; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =pod | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 NAME | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | OpenGbg::Service::StyrOchStall - Entry point to the StyrOchStall bike rental service | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head1 VERSION | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Version 0.1402, released 2016-08-12. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | my $service = OpenGbg->new->styr_och_stall; | ||||||||||||||||||||||||||||
| 77 | my $stations = $service->get_bike_stations; | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | print $stations->get_by_index(0)->to_text; | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Styr och ställ is Gothenburg's bike share program. This service has a couple of methods to get data about the bike stations. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | L<Official documentation|http://data.goteborg.se/Pages/Webservice.aspx?ID=10> | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | See L<OpenGbg> for general information. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head1 METHODS | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head2 get_bike_station($id) | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | C<$id> is the station id for the station you want to get information about. You'll need to first have fetched the stations with L<get_bike_stations|/"get_bike_stations(%geography)"> to get the ids. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Returns a L<GetBikeStation|OpenGbg::Service::StyrOchStall::GetBikeStation> object. | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head2 get_bike_stations(%geography) | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | C<%geography> is an optional hash used to limit returned stations to a geographical area. | ||||||||||||||||||||||||||||
| 100 | Its keys are C<lat> and C<long>, and optionally C<radius> (in metres). | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | If C<%geography> is absent no geographic filtering is done. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Returns a L<GetBikeStations|OpenGbg::Service::StyrOchStall::GetBikeStations> object. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head1 EXCEPTIONS | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | If the http call to the web service fails, a L<BadResponseFromService|OpenGbg::Exception::BadResponseFromService> exception is thrown. Use L<Try::Tiny> to catch. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 SOURCE | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | L<https://github.com/Csson/p5-OpenGbg> | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 HOMEPAGE | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | L<https://metacpan.org/release/OpenGbg> | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | Erik Carlsson <info@code301.com> | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | This software is copyright (c) 2016 by Erik Carlsson. | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 127 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =cut | ||||||||||||||||||||||||||||