GeoIP2/Record/City.pm

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