AbuseIPDB/ReportResponse.pm

filter: Statementstmt 100% 13 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 20 / 20 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« AbuseIPDB/CheckResponse.pm ↑ Summary
1 package WebService::AbuseIPDB::ReportResponse;
2  
3 #===============================================================================
4 # FILE: ReportResponse.pm
5 # DESCRIPTION: Reponse for report endpoint
6 # AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk
7 # ORGANIZATION: Openstrike
8 # CREATED: 17/08/19 12:26:19
9 #===============================================================================
10  
11 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use parent 'WebService::AbuseIPDB::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 our $VERSION = $WebService::AbuseIPDB::Response::VERSION;
16  
17 1 ▶sub score { return shift->{data}->{abuseConfidenceScore} }
Subroutine score: called CC=1 SCAR=0.0
Pod documented
18 1 ▶sub ip { return shift->{data}->{ipAddress} }
Subroutine ip: called CC=1 SCAR=0.0
Pod documented
19  
20 2 1;
21  
22 __END__
23  
24 =pod
25  
26 =encoding utf8
27  
28 =head1 NAME
29  
30 WebService::AbuseIPDB::ReportResponse - Specific class for responses to
31 the C<report> method of L<WebService::AbuseIPDB>.
32  
33 =head1 SYNOPSIS
34  
35 The C<report> method of L<WebService::AbuseIPDB>
36 will return an object of this class. It is a subclass of the generic
37 L<WebService::AbuseIPDB::Response> class.
38  
39 use WebService::AbuseIPDB;
40  
41 my $ipdb = WebService::AbuseIPDB->new (key => 'abc123...');
42 my $res = $ipdb->report (ip => '127.0.0.2', categories => [3],
43 comment => 'Over 3000 attacks in the last hour');
44 unless ($res->successful) {
45 for my $err (@{$res->errors}) {
46 warn "Error $err->{status}: $err->{detail}\n";
47 }
48 die "Cannot continue.\n";
49 }
50 printf "%s has a score of %i\n", $res->ip, $res->score;
51  
52 =head1 METHODS
53  
54 The C<new>, C<successful> and C<errors> methods are inherited from
55 L<WebService::AbuseIPDB::Response>. All other methods are accessors as
56 listed here.
57  
58 =head2 score
59  
60 Returns the abuse score as an integer between 0 and 100 inclusive.
61  
62 =head2 ip
63  
64 Returns the IP address itself as a string.
65  
66 =head1 STABILITY
67  
68 This is currently alpha software. Be aware that both the internals and
69 the interface are liable to change.
70  
71 =head1 AUTHOR
72  
73 Pete Houston, C<< <cpan at openstrike.co.uk> >>
74  
75 =head1 SEE ALSO
76  
77 L<WebService::AbuseIPDB> for general use of the client,
78 L<WebService::AbuseIPDB::Response> for the parent class and
79 L<Version 2 of the AbuseIPDB API|https://docs.abuseipdb.com/> for API
80 details/restrictions.
81  
82 =head1 LICENCE AND COPYRIGHT
83  
84 Copyright © 2020 Pete Houston
85  
86 This program is free software; you can redistribute it and/or modify
87 it under the terms of the GNU General Public License as published by
88 the Free Software Foundation; version 2 dated June, 1991 or at your option
89 any later version.
90  
91 This program is distributed in the hope that it will be useful,
92 but WITHOUT ANY WARRANTY; without even the implied warranty of
93 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94 GNU General Public License for more details.
95  
96 A copy of the GNU General Public License is available in the source tree;
97 if not, write to the Free Software Foundation, Inc.,
98 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
99  
100 =cut
« AbuseIPDB/CheckResponse.pm ↑ Summary