| 1 | package PagSeguro::API; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | our $VERSION = '0.004'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use PagSeguro::API::Checkout; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use PagSeguro::API::Transaction; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use PagSeguro::API::Notification; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # constructor | ||||||||||||||||||||||||||||
| 11 | sub new { | ||||||||||||||||||||||||||||
| 12 | 12 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 12 | ▶ | my %args = @_ if (@_ % 2) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # start resource | ||||||||||||||||||||||||||||
| 16 | 12 | PagSeguro::API::Resource->instance; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # check env vars | ||||||||||||||||||||||||||||
| 19 | $args{email} = $ENV{PAGSEGURO_API_EMAIL} || undef | ||||||||||||||||||||||||||||
| 20 | 12 | ▶ | unless $args{email}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ENV{'PAGSEGURO_API_EMAIL'} || undef
MC/DC100%1/1
$ENV{'PAGSEGURO_API_EMAIL'} || undef
$ENV{'PAGSEGURO_API_EMAIL'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_EMAIL'}
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $args{token} = $ENV{PAGSEGURO_API_TOKEN} || undef | ||||||||||||||||||||||||||||
| 23 | 12 | ▶ | unless $args{token}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ENV{'PAGSEGURO_API_TOKEN'} || undef
MC/DC100%1/1
$ENV{'PAGSEGURO_API_TOKEN'} || undef
$ENV{'PAGSEGURO_API_TOKEN'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_TOKEN'}
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # enable sandbox | ||||||||||||||||||||||||||||
| 26 | $ENV{PAGSEGURO_API_SANDBOX} = $args{sandbox} | ||||||||||||||||||||||||||||
| 27 | 12 | ▶ | if $args{sandbox}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # enable debug | ||||||||||||||||||||||||||||
| 30 | $ENV{PAGSEGURO_API_DEBUG} = $args{debug} | ||||||||||||||||||||||||||||
| 31 | 12 | ▶ | if $args{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | return bless { | ||||||||||||||||||||||||||||
| 34 | _email => $args{email} || undef, | ||||||||||||||||||||||||||||
| 35 | _token => $args{token} || undef, | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 12 | ▶ | _checkout => undef, | ||||||||||||||||||||||||||
|
Condition100%4/4
$args{'email'} || undef
$args{'token'} || undef
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'}
Truth table100%2/2
A
A= $args{'token'}
| |||||||||||||||||||||||||||||
| 38 | _transaction => undef, | ||||||||||||||||||||||||||||
| 39 | _notification => undef, | ||||||||||||||||||||||||||||
| 40 | }, $class; | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # accessors | ||||||||||||||||||||||||||||
| 44 | sub email { | ||||||||||||||||||||||||||||
| 45 | 18 | ▶ | $_[0]->{_email} = $_[1] if $_[1]; | ||||||||||||||||||||||||||
|
Subroutine
email: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 18 | return shift->{_email}; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub token { | ||||||||||||||||||||||||||||
| 50 | 18 | ▶ | $_[0]->{_token} = $_[1] if $_[1]; | ||||||||||||||||||||||||||
|
Subroutine
token: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 18 | return shift->{_token}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # methods | ||||||||||||||||||||||||||||
| 55 | sub transaction { | ||||||||||||||||||||||||||||
| 56 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
transaction: called CC=6 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # error | ||||||||||||||||||||||||||||
| 59 | 4 | ▶ | die "Exception: e-mail or token undef" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->email and $self->token
MC/DC0%0/2
$self->email and $self->token
$self->email
$self->token
Truth table33%1/3
A and B
A= $self->emailB= $self->token
| |||||||||||||||||||||||||||||
| 60 | unless $self->email && $self->token; | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # manual instance | ||||||||||||||||||||||||||||
| 63 | 4 | ▶ | $self->{_transaction} = $_[0] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] and $_[0]->isa("PagSeguro::API::Transaction")
MC/DC0%0/2
$_[0] and $_[0]->isa("PagSeguro::API::Transaction")
$_[0]
$_[0]->isa("PagSeguro::API::Transaction")
Truth table33%1/3
A and B
A= $_[0]B= $_[0]->isa("PagSeguro::API::Transaction")
| |||||||||||||||||||||||||||||
| 64 | if $_[0] && $_[0]->isa('PagSeguro::API::Transaction'); | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | $self->{_transaction} = PagSeguro::API::Transaction->new( | ||||||||||||||||||||||||||||
| 68 | email => $self->email, token => $self->token | ||||||||||||||||||||||||||||
| 69 | 4 | ▶ | ) unless $self->{_transaction}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 4 | return $self->{_transaction}; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | sub notification { | ||||||||||||||||||||||||||||
| 75 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
notification: called CC=6 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # error | ||||||||||||||||||||||||||||
| 78 | 2 | ▶ | die "Exception: e-mail or token undef" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->email and $self->token
MC/DC0%0/2
$self->email and $self->token
$self->email
$self->token
Truth table33%1/3
A and B
A= $self->emailB= $self->token
| |||||||||||||||||||||||||||||
| 79 | unless $self->email && $self->token; | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # manual instance | ||||||||||||||||||||||||||||
| 82 | 2 | ▶ | $self->{_notification} = $_[0] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] and $_[0]->isa("PagSeguro::API::Notification")
MC/DC0%0/2
$_[0] and $_[0]->isa("PagSeguro::API::Notification")
$_[0]
$_[0]->isa("PagSeguro::API::Notification")
Truth table33%1/3
A and B
A= $_[0]B= $_[0]->isa("PagSeguro::API::Notification")
| |||||||||||||||||||||||||||||
| 83 | if $_[0] && $_[0]->isa('PagSeguro::API::Notification'); | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | $self->{_notification} = PagSeguro::API::Notification->new( | ||||||||||||||||||||||||||||
| 87 | email => $self->email, token => $self->token | ||||||||||||||||||||||||||||
| 88 | 2 | ▶ | ) unless $self->{_notification}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | return $self->{_notification}; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub checkout { | ||||||||||||||||||||||||||||
| 94 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
checkout: called CC=6 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # error | ||||||||||||||||||||||||||||
| 97 | 3 | ▶ | die "Exception: e-mail or token undef" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->email and $self->token
MC/DC0%0/2
$self->email and $self->token
$self->email
$self->token
Truth table33%1/3
A and B
A= $self->emailB= $self->token
| |||||||||||||||||||||||||||||
| 98 | unless $self->email && $self->token; | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | # manual instance | ||||||||||||||||||||||||||||
| 101 | 3 | ▶ | $self->{_checkout} = $_[0] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] and $_[0]->isa("PagSeguro::API::Checkout")
MC/DC0%0/2
$_[0] and $_[0]->isa("PagSeguro::API::Checkout")
$_[0]
$_[0]->isa("PagSeguro::API::Checkout")
Truth table33%1/3
A and B
A= $_[0]B= $_[0]->isa("PagSeguro::API::Checkout")
| |||||||||||||||||||||||||||||
| 102 | if $_[0] && $_[0]->isa('PagSeguro::API::Checkout'); | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | $self->{_checkout} = PagSeguro::API::Checkout->new( | ||||||||||||||||||||||||||||
| 106 | email => $self->email, token => $self->token | ||||||||||||||||||||||||||||
| 107 | 3 | ▶ | ) unless $self->{_checkout}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 3 | return $self->{_checkout}; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 6 | 1; | |||||||||||||||||||||||||||
| 114 | __END__ | ||||||||||||||||||||||||||||