| 1 | package PagSeguro::API::Notification; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use base 'PagSeguro::API::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use LWP::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use XML::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # constructor | ||||||||||||||||||||||||||||
| 8 | sub new { | ||||||||||||||||||||||||||||
| 9 | 2 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | my %args = @_ if ( @_ % 2 ) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | return bless { | ||||||||||||||||||||||||||||
| 13 | email => $args{email} || undef, | ||||||||||||||||||||||||||||
| 14 | token => $args{token} || undef, | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | _notification => undef, | ||||||||||||||||||||||||||
|
Condition50%2/4
$args{'email'} || undef
$args{'token'} || undef
MC/DC0%0/1
$args{'email'} || undef
$args{'email'}
MC/DC0%0/1
$args{'token'} || undef
$args{'token'}
Truth table50%1/2
A
A= $args{'email'}
Truth table50%1/2
A
A= $args{'token'}
| |||||||||||||||||||||||||||||
| 17 | }, $class; | ||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # methods | ||||||||||||||||||||||||||||
| 21 | sub load { | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=7 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | my %args; | |||||||||||||||||||||||||||
| 25 | 1 | ▶ | $args{file} = $_[1] if $_[0] && $_[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] and $_[1]
MC/DC0%0/2
$_[0] and $_[1]
$_[0]
$_[1]
Truth table33%1/3
A and B
A= $_[0]B= $_[1]
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | if ( %args ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | # parse and return by file | ||||||||||||||||||||||||||||
| 29 | 1 | ▶ | return XMLin( $args{file} ) if $args{file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $response = get $self->_code_uri( $_[0] ) || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
&get(scalar $self->_code_uri($_[0])) || ''
MC/DC0%0/1
&get(scalar $self->_code_uri($_[0])) || ''
&get(scalar $self->_code_uri($_[0]))
Truth table0%0/2
A
A= &get(scalar $self->_code_uri($_[0]))
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # debug | ||||||||||||||||||||||||||||
| 35 | warn "[Debug] Notification Response: $response\n" | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if $ENV{PAGSEGURO_API_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | return XMLin($response); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub _code_uri { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my ( $self, $code ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_code_uri: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | my $uri = join '', | ||||||||||||||||||||||||||||
| 45 | ( | ||||||||||||||||||||||||||||
| 46 | $self->resource( | ||||||||||||||||||||||||||||
| 47 | ( $ENV{PAGSEGURO_API_SANDBOX} ? 'SANDBOX_URI' : 'BASE_URI' ) | ||||||||||||||||||||||||||||
| 48 | ), | ||||||||||||||||||||||||||||
| 49 | $self->resource('TRANSACTION'), | ||||||||||||||||||||||||||||
| 50 | $self->resource('NOTIFICATIONS'), | ||||||||||||||||||||||||||||
| 51 | "${code}", | ||||||||||||||||||||||||||||
| 52 | "?email=" . $self->{email}, | ||||||||||||||||||||||||||||
| 53 | "&token=" . $self->{token}, | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | warn "[Debug] URI: $uri\n" if $ENV{PAGSEGURO_API_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | return $uri; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 6 | 1; | |||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||