AbuseIPDB/BlacklistResponse.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 26 / 26 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« AbuseIPDB/BlacklistMember.pm ↑ Summary AbuseIPDB/CheckResponse.pm »
1 package WebService::AbuseIPDB::BlacklistResponse;
2 #
3 #===============================================================================
4 # FILE: BlacklistResponse.pm
5 # DESCRIPTION: Response for blacklist endpoint
6 # AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk
7 # ORGANIZATION: Openstrike
8 # CREATED: 11/02/20 13:46:02
9 #===============================================================================
10  
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use parent 'WebService::AbuseIPDB::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use WebService::AbuseIPDB::BlacklistMember;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 our $VERSION = $WebService::AbuseIPDB::Response::VERSION;
17  
18 1 ▶sub as_at { return shift->{meta}->{generatedAt} }
Subroutine as_at: called CC=1 SCAR=0.0
Pod documented
19 sub list {
20 return
21 6 map { WebService::AbuseIPDB::BlacklistMember->new ($_) }
22 2 ▶ @{shift->{data}};
Subroutine list: called CC=1 SCAR=0.0
Pod documented
23 }
24  
25 1 1;
26  
27 __END__
28  
29 =pod
30  
31 =encoding utf8
32  
33 =head1 NAME
34  
35 WebService::AbuseIPDB::BlacklistResponse - Specific class for responses to
36 blacklist method
37  
38 =head1 SYNOPSIS
39  
40 The C<blacklist> method of L<WebService::AbuseIPDB>
41 will return an object of this class. It is a subclass of the generic
42 L<WebService::AbuseIPDB::Response> class.
43  
44 use WebService::AbuseIPDB;
45  
46 my $ipdb = WebService::AbuseIPDB->new (key => 'abc123...');
47 my $res = $ipdb->blacklist (limit => 5);
48 unless ($res->successful) {
49 for my $err (@{$res->errors}) {
50 warn "Error $err->{status}: $err->{detail}\n";
51 }
52 die "Cannot continue.\n";
53 }
54 my $when = $res->as_at;
55 my @list = $res->list;
56 print "As at $when\n";
57 for my $item (@list) {
58 printf "%s has a score of %i\n",
59 $item->ip, $item->score;
60 }
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 as_at
69  
70 Returns the time at which this list was generated in the format
71 YYYY-MM-DDTHH:MM:SS+HH:MM as a scalar string.
72  
73 =head2 list
74  
75 Returns the payload as an array of
76 L<WebService::AbuseIPDB::BlacklistMember> objects
77  
78 =head1 SEE ALSO
79  
80 L<WebService::AbuseIPDB> for general use of the client,
81 L<WebService::AbuseIPDB::Response> for the parent class and
82 L<Version 2 of the AbuseIPDB API|https://docs.abuseipdb.com/> for API
83 details/restrictions.
84  
85 =head1 LICENCE AND COPYRIGHT
86  
87 Copyright © 2020 Pete Houston
88  
89 This program is free software; you can redistribute it and/or modify
90 it under the terms of the GNU General Public License as published by
91 the Free Software Foundation; version 2 dated June, 1991 or at your option
92 any later version.
93  
94 This program is distributed in the hope that it will be useful,
95 but WITHOUT ANY WARRANTY; without even the implied warranty of
96 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97 GNU General Public License for more details.
98  
99 A copy of the GNU General Public License is available in the source tree;
100 if not, write to the Free Software Foundation, Inc.,
101 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
102  
103 =cut
« AbuseIPDB/BlacklistMember.pm ↑ Summary AbuseIPDB/CheckResponse.pm »