line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Flotum::API::RequestHandler; |
2
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
115
|
|
3
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
90
|
|
4
|
4
|
|
|
4
|
|
19
|
use utf8; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
24
|
|
5
|
4
|
|
|
4
|
|
107
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
201
|
|
6
|
4
|
|
|
4
|
|
24
|
use Moo; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
22
|
|
7
|
4
|
|
|
4
|
|
1374
|
use namespace::clean; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
28
|
|
8
|
4
|
|
|
4
|
|
3077
|
use Stash::REST; |
|
4
|
|
|
|
|
142926
|
|
|
4
|
|
|
|
|
128
|
|
9
|
4
|
|
|
4
|
|
29
|
use JSON::MaybeXS; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
249
|
|
10
|
4
|
|
|
4
|
|
1292
|
use Furl; |
|
4
|
|
|
|
|
67293
|
|
|
4
|
|
|
|
|
1051
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'flotum_api' => ( is => 'rw', default => 'https://flotum-api.appcivico.com' ); |
13
|
|
|
|
|
|
|
has 'timeout' => ( is => 'ro', default => 10 ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'stash' => ( is => 'ro', lazy => 1, builder => '_build_stash' ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_stash { |
18
|
3
|
|
|
3
|
|
33
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
35
|
my $furl = Furl->new( |
21
|
|
|
|
|
|
|
agent => 'Furl Net-Flotum/' . $Net::Flotum::VERSION, |
22
|
|
|
|
|
|
|
timeout => $self->timeout, |
23
|
|
|
|
|
|
|
headers => [ 'Accept-Encoding' => 'gzip', 'X-Features' => 'array-errors' ], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $st = Stash::REST->new( |
27
|
|
|
|
|
|
|
do_request => sub { |
28
|
16
|
|
|
16
|
|
24445
|
my $req = shift; |
29
|
|
|
|
|
|
|
|
30
|
16
|
50
|
|
|
|
135
|
croak 'invalid flotum_api' unless $self->flotum_api =~ /^https?:\/\//; |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
|
|
64
|
$req->uri( $req->uri->abs( $self->flotum_api ) ); |
33
|
|
|
|
|
|
|
|
34
|
16
|
|
|
|
|
17343
|
return $furl->request($req); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
decode_response => sub { |
38
|
14
|
|
|
14
|
|
2925
|
my $res = shift; |
39
|
|
|
|
|
|
|
|
40
|
14
|
|
|
|
|
71
|
return decode_json( $res->content ); |
41
|
|
|
|
|
|
|
} |
42
|
3
|
|
|
|
|
260
|
); |
43
|
|
|
|
|
|
|
eval q|$st->add_trigger('process_response', sub{use DDP; my $x = $_[1]; |
44
|
|
|
|
|
|
|
my $req = $x->{req}->as_string; |
45
|
3
|
0
|
33
|
|
|
7000
|
my $res = $x->{res}->as_string; p $req; p $res;}) | if exists $ENV{TRACE} && $ENV{TRACE}; |
46
|
3
|
|
|
|
|
13
|
return $st; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |