| 1 | package Net::Braintree::Result; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Hash::Inflator; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use Net::Braintree::Util; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use Net::Braintree::ValidationErrorCollection; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Net::Braintree::CreditCardVerification; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | my $meta = __PACKAGE__->meta; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | my $response_objects = { | |||||||||||||||||||
| 11 | address => "Net::Braintree::Address", | ||||||||||||||||||||
| 12 | apple_pay => "Net::Braintree::ApplePayCard", | ||||||||||||||||||||
| 13 | apple_pay_card => "Net::Braintree::ApplePayCard", | ||||||||||||||||||||
| 14 | credit_card => "Net::Braintree::CreditCard", | ||||||||||||||||||||
| 15 | customer => "Net::Braintree::Customer", | ||||||||||||||||||||
| 16 | merchant_account => "Net::Braintree::MerchantAccount", | ||||||||||||||||||||
| 17 | payment_method => { | ||||||||||||||||||||
| 18 | credit_card => "Net::Braintree::CreditCard", | ||||||||||||||||||||
| 19 | paypal_account => "Net::Braintree::PayPalAccount" | ||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||
| 21 | settlement_batch_summary => "Net::Braintree::SettlementBatchSummary", | ||||||||||||||||||||
| 22 | subscription => "Net::Braintree::Subscription", | ||||||||||||||||||||
| 23 | transaction => "Net::Braintree::Transaction", | ||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 1 | has response => ( is => 'ro' ); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub _get_response { | ||||||||||||||||||
|
Subroutine
_get_response: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||
| 30 | 0 | ▶ | return $self->response->{'api_error_response'} || $self->response; | ||||||||||||||||||
|
Condition0%0/3
$self->response->{'api_error_response'} || $self->response
MC/DC0%0/2
$self->response->{'api_error_response'} || $self->response
$self->response->{'api_error_response'}
$self->response
Truth table0%0/3
A || B
A= $self->response->{'api_error_response'}B= $self->response
| |||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 2 | ▶ | sub patch_in_response_accessors { | ||||||||||||||||||
|
Subroutine
patch_in_response_accessors: called CC=3 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||
| 34 | 2 | my $field_rules = shift; | |||||||||||||||||||
| 35 | 2 | ▶ | while (my($key, $rule) = each(%$field_rules)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 12 | ▶ | if (ref($rule) eq "HASH") { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 0 | ▶ | $meta->add_method($key, sub { | ||||||||||||||||||
|
Subroutine
payment_method: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||||||||
| 39 | 0 | my $response = $self->_get_response(); | |||||||||||||||||||
| 40 | 0 | ▶ | while (my($subkey, $subrule) = each(%$rule)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | my $field_value = $self->$subkey; | |||||||||||||||||||
| 42 | 0 | ▶ | if ($field_value) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | 0 | keys %$rule; | |||||||||||||||||||
| 44 | 0 | return $field_value; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | return undef; | |||||||||||||||||||
| 49 | 1 | }); | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 1 | patch_in_response_accessors($rule); | |||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||
| 53 | 0 | ▶ | $meta->add_method($key, sub { | ||||||||||||||||||
|
Subroutine
customer: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||||||||
| 55 | 0 | my $response = $self->_get_response(); | |||||||||||||||||||
| 56 | 0 | ▶ | if (!$response->{$key}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | return undef; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | return $rule->new($response->{$key}); | |||||||||||||||||||
| 61 | 11 | }); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 1 | patch_in_response_accessors($response_objects); | |||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | ▶ | sub is_success { | ||||||||||||||||||
|
Subroutine
is_success: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||
| 70 | 0 | ▶ | return 1 unless $self->response->{'api_error_response'}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 0 | return 0; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | ▶ | sub api_error_response { | ||||||||||||||||||
|
Subroutine
api_error_response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||
| 76 | 0 | return $self->response->{'api_error_response'}; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | ▶ | sub message { | ||||||||||||||||||
|
Subroutine
message: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||
| 81 | 0 | ▶ | return $self->api_error_response->{'message'} if $self->api_error_response; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | 0 | return ""; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | ▶ | sub errors { | ||||||||||||||||||
|
Subroutine
errors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||
| 87 | 0 | return Net::Braintree::ValidationErrorCollection->new($self->api_error_response->{errors}); | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 0 | ▶ | sub credit_card_verification { | ||||||||||||||||||
|
Subroutine
credit_card_verification: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||
| 92 | 0 | return Net::Braintree::CreditCardVerification->new($self->api_error_response->{verification}); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 1 | 1; | |||||||||||||||||||