GeoIP2/Record/Traits.pm

filter: Statementstmt 100% 29 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 35 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« GeoIP2/Record/Subdivision.pm ↑ Summary GeoIP2/Role/Error/HTTP.pm »
1 package GeoIP2::Record::Traits;
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( Bool BoolCoercion IPAddress NonNegativeInt Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Sub::Quote qw( quote_sub );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 12 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 12 with 'GeoIP2::Role::HasIPAddress';
16  
17 12 has autonomous_system_number => (
18 is => 'ro',
19 isa => NonNegativeInt,
20 predicate => 'has_autonomous_system_number',
21 );
22  
23 12 has autonomous_system_organization => (
24 is => 'ro',
25 isa => Str,
26 predicate => 'has_autonomous_system_organization',
27 );
28  
29 12 has connection_type => (
30 is => 'ro',
31 isa => Str,
32 predicate => 'has_connection_type',
33 );
34  
35 12 has domain => (
36 is => 'ro',
37 isa => Str,
38 predicate => 'has_domain',
39 );
40  
41 12 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 12 has isp => (
58 is => 'ro',
59 isa => Str,
60 predicate => 'has_isp',
61 );
62  
63 12 has organization => (
64 is => 'ro',
65 isa => Str,
66 predicate => 'has_organization',
67 );
68  
69 12 has user_type => (
70 is => 'ro',
71 isa => Str,
72 predicate => 'has_user_type',
73 );
74  
75 12 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.006000
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 belongs to an anonymous VPN
181 system and a false value otherwise.
182  
183 This attribute is only available from the Insights web service.
184  
185 =head2 $traits_rec->is_hosting_provider()
186  
187 This returns a true value if the IP address belongs to a hosting provider and
188 a false value otherwise.
189  
190 This attribute is only available from the Insights web service.
191  
192 =head2 $traits_rec->is_legitimate_proxy()
193  
194 This attribute returns true if MaxMind believes this IP address to be a
195 legitimate proxy, such as an internal VPN used by a corporation
196  
197 This attribute is only available in the GeoIP2 Enterprise database.
198  
199 =head2 $traits_rec->is_public_proxy()
200  
201 This returns a true value if the IP address belongs to a public proxy and
202 a false value otherwise.
203  
204 This attribute is only available from the Insights web service.
205  
206 =head2 $traits_rec->is_satellite_provider()
207  
208 I<Deprecated.> Due to the increased coverage by mobile carriers, very few
209 satellite providers now serve multiple countries. As a result, the
210 output does not provide sufficiently relevant data for us to maintain it.
211  
212 This attribute is returned by all end points.
213  
214 =head2 $traits_rec->is_tor_exit_node()
215  
216 This returns a true value if the IP address is a Tor exit node and a false
217 value otherwise.
218  
219 This attribute is only available from the Insights web service.
220  
221 =head2 $traits_rec->isp()
222  
223 This returns the name of the ISP associated with the IP address.
224  
225 This attribute is only available from the City and Insights web service
226 endpoints and the GeoIP2 Enterprise database.
227  
228 =head2 $traits_rec->organization()
229  
230 This returns the name of the organization associated with the IP address.
231  
232 This attribute is only available from the City and Insights web service
233 endpoints and the GeoIP2 Enterprise database.
234  
235 =head2 $traits_rec->user_type()
236  
237 This returns the user type associated with the IP address. This can be one of
238 the following values:
239  
240 =over 4
241  
242 =item * business
243  
244 =item * cafe
245  
246 =item * cellular
247  
248 =item * college
249  
250 =item * content_delivery_network
251  
252 =item * dialup
253  
254 =item * government
255  
256 =item * hosting
257  
258 =item * library
259  
260 =item * military
261  
262 =item * residential
263  
264 =item * router
265  
266 =item * school
267  
268 =item * search_engine_spider
269  
270 =item * traveler
271  
272 =back
273  
274 This attribute is only available from the Insights end point and the GeoIP2
275 Enterprise database.
276  
277 =head1 SUPPORT
278  
279 =head1 AUTHORS
280  
281 =over 4
282  
283 =item *
284  
285 Dave Rolsky <drolsky@maxmind.com>
286  
287 =item *
288  
289 Greg Oschwald <goschwald@maxmind.com>
290  
291 =item *
292  
293 Mark Fowler <mfowler@maxmind.com>
294  
295 =item *
296  
297 Olaf Alders <oalders@maxmind.com>
298  
299 =back
300  
301 =head1 COPYRIGHT AND LICENSE
302  
303 This software is copyright (c) 2013 - 2018 by MaxMind, Inc.
304  
305 This is free software; you can redistribute it and/or modify it under
306 the same terms as the Perl 5 programming language system itself.
307  
308 =cut
« GeoIP2/Record/Subdivision.pm ↑ Summary GeoIP2/Role/Error/HTTP.pm »