line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Flotum::API::RequestHandler; |
2
|
8
|
|
|
8
|
|
33
|
use strict; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
198
|
|
3
|
8
|
|
|
8
|
|
48
|
use warnings; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
168
|
|
4
|
8
|
|
|
8
|
|
45
|
use utf8; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
37
|
|
5
|
8
|
|
|
8
|
|
156
|
use Carp qw/croak/; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
293
|
|
6
|
8
|
|
|
8
|
|
24
|
use Moo; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
53
|
|
7
|
8
|
|
|
8
|
|
1627
|
use namespace::clean; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
51
|
|
8
|
8
|
|
|
8
|
|
4550
|
use Stash::REST; |
|
8
|
|
|
|
|
192174
|
|
|
8
|
|
|
|
|
189
|
|
9
|
8
|
|
|
8
|
|
41
|
use JSON::MaybeXS; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
397
|
|
10
|
8
|
|
|
8
|
|
2264
|
use Furl; |
|
8
|
|
|
|
|
98267
|
|
|
8
|
|
|
|
|
1618
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'flotum_api' => ( is => 'rw', default => 'https://api.flotum.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
|
7
|
|
|
7
|
|
2188
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
74
|
my $furl = Furl->new( |
21
|
|
|
|
|
|
|
agent => 'Furl Net-Flotum/' . $Net::Flotum::VERSION, |
22
|
|
|
|
|
|
|
timeout => $self->timeout, |
23
|
|
|
|
|
|
|
headers => [ 'Accept-Encoding' => 'gzip' ], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $st = Stash::REST->new( |
27
|
|
|
|
|
|
|
do_request => sub { |
28
|
20
|
|
|
20
|
|
40812
|
my $req = shift; |
29
|
|
|
|
|
|
|
|
30
|
20
|
50
|
|
|
|
176
|
croak 'invalid flotum_api' unless $self->flotum_api =~ /^https?:\/\//; |
31
|
|
|
|
|
|
|
|
32
|
20
|
|
|
|
|
62
|
$req->uri( $req->uri->abs( $self->flotum_api ) ); |
33
|
|
|
|
|
|
|
|
34
|
20
|
|
|
|
|
23164
|
return $furl->request($req); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
decode_response => sub { |
38
|
18
|
|
|
18
|
|
7599
|
my $res = shift; |
39
|
|
|
|
|
|
|
|
40
|
18
|
|
|
|
|
92
|
return decode_json( $res->content ); |
41
|
|
|
|
|
|
|
} |
42
|
7
|
|
|
|
|
404
|
); |
43
|
|
|
|
|
|
|
eval q|$st->add_trigger('process_response', sub{use DDP; my $x = $_[1]; |
44
|
|
|
|
|
|
|
my $req = $x->{req}->as_string; |
45
|
7
|
0
|
33
|
|
|
10369
|
my $res = $x->{res}->as_string; p $req; p $res;}) | if exists $ENV{TRACE} && $ENV{TRACE}; |
46
|
7
|
|
|
|
|
22
|
return $st; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |