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