| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package API::ParallelsWPB::Response; |
|
2
|
4
|
|
|
4
|
|
93146
|
use strict; |
|
|
4
|
|
|
|
|
94
|
|
|
|
4
|
|
|
|
|
161
|
|
|
3
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
144
|
|
|
4
|
4
|
|
|
4
|
|
2812
|
use JSON::XS qw/decode_json/; |
|
|
4
|
|
|
|
|
14912
|
|
|
|
4
|
|
|
|
|
2148
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: processing of API responses |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:IMAGO'; # AUTHORITY |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
20
|
|
|
20
|
1
|
5177
|
my ( $class, $res ) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
20
|
|
|
|
|
92
|
my $success = $res->is_success; |
|
16
|
20
|
|
|
|
|
300
|
my $status = $res->status_line; |
|
17
|
|
|
|
|
|
|
|
|
18
|
20
|
|
|
|
|
552
|
my ( $json_content, $response, $error ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
20
|
100
|
|
|
|
78
|
if ( $success ) { |
|
21
|
19
|
|
|
|
|
63
|
$json_content = $res->content; |
|
22
|
19
|
100
|
|
|
|
306
|
$response = decode_json( $json_content )->{response} if $json_content; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
else { |
|
25
|
1
|
|
|
|
|
5
|
my $error_json = $res->content; |
|
26
|
1
|
|
|
|
|
9
|
eval { $error = decode_json( $error_json )->{error}->{message}; 1; } |
|
|
1
|
|
|
|
|
6
|
|
|
27
|
1
|
50
|
|
|
|
12
|
or do { $error = $error_json }; |
|
|
0
|
|
|
|
|
0
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
20
|
|
|
|
|
247
|
return bless( |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
|
|
|
|
|
|
success => $success, |
|
33
|
|
|
|
|
|
|
json => $json_content, |
|
34
|
|
|
|
|
|
|
error => $error, |
|
35
|
|
|
|
|
|
|
response => $response, |
|
36
|
|
|
|
|
|
|
status => $status |
|
37
|
|
|
|
|
|
|
}, |
|
38
|
|
|
|
|
|
|
$class |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub json { |
|
44
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
return $self->{json}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub success { |
|
51
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
14
|
return $self->{success}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub response { |
|
58
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
|
59
|
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
18
|
return $self->{response}; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub status { |
|
65
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
9
|
return $self->{status}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub error { |
|
73
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
10
|
return $self->{error}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |