OpenGbg/Service/AirQuality.pm

filter: Statementstmt 71.4% 30 / 42 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod 100% 2 / 2 totaltotal 74.0% 40 / 54 CC 1 SCAR 1.8
CC
1
Cov
71%
get_latest_measurement
2.0
get_measurements
2.0
BEGIN
1.0
CRAP 1.2
« OpenGbg/Service/StyrOchStall/GetBikeStations.pm ↑ Summary OpenGbg/Service/TrafficCamera.pm »
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::AirQuality;
6  
7 # ABSTRACT: Entry point to the Air Quality service
8 6 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 6 our $VERSION = '0.1401';
10  
11 6 ▶use OpenGbg::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use Types::Standard qw/Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 6 ▶use OpenGbg::Service::AirQuality::GetLatestMeasurement;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶use OpenGbg::Service::AirQuality::GetMeasurements;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 6 with 'OpenGbg::Service::Getter';
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 => 'AirQualityService/v1.0/',
28 );
29  
30 sub get_latest_measurement {
31 0 ▶ my $self = shift;
Subroutine get_latest_measurement: not called CC=1 SCAR=6.9
Pod documented
32  
33 0 my $url = 'LatestMeasurement/%s?';
34 0 my $response = $self->getter($url, 'latest_measurement');
35  
36 0 return OpenGbg::Service::AirQuality::GetLatestMeasurement->new(xml => $response);
37 }
38 sub get_measurements {
39 0 ▶ my $self = shift;
Subroutine get_measurements: not called CC=1 SCAR=6.9
Pod documented
40 0 my %args = @_;
41  
42 0 my %dates = (startdate => $args{'start'}, enddate => $args{'end'});
43 0 my $dates = join '&' => map { "$_=$dates{ $_ }"} keys %dates;
44  
45 0 my $url = "Measurements/%s?$dates&";
46 0 my $response = $self->getter($url, 'measurements');
47  
48 0 return OpenGbg::Service::AirQuality::GetMeasurements->new(xml => $response);
49 }
50  
51 6 __PACKAGE__->meta->make_immutable;
52  
53 6 1;
54  
55 __END__
56  
57 =pod
58  
59 =encoding utf-8
60  
61 =head1 NAME
62  
63 OpenGbg::Service::AirQuality - Entry point to the Air Quality service
64  
65 =head1 VERSION
66  
67 Version 0.1401, released 2016-05-05.
68  
69 =head1 SYNOPSIS
70  
71 my $service = OpenGbg->new->air_quality;
72 my $response = $service->get_latest_measurement;
73  
74 print $response->measurement->to_text;
75  
76 =head1 DESCRIPTION
77  
78 Gothenburg publishes hourly readings on weather and air quality. The service publishes two methods to get this data.
79  
80 L<Official documentation|http://data.goteborg.se/Pages/Webservice.aspx?ID=13>
81  
82 See L<OpenGbg> for general information.
83  
84 =head1 METHODS
85  
86 =head2 get_latest_measurement
87  
88 Returns a L<GetLatestMeasurement|OpenGbg::Service::AirQuality::GetLatestMeasurement> object.
89  
90 =head2 get_measurements(%dates)
91  
92 C<%dates> is a hash that filters returned measurements. Its keys are C<start> and C<end>, both are expected to be in the iso-8601 representation: C<yyyy-mm-dd>.
93  
94 Given C<start =E<gt> '2014-10-15', end =E<gt> '2014-10-25'> then all measurements between 2014-10-15 00:00:00 and 2014-10-25 00:00:00 will be returned.
95  
96 Returns a L<GetMeasurements|OpenGbg::Service::AirQuality::GetMeasurements> object.
97  
98 =head1 SOURCE
99  
100 L<https://github.com/Csson/p5-OpenGbg>
101  
102 =head1 HOMEPAGE
103  
104 L<https://metacpan.org/release/OpenGbg>
105  
106 =head1 AUTHOR
107  
108 Erik Carlsson <info@code301.com>
109  
110 =head1 COPYRIGHT AND LICENSE
111  
112 This software is copyright (c) 2016 by Erik Carlsson.
113  
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116  
117 =cut
« OpenGbg/Service/StyrOchStall/GetBikeStations.pm ↑ Summary OpenGbg/Service/TrafficCamera.pm »