File Coverage

blib/lib/GeoIP2/Model/Country.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             package GeoIP2::Model::Country;
2              
3 10     10   270071 use strict;
  10         29  
  10         512  
4 10     10   51 use warnings;
  10         17  
  10         352  
5              
6             our $VERSION = '2.006002';
7              
8 10     10   869 use Moo;
  10         18233  
  10         50  
9              
10 10     10   5235 use GeoIP2::Types qw( HashRef object_isa_type );
  10         22  
  10         645  
11 10     10   60 use Sub::Quote qw( quote_sub );
  10         18  
  10         468  
12              
13 10     10   60 use namespace::clean -except => 'meta';
  10         17  
  10         76  
14              
15             with 'GeoIP2::Role::Model::Location';
16              
17             ## no critic (ProhibitUnusedPrivateSubroutines)
18 100     100   8198 sub _has { has(@_) }
19             ## use critic
20              
21             __PACKAGE__->_define_attributes_for_keys(
22             qw( continent country maxmind registered_country traits ));
23              
24             1;
25              
26             # ABSTRACT: Model class for the GeoIP2 Precision: Country and GeoIP2 Country
27              
28             __END__
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             GeoIP2::Model::Country - Model class for the GeoIP2 Precision: Country and GeoIP2 Country
37              
38             =head1 VERSION
39              
40             version 2.006002
41              
42             =head1 SYNOPSIS
43              
44             use 5.008;
45              
46             use GeoIP2::WebService::Client;
47              
48             my $client = GeoIP2::WebService::Client->new(
49             account_id => 42,
50             license_key => 'abcdef123456',
51             );
52              
53             my $country = $client->country( ip => '24.24.24.24' );
54              
55             my $country_rec = $country->country();
56             print $country_rec->iso_code(), "\n";
57              
58             =head1 DESCRIPTION
59              
60             This class provides a model for the data returned by the GeoIP2 Precision:
61             Country web service and the GeoIP2 Country database.
62              
63             =head1 METHODS
64              
65             This class provides the following methods, each of which returns a record
66             object.
67              
68             =head2 $country->continent()
69              
70             Returns a L<GeoIP2::Record::Continent> object representing continent data for
71             the requested IP address.
72              
73             =head2 $country->country()
74              
75             Returns a L<GeoIP2::Record::Country> object representing country data for the
76             requested IP address. This record represents the country where MaxMind
77             believes the IP is located.
78              
79             =head2 $country->maxmind()
80              
81             Returns a L<GeoIP2::Record::MaxMind> object representing data about your
82             MaxMind account.
83              
84             =head2 $country->registered_country()
85              
86             Returns a L<GeoIP2::Record::Country> object representing the registered
87             country data for the requested IP address. This record represents the country
88             where the ISP has registered a given IP block and may differ from the
89             user's country.
90              
91             =head2 $country->represented_country()
92              
93             Returns a L<GeoIP2::Record::RepresentedCountry> object for the country
94             represented by the requested IP address. The represented country may differ
95             from the C<country> for things like military bases.
96              
97             =head2 $country->traits()
98              
99             Returns a L<GeoIP2::Record::Traits> object representing the traits for the
100             requested IP address.
101              
102             =head1 SUPPORT
103              
104             Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>.
105              
106             =head1 AUTHORS
107              
108             =over 4
109              
110             =item *
111              
112             Dave Rolsky <drolsky@maxmind.com>
113              
114             =item *
115              
116             Greg Oschwald <goschwald@maxmind.com>
117              
118             =item *
119              
120             Mark Fowler <mfowler@maxmind.com>
121              
122             =item *
123              
124             Olaf Alders <oalders@maxmind.com>
125              
126             =back
127              
128             =head1 COPYRIGHT AND LICENSE
129              
130             This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
131              
132             This is free software; you can redistribute it and/or modify it under
133             the same terms as the Perl 5 programming language system itself.
134              
135             =cut