File Coverage

blib/lib/GeoIP2/Model/Insights.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 18 100.0


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