line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Braintree::Result; |
2
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
6431
|
use Hash::Inflator; |
|
1
|
|
|
|
|
379
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
9
|
use Net::Braintree::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
119
|
|
5
|
1
|
|
|
1
|
|
337
|
use Net::Braintree::ValidationErrorCollection; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
724
|
use Net::Braintree::CreditCardVerification; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
591
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $meta = __PACKAGE__->meta; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
has response => ( is => 'ro' ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _get_response { |
29
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
30
|
0
|
|
0
|
|
|
0
|
return $self->response->{'api_error_response'} || $self->response; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub patch_in_response_accessors { |
34
|
2
|
|
|
2
|
0
|
3
|
my $field_rules = shift; |
35
|
2
|
|
|
|
|
12
|
while (my($key, $rule) = each(%$field_rules)) { |
36
|
12
|
100
|
|
|
|
319
|
if (ref($rule) eq "HASH") { |
37
|
|
|
|
|
|
|
$meta->add_method($key, sub { |
38
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
39
|
0
|
|
|
|
|
0
|
my $response = $self->_get_response(); |
40
|
0
|
|
|
|
|
0
|
while (my($subkey, $subrule) = each(%$rule)) { |
41
|
0
|
|
|
|
|
0
|
my $field_value = $self->$subkey; |
42
|
0
|
0
|
|
|
|
0
|
if ($field_value) { |
43
|
0
|
|
|
|
|
0
|
keys %$rule; |
44
|
0
|
|
|
|
|
0
|
return $field_value; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
return undef; |
49
|
1
|
|
|
|
|
6
|
}); |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
27
|
patch_in_response_accessors($rule); |
52
|
|
|
|
|
|
|
} else { |
53
|
|
|
|
|
|
|
$meta->add_method($key, sub { |
54
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
55
|
0
|
|
|
|
|
|
my $response = $self->_get_response(); |
56
|
0
|
0
|
|
|
|
|
if (!$response->{$key}) { |
57
|
0
|
|
|
|
|
|
return undef; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $rule->new($response->{$key}); |
61
|
11
|
|
|
|
|
41
|
}); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
patch_in_response_accessors($response_objects); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub is_success { |
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
70
|
0
|
0
|
|
|
|
|
return 1 unless $self->response->{'api_error_response'}; |
71
|
0
|
|
|
|
|
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub api_error_response { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
return $self->response->{'api_error_response'}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub message { |
80
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
81
|
0
|
0
|
|
|
|
|
return $self->api_error_response->{'message'} if $self->api_error_response; |
82
|
0
|
|
|
|
|
|
return ""; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub errors { |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
return Net::Braintree::ValidationErrorCollection->new($self->api_error_response->{errors}); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub credit_card_verification { |
91
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
92
|
0
|
|
|
|
|
|
return Net::Braintree::CreditCardVerification->new($self->api_error_response->{verification}); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |