File Coverage

blib/lib/GeoIP2/Model/Enterprise.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::Enterprise;
2              
3 7     7   46 use strict;
  7         12  
  7         183  
4 7     7   31 use warnings;
  7         12  
  7         243  
5              
6             our $VERSION = '2.006002';
7              
8 7     7   32 use Moo;
  7         10  
  7         35  
9              
10 7     7   2019 use namespace::clean -except => 'meta';
  7         20  
  7         45  
11              
12             with 'GeoIP2::Role::Model::Location', 'GeoIP2::Role::Model::HasSubdivisions';
13              
14             ## no critic (ProhibitUnusedPrivateSubroutines)
15 126     126   10403 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 Enterprise
23              
24             __END__
25              
26             =pod
27              
28             =encoding UTF-8
29              
30             =head1 NAME
31              
32             GeoIP2::Model::Enterprise - Model class for GeoIP2 Enterprise
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 $reader = GeoIP2::Database::Reader->new(
45             file => '/path/to/database',
46             locales => [ 'en', 'de', ]
47             );
48              
49             my $enterprise = $reader->enterprise( ip => '24.24.24.24' );
50              
51             my $city_rec = $enterprise->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 Enterprise
57             database.
58              
59             The only difference between the City and Enterprise 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 $enterprise->city()
68              
69             Returns a L<GeoIP2::Record::City> object representing city data for the
70             requested IP address.
71              
72             =head2 $enterprise->continent()
73              
74             Returns a L<GeoIP2::Record::Continent> object representing continent data for
75             the requested IP address.
76              
77             =head2 $enterprise->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 $enterprise->location()
84              
85             Returns a L<GeoIP2::Record::Location> object representing location data for the
86             requested IP address.
87              
88             =head2 $enterprise->postal()
89              
90             Returns a L<GeoIP2::Record::Postal> object representing postal code data for
91             the requested IP address.
92              
93             =head2 $enterprise->registered_country()
94              
95             Returns a L<GeoIP2::Record::Country> object representing the registered
96             country data for the requested IP address. This record represents the country
97             where the ISP has registered a given IP block and may differ from the
98             user's country.
99              
100             =head2 $enterprise->represented_country()
101              
102             Returns a L<GeoIP2::Record::RepresentedCountry> object for the country
103             represented by the requested IP address. The represented country may differ
104             from the C<country> for things like military bases.
105              
106             =head2 $enterprise->subdivisions()
107              
108             Returns an array of L<GeoIP2::Record::Subdivision> objects representing the
109             country subdivisions for the requested IP address. The number and type of
110             subdivisions varies by country, but a subdivision is typically a state,
111             province, county, etc.
112              
113             Some countries have multiple levels of subdivisions. For instance, the
114             subdivisions array for Oxford in the United Kingdom would have England as the
115             first element and Oxfordshire as the second element. The subdivisions array
116             for Minneapolis in the United States would have a single object for Minnesota.
117              
118             If the response did not contain any subdivisions, this method returns an empty
119             list.
120              
121             =head2 $enterprise->most_specific_subdivision()
122              
123             Returns a single L<GeoIP2::Record::Subdivision> object representing the most
124             specific subdivision returned.
125              
126             If the response did not contain any subdivisions, this method returns a
127             L<GeoIP2::Record::Subdivision> object with no values.
128              
129             =head2 $enterprise->traits()
130              
131             Returns a L<GeoIP2::Record::Traits> object representing the traits for the
132             requested IP address.
133              
134             =head1 SUPPORT
135              
136             Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>.
137              
138             =head1 AUTHORS
139              
140             =over 4
141              
142             =item *
143              
144             Dave Rolsky <drolsky@maxmind.com>
145              
146             =item *
147              
148             Greg Oschwald <goschwald@maxmind.com>
149              
150             =item *
151              
152             Mark Fowler <mfowler@maxmind.com>
153              
154             =item *
155              
156             Olaf Alders <oalders@maxmind.com>
157              
158             =back
159              
160             =head1 COPYRIGHT AND LICENSE
161              
162             This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
163              
164             This is free software; you can redistribute it and/or modify it under
165             the same terms as the Perl 5 programming language system itself.
166              
167             =cut