| 1 | package GeoIP2::Record::Location; | ||
| 2 | 6 | $GeoIP2::Record::Location::VERSION = '0.050000'; | |
| 3 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 6 | ▶ | use GeoIP2::Types qw( NonNegativeInt Num PositiveInt Str ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 6 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 6 | has accuracy_radius => ( | |
| 11 | is => 'ro', | ||
| 12 | isa => PositiveInt, | ||
| 13 | predicate => 'has_accuracy_radius', | ||
| 14 | ); | ||
| 15 | |||
| 16 | 6 | has latitude => ( | |
| 17 | is => 'ro', | ||
| 18 | isa => Num, | ||
| 19 | predicate => 'has_latitude', | ||
| 20 | ); | ||
| 21 | |||
| 22 | 6 | has longitude => ( | |
| 23 | is => 'ro', | ||
| 24 | isa => Num, | ||
| 25 | predicate => 'has_longitude', | ||
| 26 | ); | ||
| 27 | |||
| 28 | 6 | has metro_code => ( | |
| 29 | is => 'ro', | ||
| 30 | isa => PositiveInt, | ||
| 31 | predicate => 'has_metro_code', | ||
| 32 | ); | ||
| 33 | |||
| 34 | 6 | has time_zone => ( | |
| 35 | is => 'ro', | ||
| 36 | isa => Str, | ||
| 37 | predicate => 'has_time_zone', | ||
| 38 | ); | ||
| 39 | |||
| 40 | 6 | 1; | |
| 41 | |||
| 42 | # ABSTRACT: Contains data for the location record associated with an IP address | ||
| 43 | |||
| 44 | __END__ | ||
| 45 | |||
| 46 | =pod | ||
| 47 | |||
| 48 | =head1 NAME | ||
| 49 | |||
| 50 | GeoIP2::Record::Location - Contains data for the location record associated with an IP address | ||
| 51 | |||
| 52 | =head1 VERSION | ||
| 53 | |||
| 54 | version 0.050000 | ||
| 55 | |||
| 56 | =head1 SYNOPSIS | ||
| 57 | |||
| 58 | use 5.008; | ||
| 59 | |||
| 60 | use GeoIP2::WebService::Client; | ||
| 61 | |||
| 62 | my $client = GeoIP2::WebService::Client->new( | ||
| 63 | user_id => 42, | ||
| 64 | license_key => 'abcdef123456', | ||
| 65 | ); | ||
| 66 | |||
| 67 | my $insights = $client->insights( ip => '24.24.24.24' ); | ||
| 68 | |||
| 69 | my $location_rec = $insights->location(); | ||
| 70 | say $location_rec->name(); | ||
| 71 | |||
| 72 | =head1 DESCRIPTION | ||
| 73 | |||
| 74 | This class contains the location data associated with an IP address. | ||
| 75 | |||
| 76 | This record is returned by all the end points except the Country end point. | ||
| 77 | |||
| 78 | =head1 METHODS | ||
| 79 | |||
| 80 | This class provides the following methods: | ||
| 81 | |||
| 82 | =head2 $location_rec->accuracy_radius() | ||
| 83 | |||
| 84 | This returns the radius in kilometers around the specified location where the | ||
| 85 | IP address is likely to be. | ||
| 86 | |||
| 87 | This attribute is only available from the Insights end point. | ||
| 88 | |||
| 89 | =head2 $location_rec->latitude() | ||
| 90 | |||
| 91 | This returns the latitude of the location as a floating point number. | ||
| 92 | |||
| 93 | This attribute is returned by all end points except the Country end point. | ||
| 94 | |||
| 95 | =head2 $location_rec->longitude() | ||
| 96 | |||
| 97 | This returns the longitude of the location as a floating point number. | ||
| 98 | |||
| 99 | This attribute is returned by all end points except the Country end point. | ||
| 100 | |||
| 101 | =head2 $location_rec->metro-code() | ||
| 102 | |||
| 103 | This returns the metro code of the location if the location is in the US. | ||
| 104 | MaxMind returns the same metro codes as the Google AdWords API | ||
| 105 | (L<https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions>). | ||
| 106 | |||
| 107 | This attribute is returned by all end points except the Country end point. | ||
| 108 | |||
| 109 | =head2 $location_rec->time_zone() | ||
| 110 | |||
| 111 | This returns the time zone associated with a location, as specified by the IANA | ||
| 112 | Time Zone Database (L<http://www.iana.org/time-zones>), e.g., "America/New_York". | ||
| 113 | |||
| 114 | This attribute is returned by all end points except the Country end point. | ||
| 115 | |||
| 116 | =head1 AUTHORS | ||
| 117 | |||
| 118 | =over 4 | ||
| 119 | |||
| 120 | =item * | ||
| 121 | |||
| 122 | Dave Rolsky <drolsky@maxmind.com> | ||
| 123 | |||
| 124 | =item * | ||
| 125 | |||
| 126 | Greg Oschwald <goschwald@maxmind.com> | ||
| 127 | |||
| 128 | =item * | ||
| 129 | |||
| 130 | Olaf Alders <oalders@maxmind.com> | ||
| 131 | |||
| 132 | =back | ||
| 133 | |||
| 134 | =head1 COPYRIGHT AND LICENSE | ||
| 135 | |||
| 136 | This software is copyright (c) 2014 by MaxMind, Inc.. | ||
| 137 | |||
| 138 | This is free software; you can redistribute it and/or modify it under | ||
| 139 | the same terms as the Perl 5 programming language system itself. | ||
| 140 | |||
| 141 | =cut | ||