blib/lib/Net/Moip/V2/Endpoint.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.0% 9 / 10 Podpod 66.6% 2 / 3 totaltotal 87.5% 49 / 56 SCAR 6.9
CC
2
Cov
93%
get
2.0
decode_json
2.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Net/Moip/V2.pm ↑ Summary Build »
1 package Net::Moip::V2::Endpoint;
2  
3 2 ▶use IO::Socket::SSL;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Furl;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 my $JSON = JSON->new->utf8;
11  
12 2 has 'path', is => 'ro', required => 1;
13  
14 2 has 'api_url', is => 'ro',required => 1;
15  
16 2 has 'ua', is => 'ro', required => 1;
17  
18 2 has 'token', is => 'ro', required => 1;
19  
20 2 has 'key', is => 'ro', required => 1;
21  
22 2 has 'client_id', is => 'ro';
23  
24 2 has 'client_secret', is => 'ro';
25  
26 2 has 'access_token', is => 'ro';
27  
28 has '_basic_auth_token', is => 'ro', lazy => 1, default => sub {
29 4 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
30 4 'Basic '.MIME::Base64::encode_base64( $self->token .':'. $self->key, '');
31 2 };
32  
33 has 'url', is => 'ro', init_arg => undef, default => sub {
34 5 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
35 5 join '/', $self->api_url, $self->path;
36 2 };
37  
38  
39  
40 sub get {
41 2 ▶ my ($self, $id) = @_;
Subroutine get: called CC=2 SCAR=7.0
Pod undocumented
42  
43 2 ▶ my $url = join '/', $self->url, $id || ();
Condition66%2/3
$id || ()
l!l&&r!l&&!r
110
MC/DC0%0/2
$id || ()
$id ()
Truth table66%2/3
A || B
A= $idB= ()
ABresult
1X1
011
000
44 2 $self->ua->get($url, [
45 'Content-Type' => 'application/json',
46 'Authentication' => $self->_basic_auth_token
47 ]);
48 }
49  
50 sub post {
51 1 ▶ my ($self, $data) = @_;
Subroutine post: called CC=1 SCAR=0.0
Pod documented
52  
53 1 $self->ua->post($self->url, [
54  
55 'Content-Type' => 'application/json',
56 'Authentication' => $self->_basic_auth_token
57  
58 ], $JSON->encode($data) );
59 }
60  
61 sub decode_json {
62 0 ▶ my $self = shift;
Subroutine decode_json: not called CC=1 SCAR=6.9
Pod documented
63 0 $JSON->decode($_[0]);
64 }
65  
66  
67  
68 2 1;
69 __END__
« blib/lib/Net/Moip/V2.pm ↑ Summary Build »