line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ambassador::API::V2::Role::Response; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
21554
|
use Moo::Role; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
16
|
|
4
|
3
|
|
|
3
|
|
840
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
212
|
|
5
|
3
|
|
|
3
|
|
15
|
use Types::Standard ":types"; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
with 'Ambassador::API::V2::Role::HasJSON'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has http_response => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => HashRef, |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has response => ( |
17
|
|
|
|
|
|
|
is => 'lazy', |
18
|
|
|
|
|
|
|
isa => HashRef, |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _build_response { |
23
|
2
|
|
|
2
|
|
870
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
5
|
my $content = eval { $self->json->decode($self->http_response->{content}); }; |
|
2
|
|
|
|
|
54
|
|
26
|
2
|
50
|
|
|
|
7
|
croak "Failed to decode @{[ $self->http_response->{content} ]}" if !$content; |
|
0
|
|
|
|
|
0
|
|
27
|
2
|
|
|
|
|
32
|
return $content->{response}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has code => ( |
31
|
|
|
|
|
|
|
is => 'lazy', |
32
|
|
|
|
|
|
|
isa => Int, |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _build_code { |
37
|
2
|
|
|
2
|
|
1103
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
10
|
return $self->response->{code}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has message => ( |
43
|
|
|
|
|
|
|
is => 'lazy', |
44
|
|
|
|
|
|
|
isa => Str, |
45
|
|
|
|
|
|
|
required => 1 |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build_message { |
49
|
2
|
|
|
2
|
|
1863
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
7
|
return $self->response->{message}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new_from_response { |
55
|
2
|
|
|
2
|
1
|
8098
|
my $class = shift; |
56
|
2
|
|
|
|
|
4
|
my $res = shift; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
11
|
return $class->new(http_response => $res); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub is_success { |
62
|
2
|
|
|
2
|
1
|
546
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
7
|
return $self->code == 200; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |