File Coverage

blib/lib/OpenGbg.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1 4     4   159211 use 5.14.0;
  4         14  
  4         181  
2 4     4   17 use strict;
  4         5  
  4         103  
3 4     4   14 use warnings;
  4         9  
  4         168  
4             package OpenGbg;
5              
6             our $VERSION = '0.1301'; # VERSION
7             # ABSTRACT: An interface to the Open Data API of Gothenburg
8              
9 4     4   1153 use OpenGbg::Handler;
  0            
  0            
10              
11             sub new {
12             shift;
13             return OpenGbg::Handler->new(@_);
14             }
15              
16             1;
17              
18             __END__
19              
20             =pod
21              
22             =encoding utf-8
23              
24             =head1 NAME
25              
26             OpenGbg - An interface to the Open Data API of Gothenburg
27              
28             =head1 VERSION
29              
30             Version 0.1301, released 2015-01-16.
31              
32             =head1 SYNOPSIS
33              
34             use OpenGbg;
35              
36             my $opengbg = OpenGbg->new(key => 'secret-api-key');
37              
38             $response = $opengbg->styr_och_stall->get_bike_stations;
39              
40             print $response->stations->get_by_index(0)->to_text;
41              
42             =head1 DESCRIPTION
43              
44             OpenGbg is a way to connect to and use the open data published by the city of L<Gothenburg|https://en.wikipedia.org/wiki/Gothenburg>.
45              
46             The open data homepage is located at L<http://data.goteborg.se/>. All official documentation is in Swedish, but the license agreement is published
47             in English L<here|https://gbgdata.wordpress.com/goopen/>.
48              
49             To use the API you need to get a free api key.
50              
51             =head1 METHOD
52              
53             =head2 new()
54              
55             Takes an optional key-value pair, the key is C<key> and the value your api key, see L<authenticate|/"AUTHENTICATE">.
56              
57             Returns a L<OpenGbg::Handler> object on which you then call the L<services|/"SERVICES">.
58              
59             =head1 AUTHENTICATE
60              
61             Once you have your api key you can use it in two different ways:
62              
63             1. You can give it in the constructor:
64              
65             my $opengbg = OpenGbg->new(key => 'secret-api-key');
66              
67             2. You can save it in a file named C<.opengbg.ini> in your homedir:
68              
69             [API]
70             key = secret-api-key
71              
72             =head1 SERVICES
73              
74             The following services are currently implemented in this distribution:
75              
76             L<AirQuality|OpenGbg::Service::AirQuality> - Data on air quality
77              
78             L<Bridge|OpenGbg::Service::Bridge> - Data on the openness of Göta Älvbron
79              
80             L<StyrOchStall|OpenGbg::Service::StyrOchStall> - Data on rent-a-bike stations
81              
82             L<TrafficCamera|OpenGbg::Service::TrafficCamera> - Data on traffic cameras, and their images
83              
84             =head1 NAMING
85              
86             Most names related to the services are de-camelized, while others are lower-cased (no underscores). For example, the service 'GetBikeStations' is called like this:
87              
88             my $gbg = OpenGbg->new;
89             my $stations = $gbg->get_bike_stations;
90              
91             All calls to services are prefixed with 'get' even if the service isn't named that way. On the other hand, the 'service' suffix on some services are removed.
92              
93             Date/time intervals are always called 'start' and 'end' (in the web services they are sometimes called 'start' and 'stop').
94              
95             =head1 DISCLAIMER
96              
97             This is not an official distribution.
98              
99             =head1 SOURCE
100              
101             L<https://github.com/Csson/p5-OpenGbg>
102              
103             =head1 HOMEPAGE
104              
105             L<https://metacpan.org/release/OpenGbg>
106              
107             =head1 AUTHOR
108              
109             Erik Carlsson <info@code301.com>
110              
111             =head1 COPYRIGHT AND LICENSE
112              
113             This software is copyright (c) 2015 by Erik Carlsson.
114              
115             This is free software; you can redistribute it and/or modify it under
116             the same terms as the Perl 5 programming language system itself.
117              
118             =cut