File Coverage

blib/lib/GeoIP2/Record/Traits.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package GeoIP2::Record::Traits;
2              
3 12     12   71 use strict;
  12         22  
  12         327  
4 12     12   48 use warnings;
  12         21  
  12         392  
5              
6             our $VERSION = '2.006002';
7              
8 12     12   85 use Moo;
  12         20  
  12         51  
9              
10 12     12   3304 use GeoIP2::Types qw( Bool BoolCoercion IPAddress NonNegativeInt Str );
  12         21  
  12         698  
11 12     12   72 use Sub::Quote qw( quote_sub );
  12         21  
  12         524  
12              
13 12     12   64 use namespace::clean -except => 'meta';
  12         32  
  12         70  
14              
15             with 'GeoIP2::Role::HasIPAddress';
16              
17             has autonomous_system_number => (
18             is => 'ro',
19             isa => NonNegativeInt,
20             predicate => 'has_autonomous_system_number',
21             );
22              
23             has autonomous_system_organization => (
24             is => 'ro',
25             isa => Str,
26             predicate => 'has_autonomous_system_organization',
27             );
28              
29             has connection_type => (
30             is => 'ro',
31             isa => Str,
32             predicate => 'has_connection_type',
33             );
34              
35             has domain => (
36             is => 'ro',
37             isa => Str,
38             predicate => 'has_domain',
39             );
40              
41             has [
42             'is_anonymous',
43             'is_anonymous_proxy',
44             'is_anonymous_vpn',
45             'is_hosting_provider',
46             'is_legitimate_proxy',
47             'is_public_proxy',
48             'is_satellite_provider',
49             'is_tor_exit_node',
50             ] => (
51             is => 'ro',
52             isa => Bool,
53             default => quote_sub(q{ 0 }),
54             coerce => BoolCoercion,
55             );
56              
57             has isp => (
58             is => 'ro',
59             isa => Str,
60             predicate => 'has_isp',
61             );
62              
63             has organization => (
64             is => 'ro',
65             isa => Str,
66             predicate => 'has_organization',
67             );
68              
69             has user_type => (
70             is => 'ro',
71             isa => Str,
72             predicate => 'has_user_type',
73             );
74              
75             1;
76              
77             # ABSTRACT: Contains data for the traits record associated with an IP address
78              
79             __END__
80              
81             =pod
82              
83             =encoding UTF-8
84              
85             =head1 NAME
86              
87             GeoIP2::Record::Traits - Contains data for the traits record associated with an IP address
88              
89             =head1 VERSION
90              
91             version 2.006002
92              
93             =head1 SYNOPSIS
94              
95             use 5.008;
96              
97             use GeoIP2::WebService::Client;
98              
99             my $client = GeoIP2::WebService::Client->new(
100             account_id => 42,
101             license_key => 'abcdef123456',
102             );
103              
104             my $insights = $client->insights( ip => '24.24.24.24' );
105              
106             my $traits_rec = $insights->country();
107             print $traits_rec->name(), "\n";
108              
109             =head1 DESCRIPTION
110              
111             This class contains the traits data associated with an IP address.
112              
113             This record is returned by all the end points.
114              
115             =head1 METHODS
116              
117             This class provides the following methods:
118              
119             =head2 $traits_rec->autonomous_system_number()
120              
121             This returns the autonomous system number
122             (L<http://en.wikipedia.org/wiki/Autonomous_system_(Internet)>) associated with
123             the IP address.
124              
125             This attribute is only available from the City and Insights web service
126             endpoints and the GeoIP2 Enterprise database.
127              
128             =head2 $traits_rec->autonomous_system_organization()
129              
130             This returns the organization associated with the registered autonomous system
131             number (L<http://en.wikipedia.org/wiki/Autonomous_system_(Internet)>) for the IP
132             address.
133              
134             This attribute is only available from the City and Insights web service
135             endpoints and the GeoIP2 Enterprise database.
136              
137             =head2 $traits_rec->connection_type()
138              
139             This returns the connection type associated with the IP address. It may take
140             the following values: C<Dialup>, C<Cable/DSL>, C<Corporate>, or C<Cellular>.
141             Additional values may be added in the future.
142              
143             This attribute is only available in the GeoIP2 Enterprise database.
144              
145             =head2 $traits_rec->domain()
146              
147             This returns the second level domain associated with the IP address. This will
148             be something like "example.com" or "example.co.uk", not "foo.example.com".
149              
150             This attribute is only available from the City and Insights web service
151             endpoints and the GeoIP2 Enterprise database.
152              
153             =head2 $traits_rec->ip_address()
154              
155             This returns the IP address that the data in the model is for. If you
156             performed a "me" lookup against the web service, this will be the externally
157             routable IP address for the system the code is running on. If the system is
158             behind a NAT, this may differ from the IP address locally assigned to it.
159              
160             This attribute is returned by all end points.
161              
162             =head2 $traits_rec->is_anonymous()
163              
164             This returns a true value if the IP address belongs to any sort of anonymous
165             network and a false value otherwise.
166              
167             This attribute is only available from the Insights web service.
168              
169             =head2 $traits_rec->is_anonymous_proxy()
170              
171             I<Deprecated.> Please see our L<GeoIP2 Anonymous IP
172             database|https://www.maxmind.com/en/geoip2-anonymous-ip-database> or our
173             L<GeoIP2 Precision Insights service|https://www.maxmind.com/en/geoip2-precision-insights>
174             to determine whether the IP address is used by an anonymizing service.
175              
176             This attribute is returned by all end points.
177              
178             =head2 $traits_rec->is_anonymous_vpn()
179              
180             This returns a true value if the IP address is registered to an anonymous VPN
181             provider and a false value otherwise.
182              
183             If a VPN provider does not register subnets under names associated with them,
184             we will likely only flag their IP ranges using the C<is_hosting_provider>
185             attribute.
186              
187             This attribute is only available from the Insights web service.
188              
189             =head2 $traits_rec->is_hosting_provider()
190              
191             This returns a true value if the IP address belongs to a hosting or VPN
192             provider and a false value otherwise (see description of C<is_anonymous_vpn>
193             attribute).
194              
195             This attribute is only available from the Insights web service.
196              
197             =head2 $traits_rec->is_legitimate_proxy()
198              
199             This attribute returns true if MaxMind believes this IP address to be a
200             legitimate proxy, such as an internal VPN used by a corporation
201              
202             This attribute is only available in the GeoIP2 Enterprise database.
203              
204             =head2 $traits_rec->is_public_proxy()
205              
206             This returns a true value if the IP address belongs to a public proxy and
207             a false value otherwise.
208              
209             This attribute is only available from the Insights web service.
210              
211             =head2 $traits_rec->is_satellite_provider()
212              
213             I<Deprecated.> Due to the increased coverage by mobile carriers, very few
214             satellite providers now serve multiple countries. As a result, the
215             output does not provide sufficiently relevant data for us to maintain it.
216              
217             This attribute is returned by all end points.
218              
219             =head2 $traits_rec->is_tor_exit_node()
220              
221             This returns a true value if the IP address is a Tor exit node and a false
222             value otherwise.
223              
224             This attribute is only available from the Insights web service.
225              
226             =head2 $traits_rec->isp()
227              
228             This returns the name of the ISP associated with the IP address.
229              
230             This attribute is only available from the City and Insights web service
231             endpoints and the GeoIP2 Enterprise database.
232              
233             =head2 $traits_rec->organization()
234              
235             This returns the name of the organization associated with the IP address.
236              
237             This attribute is only available from the City and Insights web service
238             endpoints and the GeoIP2 Enterprise database.
239              
240             =head2 $traits_rec->user_type()
241              
242             This returns the user type associated with the IP address. This can be one of
243             the following values:
244              
245             =over 4
246              
247             =item * business
248              
249             =item * cafe
250              
251             =item * cellular
252              
253             =item * college
254              
255             =item * content_delivery_network
256              
257             =item * dialup
258              
259             =item * government
260              
261             =item * hosting
262              
263             =item * library
264              
265             =item * military
266              
267             =item * residential
268              
269             =item * router
270              
271             =item * school
272              
273             =item * search_engine_spider
274              
275             =item * traveler
276              
277             =back
278              
279             This attribute is only available from the Insights end point and the GeoIP2
280             Enterprise database.
281              
282             =head1 SUPPORT
283              
284             Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>.
285              
286             =head1 AUTHORS
287              
288             =over 4
289              
290             =item *
291              
292             Dave Rolsky <drolsky@maxmind.com>
293              
294             =item *
295              
296             Greg Oschwald <goschwald@maxmind.com>
297              
298             =item *
299              
300             Mark Fowler <mfowler@maxmind.com>
301              
302             =item *
303              
304             Olaf Alders <oalders@maxmind.com>
305              
306             =back
307              
308             =head1 COPYRIGHT AND LICENSE
309              
310             This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
311              
312             This is free software; you can redistribute it and/or modify it under
313             the same terms as the Perl 5 programming language system itself.
314              
315             =cut