line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GeoIP2::Model::City; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
137718
|
use strict; |
|
9
|
|
|
|
|
60
|
|
|
9
|
|
|
|
|
228
|
|
4
|
9
|
|
|
9
|
|
39
|
use warnings; |
|
9
|
|
|
|
|
105
|
|
|
9
|
|
|
|
|
342
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.006002'; |
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
464
|
use Moo; |
|
9
|
|
|
|
|
8295
|
|
|
9
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
3714
|
use GeoIP2::Types qw( HashRef object_isa_type ); |
|
9
|
|
|
|
|
73
|
|
|
9
|
|
|
|
|
512
|
|
11
|
9
|
|
|
9
|
|
58
|
use Sub::Quote qw( quote_sub ); |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
407
|
|
12
|
|
|
|
|
|
|
|
13
|
9
|
|
|
9
|
|
79
|
use namespace::clean -except => 'meta'; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
47
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'GeoIP2::Role::Model::Location', 'GeoIP2::Role::Model::HasSubdivisions'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
18
|
162
|
|
|
162
|
|
13229
|
sub _has { has(@_) } |
19
|
|
|
|
|
|
|
## use critic |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->_define_attributes_for_keys( __PACKAGE__->_all_record_names() ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
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.006002 |
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
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHORS |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=over 4 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Dave Rolsky <drolsky@maxmind.com> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Greg Oschwald <goschwald@maxmind.com> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Mark Fowler <mfowler@maxmind.com> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Olaf Alders <oalders@maxmind.com> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=back |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This software is copyright (c) 2013 - 2019 by MaxMind, Inc. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
174
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |