| 1 | package GeoIP2::Model::City; | ||
| 2 | |||
| 3 | 9 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 9 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 9 | our $VERSION = '2.006000'; | |
| 7 | |||
| 8 | 9 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 9 | ▶ | use GeoIP2::Types qw( HashRef object_isa_type ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 9 | ▶ | use Sub::Quote qw( quote_sub ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 9 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 9 | with 'GeoIP2::Role::Model::Location', 'GeoIP2::Role::Model::HasSubdivisions'; | |
| 16 | |||
| 17 | ## no critic (ProhibitUnusedPrivateSubroutines) | ||
| 18 | 162 | ▶ | sub _has { has(@_) } |
|
Subroutine
_has: called CC=1 SCAR=0.0
| |||
| 19 | ## use critic | ||
| 20 | |||
| 21 | 9 | __PACKAGE__->_define_attributes_for_keys( __PACKAGE__->_all_record_names() ); | |
| 22 | |||
| 23 | 9 | 1; | |
| 24 | |||
| 25 | # ABSTRACT: Model class for GeoIP2 Precision: City and GeoIP2 City | ||
| 26 | |||
| 27 | __END__ | ||
| 28 | |||
| 29 | =pod | ||
| 30 | |||
| 31 | =encoding UTF-8 | ||
| 32 | |||
| 33 | =head1 NAME | ||
| 34 | |||
| 35 | GeoIP2::Model::City - Model class for GeoIP2 Precision: City and GeoIP2 City | ||
| 36 | |||
| 37 | =head1 VERSION | ||
| 38 | |||
| 39 | version 2.006000 | ||
| 40 | |||
| 41 | =head1 SYNOPSIS | ||
| 42 | |||
| 43 | use 5.008; | ||
| 44 | |||
| 45 | use GeoIP2::WebService::Client; | ||
| 46 | |||
| 47 | my $client = GeoIP2::WebService::Client->new( | ||
| 48 | account_id => 42, | ||
| 49 | license_key => 'abcdef123456', | ||
| 50 | ); | ||
| 51 | |||
| 52 | my $city = $client->city( ip => '24.24.24.24' ); | ||
| 53 | |||
| 54 | my $city_rec = $city->city(); | ||
| 55 | print $city_rec->name(), "\n"; | ||
| 56 | |||
| 57 | =head1 DESCRIPTION | ||
| 58 | |||
| 59 | This class provides a model for the data returned by the GeoIP2 Precision: | ||
| 60 | City web service and the GeoIP2 City database. | ||
| 61 | |||
| 62 | The only difference between the City and Insights model classes is which | ||
| 63 | fields in each record may be populated. See | ||
| 64 | L<http://dev.maxmind.com/geoip/geoip2/web-services> for more details. | ||
| 65 | |||
| 66 | =head1 METHODS | ||
| 67 | |||
| 68 | This class provides the following methods, each of which returns a record | ||
| 69 | object. | ||
| 70 | |||
| 71 | =head2 $city->city() | ||
| 72 | |||
| 73 | Returns a L<GeoIP2::Record::City> object representing city data for the | ||
| 74 | requested IP address. | ||
| 75 | |||
| 76 | =head2 $city->continent() | ||
| 77 | |||
| 78 | Returns a L<GeoIP2::Record::Continent> object representing continent data for | ||
| 79 | the requested IP address. | ||
| 80 | |||
| 81 | =head2 $city->country() | ||
| 82 | |||
| 83 | Returns a L<GeoIP2::Record::Country> object representing country data for the | ||
| 84 | requested IP address. This record represents the country where MaxMind | ||
| 85 | believes the IP is located. | ||
| 86 | |||
| 87 | =head2 $city->location() | ||
| 88 | |||
| 89 | Returns a L<GeoIP2::Record::Location> object representing country data for the | ||
| 90 | requested IP address. | ||
| 91 | |||
| 92 | =head2 $city->maxmind() | ||
| 93 | |||
| 94 | Returns a L<GeoIP2::Record::MaxMind> object representing data about your | ||
| 95 | MaxMind account. | ||
| 96 | |||
| 97 | =head2 $city->postal() | ||
| 98 | |||
| 99 | Returns a L<GeoIP2::Record::Postal> object representing postal code data for | ||
| 100 | the requested IP address. | ||
| 101 | |||
| 102 | =head2 $city->registered_country() | ||
| 103 | |||
| 104 | Returns a L<GeoIP2::Record::Country> object representing the registered | ||
| 105 | country data for the requested IP address. This record represents the country | ||
| 106 | where the ISP has registered a given IP block and may differ from the | ||
| 107 | user's country. | ||
| 108 | |||
| 109 | =head2 $city->represented_country() | ||
| 110 | |||
| 111 | Returns a L<GeoIP2::Record::RepresentedCountry> object for the country | ||
| 112 | represented by the requested IP address. The represented country may differ | ||
| 113 | from the C<country> for things like military bases. | ||
| 114 | |||
| 115 | =head2 $city->subdivisions() | ||
| 116 | |||
| 117 | Returns an array of L<GeoIP2::Record::Subdivision> objects representing the | ||
| 118 | country subdivisions for the requested IP address. The number and type of | ||
| 119 | subdivisions varies by country, but a subdivision is typically a state, | ||
| 120 | province, county, etc. | ||
| 121 | |||
| 122 | Some countries have multiple levels of subdivisions. For instance, the | ||
| 123 | subdivisions array for Oxford in the United Kingdom would have England as the | ||
| 124 | first element and Oxfordshire as the second element. The subdivisions array | ||
| 125 | for Minneapolis in the United States would have a single object for Minnesota. | ||
| 126 | |||
| 127 | If the response did not contain any subdivisions, this method returns an empty | ||
| 128 | list. | ||
| 129 | |||
| 130 | =head2 $city->most_specific_subdivision() | ||
| 131 | |||
| 132 | Returns a single L<GeoIP2::Record::Subdivision> object representing the most | ||
| 133 | specific subdivision returned. | ||
| 134 | |||
| 135 | If the response did not contain any subdivisions, this method returns a | ||
| 136 | L<GeoIP2::Record::Subdivision> object with no values. | ||
| 137 | |||
| 138 | =head2 $city->traits() | ||
| 139 | |||
| 140 | Returns a L<GeoIP2::Record::Traits> object representing the traits for the | ||
| 141 | requested IP address. | ||
| 142 | |||
| 143 | =head1 SUPPORT | ||
| 144 | |||
| 145 | =head1 AUTHORS | ||
| 146 | |||
| 147 | =over 4 | ||
| 148 | |||
| 149 | =item * | ||
| 150 | |||
| 151 | Dave Rolsky <drolsky@maxmind.com> | ||
| 152 | |||
| 153 | =item * | ||
| 154 | |||
| 155 | Greg Oschwald <goschwald@maxmind.com> | ||
| 156 | |||
| 157 | =item * | ||
| 158 | |||
| 159 | Mark Fowler <mfowler@maxmind.com> | ||
| 160 | |||
| 161 | =item * | ||
| 162 | |||
| 163 | Olaf Alders <oalders@maxmind.com> | ||
| 164 | |||
| 165 | =back | ||
| 166 | |||
| 167 | =head1 COPYRIGHT AND LICENSE | ||
| 168 | |||
| 169 | This software is copyright (c) 2013 - 2018 by MaxMind, Inc. | ||
| 170 | |||
| 171 | This is free software; you can redistribute it and/or modify it under | ||
| 172 | the same terms as the Perl 5 programming language system itself. | ||
| 173 | |||
| 174 | =cut | ||