| 1 | package Weather::OpenWeatherMap::Request::Find; | ||
| 2 | 2 | $Weather::OpenWeatherMap::Request::Find::VERSION = '0.003001'; | |
| 3 | 2 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use URI::Escape 'uri_escape_utf8'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use Types::Standard -all; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | extends 'Weather::OpenWeatherMap::Request'; | |
| 9 | |||
| 10 | has max => ( | ||
| 11 | lazy => 1, | ||
| 12 | is => 'ro', | ||
| 13 | isa => Int, | ||
| 14 | 1 | ▶ | builder => sub { 10 }, |
|
Subroutine
_build_max: called CC=1 SCAR=0.0
| |||
| 15 | 2 | ); | |
| 16 | |||
| 17 | has type => ( | ||
| 18 | lazy => 1, | ||
| 19 | is => 'ro', | ||
| 20 | isa => Str, | ||
| 21 | 2 | ▶ | builder => sub { 'accurate' }, |
|
Subroutine
_build_type: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 22 | 2 | ); | |
| 23 | |||
| 24 | |||
| 25 | sub _url_bycode { | ||
| 26 | 0 | ▶ | carp "Find does not support city codes"; |
|
Subroutine
_url_bycode: not called CC=1 SCAR=6.9
| |||
| 27 | 0 | return 'http://api.openweathermap.org/data/2.5/find' | |
| 28 | } | ||
| 29 | |||
| 30 | sub _url_bycoord { | ||
| 31 | 1 | ▶ | my $self = shift; |
|
Subroutine
_url_bycoord: called CC=1 SCAR=0.0
| |||
| 32 | 1 | my ($lat, $long) = map {; uri_escape_utf8($_) } @_; | |
| 33 | 1 | "http://api.openweathermap.org/data/2.5/find?lat=$lat&lon=$long" | |
| 34 | . '&units=' . $self->_units | ||
| 35 | . '&type=' . $self->type | ||
| 36 | . '&cnt=' . $self->max | ||
| 37 | } | ||
| 38 | |||
| 39 | sub _url_byname { | ||
| 40 | 1 | ▶ | my ($self, @parts) = @_; |
|
Subroutine
_url_byname: called CC=1 SCAR=0.0
| |||
| 41 | 'http://api.openweathermap.org/data/2.5/find?q=' | ||
| 42 | 1 | . join(',', map {; uri_escape_utf8($_) } @parts) | |
| 43 | . '&units=' . $self->_units | ||
| 44 | . '&type=' . $self->type | ||
| 45 | . '&cnt=' . $self->max | ||
| 46 | } | ||
| 47 | |||
| 48 | 2 | 1; | |
| 49 | |||
| 50 | =head1 NAME | ||
| 51 | |||
| 52 | Weather::OpenWeatherMap::Request::Find | ||
| 53 | |||
| 54 | =head1 SYNOPSIS | ||
| 55 | |||
| 56 | # Usually created by Weather::OpenWeatherMap | ||
| 57 | use Weather::OpenWeatherMap::Request::Find; | ||
| 58 | my $request = Weather::OpenWeatherMap::Request::Find->new( | ||
| 59 | tag => 'foo', | ||
| 60 | location => 'Manchester', | ||
| 61 | max => 5, | ||
| 62 | ); | ||
| 63 | |||
| 64 | my $http_request_obj = $request->http_request; | ||
| 65 | |||
| 66 | =head1 DESCRIPTION | ||
| 67 | |||
| 68 | A L<Weather::OpenWeatherMap::Request> subclass for building a city search | ||
| 69 | request. | ||
| 70 | |||
| 71 | =head1 ATTRIBUTES | ||
| 72 | |||
| 73 | =head3 max | ||
| 74 | |||
| 75 | The maximum number of results to ask for. | ||
| 76 | |||
| 77 | =head3 type | ||
| 78 | |||
| 79 | The type of search to perform; C<accurate> looks for exact matches, C<like> | ||
| 80 | searches by substring. | ||
| 81 | |||
| 82 | =head1 SEE ALSO | ||
| 83 | |||
| 84 | L<Weather::OpenWeatherMap::Result::Find> | ||
| 85 | |||
| 86 | =head1 AUTHOR | ||
| 87 | |||
| 88 | Jon Portnoy <avenj@cobaltirc.org> | ||
| 89 | |||
| 90 | Licensed under the same terms as Perl. | ||