lib/PagSeguro/API.pm

filter: Statementstmt 80.8% 38 / 47 Branchbran 40.6% 13 / 32 Conditioncond 100% 8 / 8 MC/DCmcdc 100% 4 / 4 Subroutinesub 80.0% 12 / 15 Podpod 88.8% 8 / 9 totaltotal 72.1% 83 / 115 CC 21 SCAR 19.1
CC
21
Cov
68%
_set_auth
20.0
new
10.2
debug
6.0
CRAP 6.7
« blib/lib/PagSeguro/API/Transaction.pm ↑ Summary lib/PagSeguro/API/Transaction.pm »
1 package PagSeguro::API;
2 # ABSTRACT: PagSeguro::API - UOL PagSeguro Payment Gateway API Module
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 our $VERSION = '0.006';
7  
8 6 ▶use PagSeguro::API::Checkout;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use PagSeguro::API::Transaction;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use PagSeguro::API::Notification;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # constructor
13 sub new {
14 12 ▶ my $class = shift;
Subroutine new: called CC=10 SCAR=23.2
Pod documented
15 12 ▶ my $args = (@_ % 2 == 0)? {@_} : shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 0 ? : 12 0 12
16  
17 # check env vars
18 $args->{email} = $ENV{PAGSEGURO_API_EMAIL} || undef
19 12 ▶ unless $args->{email};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"email"} 2 10 12
Condition100%2/2
$ENV{'PAGSEGURO_API_EMAIL'} || undef
l!l
11
MC/DC100%1/1
$ENV{'PAGSEGURO_API_EMAIL'} || undef
$ENV{'PAGSEGURO_API_EMAIL'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_EMAIL'}
Aresult
11
00
20  
21 $args->{token} = $ENV{PAGSEGURO_API_TOKEN} || undef
22 12 ▶ unless $args->{token};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"token"} 2 10 12
Condition100%2/2
$ENV{'PAGSEGURO_API_TOKEN'} || undef
l!l
11
MC/DC100%1/1
$ENV{'PAGSEGURO_API_TOKEN'} || undef
$ENV{'PAGSEGURO_API_TOKEN'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_TOKEN'}
Aresult
11
00
23  
24 # enable sandbox
25 $ENV{PAGSEGURO_API_SANDBOX} = $args->{sandbox}
26 12 ▶ if $args->{sandbox};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"sandbox"} 0 12 12
27  
28 # enable debug
29 $ENV{PAGSEGURO_API_DEBUG} = $args->{debug}
30 12 ▶ if $args->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"debug"} 0 12 12
31  
32 return bless {
33 _email => $args->{email} || undef,
34 _token => $args->{token} || undef,
35  
36 # load resources
37 12 ▶ _resources => PagSeguro::API::Resource->new
Condition100%4/4
$args->{'email'} || undef
l!l
111
$args->{'token'} || undef
l!l
111
MC/DC100%1/1
$args->{'email'} || undef
$args->{'email'}
MC/DC100%1/1
$args->{'token'} || undef
$args->{'token'}
Truth table100%2/2
A
A= $args->{'email'}
Aresult
11
00
Truth table100%2/2
A
A= $args->{'token'}
Aresult
11
00
38 }, $class;
39 }
40  
41 # accessors
42 sub email {
43 4 ▶ $_[0]->{_email} = $_[1] if $_[1];
Subroutine email: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 4 4
44 4 return shift->{_email};
45 }
46  
47 sub token {
48 4 ▶ $_[0]->{_token} = $_[1] if $_[1];
Subroutine token: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 4 4
49 4 return shift->{_token};
50 }
51  
52 sub debug {
53 0 ▶ $_[0]->{_debug} = $_[1] if $_[1];
Subroutine debug: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 0 0
54 0 return shift->{_debug};
55 }
56  
57 sub sandbox {
58 0 ▶ $_[0]->{_sandbox} = $_[1] if $_[1];
Subroutine sandbox: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 0 0
59 0 return shift->{_sandbox};
60 }
61 sub resource {
62 2 ▶ return $_[0]->{_resources}->get($_[1]) if $_[1];
Subroutine resource: called CC=2 SCAR=9.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 2 0 2
63 0 return $_[0]->{_resources};
64 }
65  
66 # methods
67 sub transaction {
68 4 ▶ my $self = shift;
Subroutine transaction: called CC=2 SCAR=7.1
Pod documented
69  
70 # setting auth
71 4 ▶ $self->_set_auth(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
72  
73 4 return PagSeguro::API::Transaction->new( context => $self );
74 }
75  
76 sub notification {
77 2 ▶ my $self = shift;
Subroutine notification: called CC=2 SCAR=7.1
Pod documented
78  
79 # setting auth
80 2 ▶ $self->_set_auth(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
81  
82 2 return PagSeguro::API::Notification->new( context => $self );
83 }
84  
85 sub checkout {
86 3 ▶ my $self = shift;
Subroutine checkout: called CC=2 SCAR=7.1
Pod documented
87  
88 # setting auth
89 3 ▶ $self->_set_auth(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 3 3
90  
91 3 return PagSeguro::API::Checkout->new( context => $self );
92 }
93  
94 sub _set_auth {
95 0 ▶ my $self = shift;
Subroutine _set_auth: not called CC=4 SCAR=30.0
96 0 ▶ my $args = (@_ % 2 == 0)? {@_}: shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 0 ? : 0 0 0
97  
98 0 ▶ $self->email($args->{email}) if $args->{email};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"email"} 0 0 0
99 0 ▶ $self->email($args->{token}) if $args->{token};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"token"} 0 0 0
100 }
101  
102 6 1;
103 __END__
« blib/lib/PagSeguro/API/Transaction.pm ↑ Summary lib/PagSeguro/API/Transaction.pm »