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