File Coverage

blib/lib/GeoIP2/Record/Country.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package GeoIP2::Record::Country;
2              
3 12     12   73 use strict;
  12         23  
  12         310  
4 12     12   92 use warnings;
  12         20  
  12         398  
5              
6             our $VERSION = '2.006002';
7              
8 12     12   58 use Moo;
  12         67  
  12         71  
9              
10 12     12   3169 use namespace::clean -except => 'meta';
  12         21  
  12         74  
11              
12             with 'GeoIP2::Role::Record::Country';
13              
14             1;
15              
16             # ABSTRACT: Contains data for the country record associated with an IP address
17              
18             __END__
19              
20             =pod
21              
22             =encoding UTF-8
23              
24             =head1 NAME
25              
26             GeoIP2::Record::Country - Contains data for the country record associated with an IP address
27              
28             =head1 VERSION
29              
30             version 2.006002
31              
32             =head1 SYNOPSIS
33              
34             use 5.008;
35              
36             use GeoIP2::WebService::Client;
37              
38             my $client = GeoIP2::WebService::Client->new(
39             account_id => 42,
40             license_key => 'abcdef123456',
41             );
42              
43             my $insights = $client->insights( ip => '24.24.24.24' );
44              
45             my $country_rec = $insights->country();
46             print $country_rec->name(), "\n";
47              
48             =head1 DESCRIPTION
49              
50             This class contains the country-level data associated with an IP address.
51              
52             This record is returned by all the end points.
53              
54             =head1 METHODS
55              
56             This class provides the following methods:
57              
58             =head2 $country_rec->confidence()
59              
60             This returns a value from 0-100 indicating MaxMind's confidence that the
61             country is correct.
62              
63             This attribute is only available from the Insights end point and the GeoIP2
64             Enterprise database.
65              
66             =head2 $country_rec->geoname_id()
67              
68             This returns a C<geoname_id> for the country.
69              
70             This attribute is returned by all end points.
71              
72             =head2 $country_rec->is_in_european_union()
73              
74             This returns a true value if the country is a member state of the European
75             Union and a false value otherwise.
76              
77             This attribute is available from all web service end points and the GeoIP2
78             Country, City, and Enterprise databases.
79              
80             =head2 $country_rec->iso_code()
81              
82             This returns the two-character ISO 3166-1
83             (L<http://en.wikipedia.org/wiki/ISO_3166-1>) alpha code for the country.
84              
85             This attribute is returned by all end points.
86              
87             =head2 $country_rec->name()
88              
89             This returns a name for the country. The locale chosen depends on the
90             C<locales> argument that was passed to the record's constructor. This will be
91             passed through from the L<GeoIP2::WebService::Client> object you used to fetch
92             the data that populated this record.
93              
94             If the record does not have a name in any of the locales you asked for, this
95             method returns C<undef>.
96              
97             This attribute is returned by all end points.
98              
99             =head2 $country_rec->names()
100              
101             This returns a hash reference where the keys are locale codes and the values
102             are names. See L<GeoIP2::WebService::Client> for a list of the possible
103             locale codes.
104              
105             This attribute is returned by all end points.
106              
107             =head1 SUPPORT
108              
109             Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>.
110              
111             =head1 AUTHORS
112              
113             =over 4
114              
115             =item *
116              
117             Dave Rolsky <drolsky@maxmind.com>
118              
119             =item *
120              
121             Greg Oschwald <goschwald@maxmind.com>
122              
123             =item *
124              
125             Mark Fowler <mfowler@maxmind.com>
126              
127             =item *
128              
129             Olaf Alders <oalders@maxmind.com>
130              
131             =back
132              
133             =head1 COPYRIGHT AND LICENSE
134              
135             This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
136              
137             This is free software; you can redistribute it and/or modify it under
138             the same terms as the Perl 5 programming language system itself.
139              
140             =cut