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