blib/lib/neverbounce.pm

filter: Statementstmt 14.6% 34 / 232 Branchbran 0.0% 0 / 88 Conditioncond 0.0% 0 / 95 MC/DCmcdc 0.0% 0 / 51 Subroutinesub 47.3% 9 / 19 Podpod 0.0% 0 / 7 totaltotal 8.7% 43 / 492 CC 77 SCAR 51.1
CC
77
Cov
8%
nb_email_list_batch_result
420.0
nb_result_code
182.0
nb_email_list_batch_send
156.0
CRAP 166.4
↑ Summary
1 package neverbounce;
2
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use vars qw($AUTOLOAD $NB_API_VERSION %result_details %status_code_des);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Convert::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HTTP::Request::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 require Exporter;
13 1 $NB_API_VERSION = '3.1';
14 1 our $VERSION = '0.07';
15 1 our @ISA = qw(Exporter);
16 1 our @EXPORT_OK = qw();
17 1 %result_details = (
18 0 => 'No additional details',
19 1 => 'Provided email failed the syntax check'
20 );
21 1 %status_code_des= (
22 0 => 'Request has been received but has not started idexing',
23 1 => 'List is indexing and deduping',
24 2 => 'List is awaiting user input (Typically skipped for lists submitted via API)',
25 3 => 'List is being processed',
26 4 => 'List has completed verification',
27 5 => 'List has failed'
28 );
29 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
30 0 my $class = shift;
31 0 my $self = bless {}, $class;
32 0 my %hash = @_;
33 0 my $temp = $self->_initialize(@_);
34 0 ▶ if($temp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp) { } 0 0 0
35 0 return $self;
36 } else {
37 0 return;
38 }
39 }
40 0 ▶sub _initialize {
Subroutine _initialize: not called CC=10 SCAR=47.0
41 0 my $self = shift;
42 0 my %hash = @_;
43 0 ▶ if (exists($hash{api_username})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{'api_username'}) { } 0 0 0
44 0 $self->{api_username} = $hash{api_username};
45 } else {
46 0 return (resp_status=>'error',data => {error => 'mandatory_value_missing',error_description => "The value for 'api_username' is missing"},request_data => '');
47 }
48 0 ▶ if (exists($hash{api_secret_key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{'api_secret_key'}) { } 0 0 0
49 0 $self->{api_secret_key} = $hash{api_secret_key};
50 } else {
51 0 return (resp_status=>'error',data => {error => 'mandatory_value_missing',error_description => "The value for 'api_secret_key' is missing"},request_data => '');
52 }
53 0 $self->{authorization} = encode_base64($self->{api_username}.':'.$self->{api_secret_key});
54 0 my $req;
55 0 $req=POST(
56 "https://api.neverbounce.com/v3/access_token",
57 Content_Type => 'form-data',
58 Content =>[
59 grant_type => 'client_credentials',
60 scope => 'basic user'
61 ]
62 );
63 0 my $ua=LWP::UserAgent->new();
64 0 $ua->ssl_opts( "verify_hostname" => 0 );
65 0 $ua->agent('Mozilla/5.0');
66 0 $ua->default_header("Authorization"=>"Basic ".$self->{authorization});
67 0 my $result=$ua->request($req);
68 0 ▶ if($result->is_success && $result->{_content} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{'_content'} ne '') { } 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} ne ""
$result->is_success $result->{"_content"} ne ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} ne ""
ABresult
0X0
100
111
69 0 my $response=decode_json($result->{_content});
70 0 ▶ if(defined($response->{error}) || (defined($response->{success}) && $response->{success} ne 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response->{'error'} or defined $response->{'success'} and $response->{'success'} ne 1) { } 0 0 0
Condition0%0/6
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
l!l&&r!l&&!r
000
defined $response->{"success"} and $response->{"success"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
defined $response->{"error"} defined $response->{"success"} $response->{"success"} ne 1
Truth table0%0/4
A or B and C
A= defined $response->{"error"}B= defined $response->{"success"}C= $response->{"success"} ne 1
ABCresult
1XX1
0111
00X0
0100
71 0 my %response_hash = %{$response};
72 0 my %error_data = $self->nb_error(%response_hash);
73 0 die Dumper(\%error_data);
74 } else {
75 0 $self->{access_token} = $response->{access_token};
76 0 $self->{expires_in} = $response->{expires_in};
77 0 $self->{token_type} = $response->{token_type};
78 0 $self->{scope} = $response->{scope};
79 }
80 } else {
81 0 my $msg=qq{Processing terminated due to failure in request to neverbounce.com};
82 0 ▶ if($result->is_success && $result->{_content} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{'_content'} eq '') { } 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} eq ""
$result->is_success $result->{"_content"} eq ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} eq ""
ABresult
0X0
100
111
83 0 $msg=qq{Process terminated since there is no respone data from neverbounce.com};
84 0 print STDERR $msg."\n\n".Dumper($result);
85 } else {
86 0 print STDERR $msg."\n\n".Dumper($result);
87 }
88 0 return 0;
89 }
90 }
91 0 ▶sub nb_verify_email {
Subroutine nb_verify_email: not called CC=9 SCAR=45.0
Pod undocumented
92 0 my $self = shift;
93 0 my %hash = @_;
94 0 ▶ if (exists($hash{email})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{'email'}) { } 0 0 0
95 0 $self->{email} = $hash{email};
96 } else {
97 0 return (resp_status=>'error',data => {error => 'mandatory_value_missing',error_description => "The value for 'email' is missing. Please provide email address to make verification."},request_data => '');
98 }
99 0 my $req;
100 $req=POST(
101 "https://api.neverbounce.com/v3/single?access_token=".$self->{access_token},
102 Content_Type => 'form-data',
103 Content =>[
104 email => $self->{email}
105 0 ]
106 );
107 0 my $ua=LWP::UserAgent->new();
108 0 $ua->ssl_opts( "verify_hostname" => 0 );
109 0 $ua->agent('Mozilla/5.0');
110 0 my $result=$ua->request($req);
111 0 ▶ if($result->is_success && $result->{_content} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{'_content'} ne '') { } 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} ne ""
$result->is_success $result->{"_content"} ne ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} ne ""
ABresult
0X0
100
111
112 0 my $response=decode_json($result->{_content});
113 0 ▶ if(defined($response->{error}) || (defined($response->{success}) && $response->{success} ne 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response->{'error'} or defined $response->{'success'} and $response->{'success'} ne 1) { } 0 0 0
Condition0%0/6
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
l!l&&r!l&&!r
000
defined $response->{"success"} and $response->{"success"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
defined $response->{"error"} defined $response->{"success"} $response->{"success"} ne 1
Truth table0%0/4
A or B and C
A= defined $response->{"error"}B= defined $response->{"success"}C= $response->{"success"} ne 1
ABCresult
1XX1
0111
00X0
0100
114 0 my %response_hash = %{$response};
115 0 my %error_data = $self->nb_error(%response_hash);
116 0 $error_data{request_data} = Dumper($result);
117 0 return %error_data;
118 } else {
119 my %response_data = (
120 resp_status => 'success',
121 data => {
122 result_code => $response->{result},
123 result_text_code => $self->nb_result_code(result_code=>$response->{result},response_type=>'text_code'),
124 result_description => $self->nb_result_code(result_code=>$response->{result},response_type=>'description'),
125 result_safe_to_send => $self->nb_result_code(result_code=>$response->{result},response_type=>'safe_to_send'),
126 result_details_code => $response->{result_details},
127 result_details_description => $result_details{$response->{result_details}},
128 neverbounce_execution_time => $response->{execution_time}
129 },
130 0 request_data => Dumper($result)
131 );
132 0 return %response_data;
133 }
134 } else {
135 0 my $msg=qq{Processing terminated due to failure in request to neverbounce.com};
136 0 ▶ if($result->is_success && $result->{_content} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{"_content"} eq "") 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} eq ""
$result->is_success $result->{"_content"} eq ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} eq ""
ABresult
0X0
100
111
137 0 $msg=qq{Process terminated since there is no respone data from neverbounce.com};
138 }
139 0 return (resp_status=>'error',data => {error => 'Connection Error',error_description => $msg},request_data => Dumper($result));
140 }
141 }
142 0 ▶sub nb_email_list_batch_send {
Subroutine nb_email_list_batch_send: not called CC=12 SCAR=50.5
Pod undocumented
143 0 my $self = shift;
144 0 my %hash = @_;
145 0 ▶ $self->{input_location} = ($hash{input_location} eq '1')?$hash{input_location}:'0';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'input_location'} eq '1' ? : 0 0 0
146 0 ▶ if (exists($hash{input})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{'input'}) { } 0 0 0
147 0 $self->{input} = $hash{input};
148 } else {
149 0 return (resp_status=>'error',data => {error => 'mandatory_value_missing',error_description => "The value for 'input' is missing. Expected value: (If 'input_location' = 0, then 'input' should be the URL pointed to file which contain email list. If 'input_location' = 1, then 'input' should be URL encoded string of the contents of email list.)"},request_data => '');
150 }
151 0 ▶ if (exists($hash{filename})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{"filename"}) 0 0 0
152 0 $self->{filename} = $hash{filename};
153 }
154 0 my $req;
155 $req=POST(
156 "https://api.neverbounce.com/v3/bulk?access_token=".$self->{access_token},
157 Content_Type => 'form-data',
158 Content => [
159 input_location => $self->{input_location},
160 input => $self->{input},
161 0 ▶ filename => defined($self->{filename})?$self->{filename}:''
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'filename'} ? : 0 0 0
162 ]
163 );
164 0 my $ua=LWP::UserAgent->new();
165 0 $ua->ssl_opts( "verify_hostname" => 0 );
166 0 $ua->agent('Mozilla/5.0');
167 0 my $result=$ua->request($req);
168 0 ▶ if($result->is_success && $result->{_content} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{'_content'} ne '') { } 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} ne ""
$result->is_success $result->{"_content"} ne ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} ne ""
ABresult
0X0
100
111
169 0 my $response=decode_json($result->{_content});
170 0 ▶ if(defined($response->{error}) || (defined($response->{success}) && $response->{success} ne 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response->{'error'} or defined $response->{'success'} and $response->{'success'} ne 1) { } 0 0 0
Condition0%0/6
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
l!l&&r!l&&!r
000
defined $response->{"success"} and $response->{"success"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
defined $response->{"error"} defined $response->{"success"} $response->{"success"} ne 1
Truth table0%0/4
A or B and C
A= defined $response->{"error"}B= defined $response->{"success"}C= $response->{"success"} ne 1
ABCresult
1XX1
0111
00X0
0100
171 0 my %response_hash = %{$response};
172 0 my %error_data = $self->nb_error(%response_hash);
173 0 $error_data{request_data} = Dumper($result);
174 0 return %error_data;
175 } else {
176 my %response_data = (
177 resp_status => 'success',
178 data => {
179 job_status => $response->{job_status},
180 job_id => $response->{job_id},
181 neverbounce_execution_time => $response->{execution_time}
182 },
183 0 request_data => Dumper($result)
184 );
185 0 return %response_data;
186 }
187 } else {
188 0 my $msg=qq{Processing terminated due to failure in request to neverbounce.com};
189 0 ▶ if($result->is_success && $result->{_content} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{"_content"} eq "") 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} eq ""
$result->is_success $result->{"_content"} eq ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} eq ""
ABresult
0X0
100
111
190 0 $msg=qq{Process terminated since there is no respone data from neverbounce.com};
191 }
192 0 return (resp_status=>'error',data => {error => 'Connection Error',error_description => $msg},request_data => Dumper($result));
193 }
194 }
195 0 ▶sub nb_email_list_batch_check {
Subroutine nb_email_list_batch_check: not called CC=9 SCAR=45.0
Pod undocumented
196 0 my $self = shift;
197 0 my %hash = @_;
198 0 ▶ if (exists($hash{job_id})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{'job_id'}) { } 0 0 0
199 0 $self->{job_id} = $hash{job_id};
200 } else {
201 0 return (resp_status=>'error',data => {error => 'mandatory_value_missing',error_description => "The value for 'job_id' is missing."},request_data => '');
202 }
203 0 my $req;
204 $req=POST(
205 "https://api.neverbounce.com/v3/status?access_token=".$self->{access_token},
206 Content_Type => 'form-data',
207 Content =>[
208 version => $NB_API_VERSION,
209 job_id => $self->{job_id}
210 0 ]
211 );
212 0 my $ua=LWP::UserAgent->new();
213 0 $ua->ssl_opts( "verify_hostname" => 0 );
214 0 $ua->agent('Mozilla/5.0');
215 0 my $result=$ua->request($req);
216 0 ▶ if($result->is_success && $result->{_content} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{'_content'} ne '') { } 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} ne ""
$result->is_success $result->{"_content"} ne ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} ne ""
ABresult
0X0
100
111
217 0 my $response=decode_json($result->{_content});
218 0 ▶ if(defined($response->{error}) || (defined($response->{success}) && $response->{success} ne 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response->{'error'} or defined $response->{'success'} and $response->{'success'} ne 1) { } 0 0 0
Condition0%0/6
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
l!l&&r!l&&!r
000
defined $response->{"success"} and $response->{"success"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
defined $response->{"error"} defined $response->{"success"} $response->{"success"} ne 1
Truth table0%0/4
A or B and C
A= defined $response->{"error"}B= defined $response->{"success"}C= $response->{"success"} ne 1
ABCresult
1XX1
0111
00X0
0100
219 0 my %response_hash = %{$response};
220 0 my %error_data = $self->nb_error(%response_hash);
221 0 $error_data{request_data} = Dumper($result);
222 0 return %error_data;
223 } else {
224 my %response_data = (
225 resp_status => 'success',
226 data => {
227 status => $response->{status},
228 status_desc => $status_code_des{$response->{status}},
229 id => $response->{id},
230 type => $response->{type},
231 input_location => $response->{input_location},
232 orig_name => $response->{orig_name},
233 created => $response->{created},
234 started => $response->{started},
235 finished => $response->{finished},
236 file_details => $response->{file_details},
237 job_details => $response->{job_details},
238 neverbounce_execution_time => $response->{execution_time},
239 stats => $response->{stats}
240 },
241 0 request_data => Dumper($result)
242 );
243 0 return %response_data;
244 }
245 } else {
246 0 my $msg=qq{Processing terminated due to failure in request to neverbounce.com};
247 0 ▶ if($result->is_success && $result->{_content} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{"_content"} eq "") 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} eq ""
$result->is_success $result->{"_content"} eq ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} eq ""
ABresult
0X0
100
111
248 0 $msg=qq{Process terminated since there is no respone data from neverbounce.com};
249 }
250 0 return (resp_status=>'error',data => {error => 'Connection Error',error_description => $msg},request_data => Dumper($result));
251 }
252 }
253 0 ▶sub nb_email_list_batch_result {
Subroutine nb_email_list_batch_result: not called CC=20 SCAR=60.4
Pod undocumented
254 0 my $self = shift;
255 0 my %hash = @_;
256 0 ▶ if (exists($hash{job_id})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{'job_id'}) { } 0 0 0
257 0 $self->{job_id} = $hash{job_id};
258 } else {
259 0 return (resp_status=>'error',data => {error => 'mandatory_value_missing',error_description => "The value for 'job_id' is missing."},request_data => '');
260 }
261 0 my %check_status=$self->nb_email_list_batch_check(job_id=>$hash{job_id});
262 0 ▶ if($check_status{resp_status} ne 'success'){
Branch: 2 branches
BranchTrueFalseTotal
if ($check_status{'resp_status'} ne 'success') { } 0 0 0
elsif ($check_status{'data'}{'status'} ne '4') { } 0 0 0
263 0 return %check_status;
264 } elsif($check_status{data}{status} ne '4') {
265 my %error_data = (
266 resp_status=>'error',
267 data => $check_status{data},
268 0 request_data => ''
269 );
270 0 $error_data{data}{error}='list_verification_completion_failure';
271 0 $error_data{data}{error_description}=$check_status{data}{status_desc};
272 0 return %error_data;
273 }
274 0 ▶ $self->{valids} = ($hash{valids} eq '0')?$hash{valids}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'valids'} eq '0' ? : 0 0 0
275 0 ▶ $self->{invalids} = ($hash{invalids} eq '0')?$hash{invalids}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'invalids'} eq '0' ? : 0 0 0
276 0 ▶ $self->{catchall} = ($hash{catchall} eq '0')?$hash{catchall}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'catchall'} eq '0' ? : 0 0 0
277 0 ▶ $self->{disposable} = ($hash{disposable} eq '0')?$hash{disposable}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'disposable'} eq '0' ? : 0 0 0
278 0 ▶ $self->{unknown} = ($hash{unknown} eq '0')?$hash{unknown}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'unknown'} eq '0' ? : 0 0 0
279 0 ▶ $self->{duplicates} = ($hash{duplicates} eq '0')?$hash{duplicates}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'duplicates'} eq '0' ? : 0 0 0
280 0 ▶ $self->{textcodes} = ($hash{textcodes} eq '0')?$hash{textcodes}:'1';
Branch: 1 branch
BranchTrueFalseTotal
$hash{'textcodes'} eq '0' ? : 0 0 0
281 0 my $req;
282 $req=POST(
283 "https://api.neverbounce.com/v3/download?access_token=".$self->{access_token},
284 Content_Type => 'form-data',
285 Content =>[
286 job_id => $self->{job_id},
287 valids => $self->{valids},
288 invalids => $self->{invalids},
289 catchall => $self->{catchall},
290 disposable => $self->{disposable},
291 unknown => $self->{unknown},
292 duplicates => $self->{duplicates},
293 textcodes => $self->{textcodes},
294 0 ]
295 );
296 0 my $ua=LWP::UserAgent->new();
297 0 $ua->ssl_opts( "verify_hostname" => 0 );
298 0 $ua->agent('Mozilla/5.0');
299 0 my $result=$ua->request($req);
300 0 $result->{_content}=~s/\n+$//;
301 0 $result->{_content}=~s/\r+$//;
302 0 $result->{_content}=~s/\n+$//;
303 0 ▶ if($result->is_success && $result->{_content} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{'_content'} ne '') { } 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} ne ""
$result->is_success $result->{"_content"} ne ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} ne ""
ABresult
0X0
100
111
304 0 my $temp=0;
305 0 ▶ eval {decode_json($result->{_content});$temp=1;1;} or do {$temp=0;};
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &decode_json($result->{"_content"}); $temp = 1; 1 } } or do { $temp = 0 } 0 0 0
306 0 ▶ if($temp > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp > 0) { } 0 0 0
307 0 my $response=decode_json($result->{_content});
308 0 ▶ if(defined($response->{error}) || (defined($response->{success}) && $response->{success} ne 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response->{'error'} or defined $response->{'success'} and $response->{'success'} ne 1) { } 0 0 0
Condition0%0/6
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
l!l&&r!l&&!r
000
defined $response->{"success"} and $response->{"success"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $response->{"error"} or defined $response->{"success"} and $response->{"success"} ne 1
defined $response->{"error"} defined $response->{"success"} $response->{"success"} ne 1
Truth table0%0/4
A or B and C
A= defined $response->{"error"}B= defined $response->{"success"}C= $response->{"success"} ne 1
ABCresult
1XX1
0111
00X0
0100
309 0 my %response_hash = %{$response};
310 0 my %error_data = $self->nb_error(%response_hash);
311 0 $error_data{request_data} = Dumper($result);
312 0 return %error_data;
313 } else {
314 0 return (resp_status=>'error',data => {error => 'Unknown Error',error_description => "Unknown Error"},request_data => Dumper($result));
315 }
316 } else {
317 my %response_data = (
318 resp_status => 'success',
319 data => {
320 list => $result->{_content}
321 },
322 0 request_data => Dumper($result)
323 );
324 0 return %response_data;
325 }
326 } else {
327 0 my $msg=qq{Processing terminated due to failure in request to neverbounce.com};
328 0 ▶ if($result->is_success && $result->{_content} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_success and $result->{"_content"} eq "") 0 0 0
Condition0%0/3
$result->is_success and $result->{"_content"} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$result->is_success and $result->{"_content"} eq ""
$result->is_success $result->{"_content"} eq ""
Truth table0%0/3
A and B
A= $result->is_successB= $result->{"_content"} eq ""
ABresult
0X0
100
111
329 0 $msg=qq{Process terminated since there is no respone data from neverbounce.com};
330 }
331 0 return (resp_status=>'error',data => {error => 'Connection Error',error_description => $msg},request_data => Dumper($result));
332 }
333 }
334 0 ▶sub nb_result_code {
Subroutine nb_result_code: not called CC=13 SCAR=52.0
Pod undocumented
335 0 my $self = shift;
336 0 my %hash = @_;
337 0 my %result_codes = (
338 0 => {
339 text_code => 'valid',
340 numeric_code=> '0',
341 description => 'Verified as real address',
342 safe_to_send=> 'Yes'
343 },
344 1 => {
345 text_code => 'invalid',
346 numeric_code=> '1',
347 description => 'Verified as not valid',
348 safe_to_send=> 'No'
349 },
350 2 => {
351 text_code => 'disposable',
352 numeric_code=> '2',
353 description => 'A temporary, disposable address',
354 safe_to_send=> 'No'
355 },
356 3 => {
357 text_code => 'catchall',
358 numeric_code=> '3',
359 description => 'A domain-wide setting',
360 safe_to_send=> 'Maybe. Not recommended unless on private server'
361 },
362 4 => {
363 text_code => 'unknown',
364 numeric_code=> '4',
365 description => 'The server cannot be reached',
366 safe_to_send=> 'No'
367 },
368 'valid' => {
369 text_code => 'valid',
370 numeric_code=> '0',
371 description => 'Verified as real address',
372 safe_to_send=> 'Yes'
373 },
374 'invalid' => {
375 text_code => 'invalid',
376 numeric_code=> '1',
377 description => 'Verified as not valid',
378 safe_to_send=> 'No'
379 },
380 'disposable'=> {
381 text_code => 'disposable',
382 numeric_code=> '2',
383 description => 'A temporary, disposable address',
384 safe_to_send=> 'No'
385 },
386 'catchall' => {
387 text_code => 'catchall',
388 numeric_code=> '3',
389 description => 'A domain-wide setting',
390 safe_to_send=> 'Maybe. Not recommended unless on private server'
391 },
392 'unknown' => {
393 text_code => 'unknown',
394 numeric_code=> '4',
395 description => 'The server cannot be reached',
396 safe_to_send=> 'No'
397 }
398 );
399 0 ▶ if($hash{result_code} && $hash{result_code} ne '' && (($hash{result_code}=~/^\d+$/ && $hash{result_code} < 5) || $hash{result_code} eq 'valid' || $hash{result_code} eq 'invalid' || $hash{result_code} eq 'disposable' || $hash{result_code} eq 'catchall' || $hash{result_code} eq 'unknown')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{'result_code'} and $hash{'result_code'} ne '' and $hash{'result_code'} =~ /^\d+$/ && $hash{'result_code'} < 5 || $hash{'result_code'} eq 'valid' || $hash{'result_code'} eq 'invalid' || $hash{'result_code'} eq 'disposable' || $hash{'result_code'} eq 'catchall' || $hash{'result_code'} eq 'unknown') { } 0 0 0
Condition0%0/24
$hash{"result_code"} and $hash{"result_code"} ne "" and $hash{"result_code"} =~ /^\d+$/ && $hash{"result_code"} < 5 || $hash{"result_code"} eq "valid" || $hash{"result_code"} eq "invalid" || $hash{"result_code"} eq "disposable" || $hash{"result_code"} eq "catchall" || $hash{"result_code"} eq "unknown"
!ll&&!rl&&r
000
$hash{"result_code"} and $hash{"result_code"} ne ""
!ll&&!rl&&r
000
$hash{"result_code"} =~ /^\d+$/ and $hash{"result_code"} < 5 or $hash{"result_code"} eq "valid" or $hash{"result_code"} eq "invalid" or $hash{"result_code"} eq "disposable" or $hash{"result_code"} eq "catchall" or $hash{"result_code"} eq "unknown"
l!l&&r!l&&!r
000
$hash{"result_code"} =~ /^\d+$/ and $hash{"result_code"} < 5 or $hash{"result_code"} eq "valid" or $hash{"result_code"} eq "invalid" or $hash{"result_code"} eq "disposable" or $hash{"result_code"} eq "catchall"
l!l&&r!l&&!r
000
$hash{"result_code"} =~ /^\d+$/ and $hash{"result_code"} < 5 or $hash{"result_code"} eq "valid" or $hash{"result_code"} eq "invalid" or $hash{"result_code"} eq "disposable"
l!l&&r!l&&!r
000
$hash{"result_code"} =~ /^\d+$/ and $hash{"result_code"} < 5 or $hash{"result_code"} eq "valid" or $hash{"result_code"} eq "invalid"
l!l&&r!l&&!r
000
$hash{"result_code"} =~ /^\d+$/ and $hash{"result_code"} < 5 or $hash{"result_code"} eq "valid"
l!l&&r!l&&!r
000
$hash{"result_code"} =~ /^\d+$/ and $hash{"result_code"} < 5
!ll&&!rl&&r
000
MC/DC0%0/9
$hash{"result_code"} and $hash{"result_code"} ne "" and $hash{"result_code"} =~ /^\d+$/ && $hash{"result_code"} < 5 || $hash{"result_code"} eq "valid" || $hash{"result_code"} eq "invalid" || $hash{"result_code"} eq "disposable" || $hash{"result_code"} eq "catchall" || $hash{"result_code"} eq "unknown"
$hash{"result_code"} $hash{"result_code"} ne "" $hash{"result_code"} =~ /^\d+$/ $hash{"result_code"} < 5 $hash{"result_code"} eq "valid" $hash{"result_code"} eq "invalid" $hash{"result_code"} eq "disposable" $hash{"result_code"} eq "catchall" $hash{"result_code"} eq "unknown"
Truth table0%0/15
A and B and C and D or E or F or G or H or I
A= $hash{"result_code"}B= $hash{"result_code"} ne ""C= $hash{"result_code"} =~ /^\d+$/D= $hash{"result_code"} < 5E= $hash{"result_code"} eq "valid"F= $hash{"result_code"} eq "invalid"G= $hash{"result_code"} eq "disposable"H= $hash{"result_code"} eq "catchall"I= $hash{"result_code"} eq "unknown"
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
110X000000
1110000000
1111XXXXX1
110X1XXXX1
11101XXXX1
110X01XXX1
111001XXX1
110X001XX1
1110001XX1
110X0001X1
11100001X1
110X000011
1110000011
400 0 ▶ if($hash{response_type} && $hash{response_type} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{'response_type'} and $hash{'response_type'} ne '') { } 0 0 0
Condition0%0/3
$hash{"response_type"} and $hash{"response_type"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$hash{"response_type"} and $hash{"response_type"} ne ""
$hash{"response_type"} $hash{"response_type"} ne ""
Truth table0%0/3
A and B
A= $hash{"response_type"}B= $hash{"response_type"} ne ""
ABresult
0X0
100
111
401 0 ▶ if(defined($result_codes{$hash{result_code}}{$hash{response_type}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $result_codes{$hash{'result_code'}}{$hash{'response_type'}}) { } 0 0 0
402 0 return $result_codes{$hash{result_code}}{$hash{response_type}};
403 } else {
404 0 return %{$result_codes{$hash{result_code}}};
405 }
406 } else {
407 0 return %{$result_codes{$hash{result_code}}};
408 }
409 } else {
410 0 return %result_codes;
411 }
412 }
413 0 ▶sub nb_error {
Subroutine nb_error: not called CC=7 SCAR=40.3
Pod undocumented
414 0 my $self = shift;
415 0 my %hash = @_;
416 0 ▶ if(defined($hash{'error'})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $hash{'error'}) { } 0 0 0
elsif (defined $hash{'success'} and $hash{'success'} ne 'true') { } 0 0 0
417 0 return (resp_status=>'error',data => {error => $hash{'error'},error_description => $hash{'error_description'}});
418 ▶ } elsif(defined($hash{success}) && $hash{success} ne 'true') {
Condition0%0/3
defined $hash{"success"} and $hash{"success"} ne "true"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hash{"success"} and $hash{"success"} ne "true"
defined $hash{"success"} $hash{"success"} ne "true"
Truth table0%0/3
A and B
A= defined $hash{"success"}B= $hash{"success"} ne "true"
ABresult
0X0
100
111
419 0 ▶ if(defined($hash{msg}) && $hash{msg} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash{'msg'} and $hash{'msg'} ne '') { } 0 0 0
Condition0%0/3
defined $hash{"msg"} and $hash{"msg"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hash{"msg"} and $hash{"msg"} ne ""
defined $hash{"msg"} $hash{"msg"} ne ""
Truth table0%0/3
A and B
A= defined $hash{"msg"}B= $hash{"msg"} ne ""
ABresult
0X0
100
111
420 0 ▶ if($hash{'msg'} eq "Authentication failed") {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{'msg'} eq 'Authentication failed') { } 0 0 0
421 0 return (resp_status=>'error',data => {error => 'Expired/Invalid Access Tokens',error_description => $hash{'msg'}});
422 } else {
423 0 return (resp_status=>'error',data => {error => 'API Errors',error_description => $hash{'msg'}});
424 }
425 } else {
426 0 return (resp_status=>'error',data => {error => 'Error Code: '.$hash{'error_code'},error_description => $hash{'error_msg'}});
427 }
428 }
429 }
430 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
431 0 my $self = shift;
432 0 ▶ my $type = ref($self) || croak("$self is not an object");
Condition0%0/2
ref $self || croak("$self is not an object")
l!l
00
MC/DC0%0/1
ref $self || croak("$self is not an object")
ref $self
Truth table0%0/2
A
A= ref $self
Aresult
11
00
433 0 my $field = $AUTOLOAD;
434 0 $field =~ s/.*://;
435 0 my $temp='';
436 0 ▶ unless (exists $self->{$field}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{$field}) 0 0 0
437 0 die "$field does not exist in object/class $type";
438 }
439 0 exit(1);
440 }
441 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
442 0 my $self = undef;
443 }
444 1 1;
445 __END__
↑ Summary