| 1 | package GeoIP2::Record::Location; | ||
| 2 | |||
| 3 | 12 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 12 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 12 | our $VERSION = '2.006000'; | |
| 7 | |||
| 8 | 12 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 12 | ▶ | use GeoIP2::Types qw( NonNegativeInt Num PositiveInt Str ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 12 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 12 | has accuracy_radius => ( | |
| 15 | is => 'ro', | ||
| 16 | isa => PositiveInt, | ||
| 17 | predicate => 'has_accuracy_radius', | ||
| 18 | ); | ||
| 19 | |||
| 20 | 12 | has average_income => ( | |
| 21 | is => 'ro', | ||
| 22 | isa => NonNegativeInt, | ||
| 23 | predicate => 'has_average_income', | ||
| 24 | ); | ||
| 25 | |||
| 26 | 12 | has latitude => ( | |
| 27 | is => 'ro', | ||
| 28 | isa => Num, | ||
| 29 | predicate => 'has_latitude', | ||
| 30 | ); | ||
| 31 | |||
| 32 | 12 | has longitude => ( | |
| 33 | is => 'ro', | ||
| 34 | isa => Num, | ||
| 35 | predicate => 'has_longitude', | ||
| 36 | ); | ||
| 37 | |||
| 38 | 12 | has metro_code => ( | |
| 39 | is => 'ro', | ||
| 40 | isa => PositiveInt, | ||
| 41 | predicate => 'has_metro_code', | ||
| 42 | ); | ||
| 43 | |||
| 44 | 12 | has population_density => ( | |
| 45 | is => 'ro', | ||
| 46 | isa => NonNegativeInt, | ||
| 47 | predicate => 'has_population_density', | ||
| 48 | ); | ||
| 49 | |||
| 50 | 12 | has time_zone => ( | |
| 51 | is => 'ro', | ||
| 52 | isa => Str, | ||
| 53 | predicate => 'has_time_zone', | ||
| 54 | ); | ||
| 55 | |||
| 56 | 12 | 1; | |
| 57 | |||
| 58 | # ABSTRACT: Contains data for the location record associated with an IP address | ||
| 59 | |||
| 60 | __END__ | ||
| 61 | |||
| 62 | =pod | ||
| 63 | |||
| 64 | =encoding UTF-8 | ||
| 65 | |||
| 66 | =head1 NAME | ||
| 67 | |||
| 68 | GeoIP2::Record::Location - Contains data for the location record associated with an IP address | ||
| 69 | |||
| 70 | =head1 VERSION | ||
| 71 | |||
| 72 | version 2.006000 | ||
| 73 | |||
| 74 | =head1 SYNOPSIS | ||
| 75 | |||
| 76 | use 5.008; | ||
| 77 | |||
| 78 | use GeoIP2::WebService::Client; | ||
| 79 | |||
| 80 | my $client = GeoIP2::WebService::Client->new( | ||
| 81 | account_id => 42, | ||
| 82 | license_key => 'abcdef123456', | ||
| 83 | ); | ||
| 84 | |||
| 85 | my $insights = $client->insights( ip => '24.24.24.24' ); | ||
| 86 | |||
| 87 | my $location_rec = $insights->location(); | ||
| 88 | print $location_rec->name(), "\n"; | ||
| 89 | |||
| 90 | =head1 DESCRIPTION | ||
| 91 | |||
| 92 | This class contains the location data associated with an IP address. | ||
| 93 | |||
| 94 | This record is returned by all the end points except the Country end point. | ||
| 95 | |||
| 96 | =head1 METHODS | ||
| 97 | |||
| 98 | This class provides the following methods: | ||
| 99 | |||
| 100 | =head2 $location_rec->accuracy_radius() | ||
| 101 | |||
| 102 | The approximate accuracy radius in kilometers around the latitude and | ||
| 103 | longitude for the IP address. This is the radius where we have a 67% | ||
| 104 | confidence that the device using the IP address resides within the circle | ||
| 105 | centered at the latitude and longitude with the provided radius. | ||
| 106 | |||
| 107 | This attribute is returned by all end points and location databases except | ||
| 108 | Country. | ||
| 109 | |||
| 110 | =head2 $location_rec->average_income() | ||
| 111 | |||
| 112 | This returns a non-negative integer representing the average income in US | ||
| 113 | dollars associated with the requested IP address. | ||
| 114 | |||
| 115 | This attribute is only available from the Insights end point and the GeoIP2 | ||
| 116 | Enterprise database. | ||
| 117 | |||
| 118 | =head2 $location_rec->latitude() | ||
| 119 | |||
| 120 | The approximate latitude of the location associated with the IP address. This | ||
| 121 | value is not precise and should not be used to identify a particular address | ||
| 122 | or household. | ||
| 123 | |||
| 124 | This attribute is returned by all end points and location databases except | ||
| 125 | Country. | ||
| 126 | |||
| 127 | =head2 $location_rec->longitude() | ||
| 128 | |||
| 129 | The approximate longitude of the location associated with the IP address. This | ||
| 130 | value is not precise and should not be used to identify a particular address | ||
| 131 | or household. | ||
| 132 | |||
| 133 | This attribute is returned by all end points and location databases except | ||
| 134 | Country. | ||
| 135 | |||
| 136 | =head2 $location_rec->metro-code() | ||
| 137 | |||
| 138 | This returns the metro code of the location if the location is in the US. | ||
| 139 | MaxMind returns the same metro codes as the Google AdWords API | ||
| 140 | (L<https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions>). | ||
| 141 | |||
| 142 | This attribute is returned by all end points except the Country end point. | ||
| 143 | |||
| 144 | =head2 $location_rec->population_density() | ||
| 145 | |||
| 146 | Returns a non-negative integer representing the estimated population per square | ||
| 147 | kilometer associated with the requested IP address. | ||
| 148 | |||
| 149 | This attribute is only available from the Insights end point and the GeoIP2 | ||
| 150 | Enterprise database. | ||
| 151 | |||
| 152 | =head2 $location_rec->time_zone() | ||
| 153 | |||
| 154 | This returns the time zone associated with a location, as specified by the IANA | ||
| 155 | Time Zone Database (L<http://www.iana.org/time-zones>), e.g., "America/New_York". | ||
| 156 | |||
| 157 | This attribute is returned by all end points except the Country end point. | ||
| 158 | |||
| 159 | =head1 SUPPORT | ||
| 160 | |||
| 161 | =head1 AUTHORS | ||
| 162 | |||
| 163 | =over 4 | ||
| 164 | |||
| 165 | =item * | ||
| 166 | |||
| 167 | Dave Rolsky <drolsky@maxmind.com> | ||
| 168 | |||
| 169 | =item * | ||
| 170 | |||
| 171 | Greg Oschwald <goschwald@maxmind.com> | ||
| 172 | |||
| 173 | =item * | ||
| 174 | |||
| 175 | Mark Fowler <mfowler@maxmind.com> | ||
| 176 | |||
| 177 | =item * | ||
| 178 | |||
| 179 | Olaf Alders <oalders@maxmind.com> | ||
| 180 | |||
| 181 | =back | ||
| 182 | |||
| 183 | =head1 COPYRIGHT AND LICENSE | ||
| 184 | |||
| 185 | This software is copyright (c) 2013 - 2018 by MaxMind, Inc. | ||
| 186 | |||
| 187 | This is free software; you can redistribute it and/or modify it under | ||
| 188 | the same terms as the Perl 5 programming language system itself. | ||
| 189 | |||
| 190 | =cut | ||