AbuseIPDB/CheckResponse.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 100% 12 / 12 totaltotal 100% 50 / 50 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« AbuseIPDB/BlacklistResponse.pm ↑ Summary AbuseIPDB/ReportResponse.pm »
1 package WebService::AbuseIPDB::CheckResponse;
2 #
3 #===============================================================================
4 # FILE: CheckResponse.pm
5 # DESCRIPTION: Response for check endpoint
6 # AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk
7 # ORGANIZATION: Openstrike
8 # CREATED: 12/08/19 14:51:10
9 #===============================================================================
10  
11 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use parent 'WebService::AbuseIPDB::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 our $VERSION = $WebService::AbuseIPDB::Response::VERSION;
16  
17 1 ▶sub cc { return shift->{data}->{countryCode} }
Subroutine cc: called CC=1 SCAR=0.0
Pod documented
18 1 ▶sub score { return shift->{data}->{abuseConfidenceScore} }
Subroutine score: called CC=1 SCAR=0.0
Pod documented
19 1 ▶sub report_count { return shift->{data}->{totalReports} }
Subroutine report_count: called CC=1 SCAR=0.0
Pod documented
20 1 ▶sub whitelisted { return shift->{data}->{isWhitelisted} }
Subroutine whitelisted: called CC=1 SCAR=0.0
Pod documented
21 1 ▶sub isp { return shift->{data}->{isp} }
Subroutine isp: called CC=1 SCAR=0.0
Pod documented
22 1 ▶sub last_report_time { return shift->{data}->{lastReportedAt} }
Subroutine last_report_time: called CC=1 SCAR=0.0
Pod documented
23 1 ▶sub usage_type { return shift->{data}->{usageType} }
Subroutine usage_type: called CC=1 SCAR=0.0
Pod documented
24 1 ▶sub ip { return shift->{data}->{ipAddress} }
Subroutine ip: called CC=1 SCAR=0.0
Pod documented
25 1 ▶sub ipv { return shift->{data}->{ipVersion} }
Subroutine ipv: called CC=1 SCAR=0.0
Pod documented
26 1 ▶sub public { return shift->{data}->{isPublic} }
Subroutine public: called CC=1 SCAR=0.0
Pod documented
27 1 ▶sub domain { return shift->{data}->{domain} }
Subroutine domain: called CC=1 SCAR=0.0
Pod documented
28 1 ▶sub reporter_count { return shift->{data}->{numDistinctUsers} }
Subroutine reporter_count: called CC=1 SCAR=0.0
Pod documented
29  
30 3 1;
31  
32 __END__
33  
34 =pod
35  
36 =encoding utf8
37  
38 =head1 NAME
39  
40 WebService::AbuseIPDB::CheckResponse - Specific class for responses to
41 check method
42  
43 =head1 SYNOPSIS
44  
45 The C<check> method of L<WebService::AbuseIPDB>
46 will return an object of this class. It is a subclass of the generic
47 L<WebService::AbuseIPDB::Response> class.
48  
49 use WebService::AbuseIPDB;
50  
51 my $ipdb = WebService::AbuseIPDB->new (key => 'abc123...');
52 my $res = $ipdb->check (ip => '127.0.0.2');
53 unless ($res->successful) {
54 for my $err (@{$res->errors}) {
55 warn "Error $err->{status}: $err->{detail}\n";
56 }
57 die "Cannot continue.\n";
58 }
59 printf "%s has a score of %i, last reported at %s\n",
60 $res->ip, $res->score, $res->last_report_time;
61  
62 =head1 METHODS
63  
64 The C<new>, C<successful> and C<errors> methods are inherited from
65 L<WebService::AbuseIPDB::Response>. All other methods are accessors as
66 listed here.
67  
68 =head2 cc
69  
70 Returns the 2-letter country code of this IP address.
71  
72 =head2 score
73  
74 Returns the abuse score as an integer between 0 and 100 inclusive.
75  
76 =head2 report_count
77  
78 Returns the total number of reports of this address in the requested
79 date range as a whole number.
80  
81 =head2 isp
82  
83 Returns the ISP of this IP address, according to AbuseIPDB records.
84  
85 =head2 last_report_time
86  
87 Returns the time of the last report of this address as
88 "YYYY-MM-DDTHH:MM:SS+HH:MM".
89  
90 =head2 usage_type
91  
92 Returns the usage type of this IP address, according to AbuseIPDB
93 records.
94  
95 =head2 whitelisted
96  
97 Returns true if AbuseIPDB has whitelisted this address for some reason.
98  
99 =head2 ip
100  
101 Returns the IP address itself as a string.
102  
103 =head2 ipv
104  
105 Returns the version of the IP address as an integer (ie. 6 or 4).
106  
107 =head2 public
108  
109 Returns true if the IP address is a public address, otherwise false.
110  
111 =head2 reporter_count
112  
113 Returns the number of distinct users who have reported this IP address
114 in the requested date range.
115  
116 =head2 domain
117  
118 Returns the domain of this IP address, according to AbuseIPDB records.
119  
120 =head1 STABILITY
121  
122 This is currently alpha software. Be aware that both the internals and
123 the interface are liable to change.
124  
125 =head1 AUTHOR
126  
127 Pete Houston, C<< <cpan at openstrike.co.uk> >>
128  
129 =head1 SEE ALSO
130  
131 L<WebService::AbuseIPDB> for general use of the client,
132 L<WebService::AbuseIPDB::Response> for the parent class and
133 L<Version 2 of the AbuseIPDB API|https://docs.abuseipdb.com/> for API
134 details/restrictions.
135  
136 =head1 LICENCE AND COPYRIGHT
137  
138 Copyright © 2020 Pete Houston
139  
140 This program is free software; you can redistribute it and/or modify
141 it under the terms of the GNU General Public License as published by
142 the Free Software Foundation; version 2 dated June, 1991 or at your option
143 any later version.
144  
145 This program is distributed in the hope that it will be useful,
146 but WITHOUT ANY WARRANTY; without even the implied warranty of
147 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
148 GNU General Public License for more details.
149  
150 A copy of the GNU General Public License is available in the source tree;
151 if not, write to the Free Software Foundation, Inc.,
152 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
153  
154 =cut
« AbuseIPDB/BlacklistResponse.pm ↑ Summary AbuseIPDB/ReportResponse.pm »