line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Flotum::API::RequestHandler; |
2
|
4
|
|
|
4
|
|
15
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
99
|
|
3
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
84
|
|
4
|
4
|
|
|
4
|
|
11
|
use utf8; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
23
|
|
5
|
4
|
|
|
4
|
|
81
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
163
|
|
6
|
4
|
|
|
4
|
|
14
|
use Moo; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
17
|
|
7
|
4
|
|
|
4
|
|
968
|
use namespace::clean; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
23
|
|
8
|
4
|
|
|
4
|
|
2739
|
use Stash::REST; |
|
4
|
|
|
|
|
114916
|
|
|
4
|
|
|
|
|
118
|
|
9
|
4
|
|
|
4
|
|
26
|
use JSON::MaybeXS; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
275
|
|
10
|
4
|
|
|
4
|
|
1219
|
use Furl; |
|
4
|
|
|
|
|
55796
|
|
|
4
|
|
|
|
|
935
|
|
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
|
3
|
|
|
3
|
|
31
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
47
|
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
|
17
|
|
|
17
|
|
22051
|
my $req = shift; |
29
|
|
|
|
|
|
|
|
30
|
17
|
50
|
|
|
|
156
|
croak 'invalid flotum_api' unless $self->flotum_api =~ /^https?:\/\//; |
31
|
|
|
|
|
|
|
|
32
|
17
|
|
|
|
|
62
|
$req->uri( $req->uri->abs( $self->flotum_api ) ); |
33
|
|
|
|
|
|
|
|
34
|
17
|
|
|
|
|
14952
|
return $furl->request($req); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
decode_response => sub { |
38
|
14
|
|
|
14
|
|
2337
|
my $res = shift; |
39
|
|
|
|
|
|
|
|
40
|
14
|
|
|
|
|
71
|
return decode_json( $res->content ); |
41
|
|
|
|
|
|
|
} |
42
|
3
|
|
|
|
|
210
|
); |
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
|
|
|
5207
|
my $res = $x->{res}->as_string; p $req; p $res;}) | if exists $ENV{TRACE} && $ENV{TRACE}; |
46
|
3
|
|
|
|
|
11
|
return $st; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |