| 1 | package GeoIP2::Record::Country; | ||
| 2 | 6 | $GeoIP2::Record::Country::VERSION = '0.050000'; | |
| 3 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 6 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 6 | with 'GeoIP2::Role::Record::Country'; | |
| 9 | |||
| 10 | 6 | 1; | |
| 11 | |||
| 12 | # ABSTRACT: Contains data for the country record associated with an IP address | ||
| 13 | |||
| 14 | __END__ | ||
| 15 | |||
| 16 | =pod | ||
| 17 | |||
| 18 | =head1 NAME | ||
| 19 | |||
| 20 | GeoIP2::Record::Country - Contains data for the country record associated with an IP address | ||
| 21 | |||
| 22 | =head1 VERSION | ||
| 23 | |||
| 24 | version 0.050000 | ||
| 25 | |||
| 26 | =head1 SYNOPSIS | ||
| 27 | |||
| 28 | use 5.008; | ||
| 29 | |||
| 30 | use GeoIP2::WebService::Client; | ||
| 31 | |||
| 32 | my $client = GeoIP2::WebService::Client->new( | ||
| 33 | user_id => 42, | ||
| 34 | license_key => 'abcdef123456', | ||
| 35 | ); | ||
| 36 | |||
| 37 | my $insights = $client->insights( ip => '24.24.24.24' ); | ||
| 38 | |||
| 39 | my $country_rec = $insights->country(); | ||
| 40 | say $country_rec->name(); | ||
| 41 | |||
| 42 | =head1 DESCRIPTION | ||
| 43 | |||
| 44 | This class contains the country-level data associated with an IP address. | ||
| 45 | |||
| 46 | This record is returned by all the end points. | ||
| 47 | |||
| 48 | =head1 METHODS | ||
| 49 | |||
| 50 | This class provides the following methods: | ||
| 51 | |||
| 52 | =head2 $country_rec->confidence() | ||
| 53 | |||
| 54 | This returns a value from 0-100 indicating MaxMind's confidence that the | ||
| 55 | country is correct. | ||
| 56 | |||
| 57 | This attribute is only available from the Insights end point. | ||
| 58 | |||
| 59 | =head2 $country_rec->geoname_id() | ||
| 60 | |||
| 61 | This returns a C<geoname_id> for the country. | ||
| 62 | |||
| 63 | This attribute is returned by all end points. | ||
| 64 | |||
| 65 | =head2 $country_rec->iso_code() | ||
| 66 | |||
| 67 | This returns the two-character ISO 3166-1 | ||
| 68 | (L<http://en.wikipedia.org/wiki/ISO_3166-1>) alpha code for the country. | ||
| 69 | |||
| 70 | This attribute is returned by all end points. | ||
| 71 | |||
| 72 | =head2 $country_rec->name() | ||
| 73 | |||
| 74 | This returns a name for the country. The locale chosen depends on the | ||
| 75 | C<locales> argument that was passed to the record's constructor. This will be | ||
| 76 | passed through from the L<GeoIP2::WebService::Client> object you used to fetch | ||
| 77 | the data that populated this record. | ||
| 78 | |||
| 79 | If the record does not have a name in any of the locales you asked for, this | ||
| 80 | method returns C<undef>. | ||
| 81 | |||
| 82 | This attribute is returned by all end points. | ||
| 83 | |||
| 84 | =head2 $country_rec->names() | ||
| 85 | |||
| 86 | This returns a hash reference where the keys are locale codes and the values | ||
| 87 | are names. See L<GeoIP2::WebService::Client> for a list of the possible | ||
| 88 | locale codes. | ||
| 89 | |||
| 90 | This attribute is returned by all end points. | ||
| 91 | |||
| 92 | =head1 AUTHORS | ||
| 93 | |||
| 94 | =over 4 | ||
| 95 | |||
| 96 | =item * | ||
| 97 | |||
| 98 | Dave Rolsky <drolsky@maxmind.com> | ||
| 99 | |||
| 100 | =item * | ||
| 101 | |||
| 102 | Greg Oschwald <goschwald@maxmind.com> | ||
| 103 | |||
| 104 | =item * | ||
| 105 | |||
| 106 | Olaf Alders <oalders@maxmind.com> | ||
| 107 | |||
| 108 | =back | ||
| 109 | |||
| 110 | =head1 COPYRIGHT AND LICENSE | ||
| 111 | |||
| 112 | This software is copyright (c) 2014 by MaxMind, Inc.. | ||
| 113 | |||
| 114 | This is free software; you can redistribute it and/or modify it under | ||
| 115 | the same terms as the Perl 5 programming language system itself. | ||
| 116 | |||
| 117 | =cut | ||