line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::Result; |
2
|
|
|
|
|
|
|
$WebService::Braintree::Result::VERSION = '0.94'; |
3
|
20
|
|
|
20
|
|
340
|
use 5.010_001; |
|
20
|
|
|
|
|
63
|
|
4
|
20
|
|
|
20
|
|
146
|
use strictures 1; |
|
20
|
|
|
|
|
121
|
|
|
20
|
|
|
|
|
692
|
|
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
1651
|
use Moose; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
146
|
|
7
|
20
|
|
|
20
|
|
124992
|
use Hash::Inflator; |
|
20
|
|
|
|
|
7491
|
|
|
20
|
|
|
|
|
600
|
|
8
|
|
|
|
|
|
|
|
9
|
20
|
|
|
20
|
|
120
|
use WebService::Braintree::Util qw(is_hashref); |
|
20
|
|
|
|
|
41
|
|
|
20
|
|
|
|
|
973
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# XXX: Why only these classes? |
12
|
20
|
|
|
20
|
|
4996
|
use WebService::Braintree::ValidationErrorCollection; |
|
20
|
|
|
|
|
60
|
|
|
20
|
|
|
|
|
689
|
|
13
|
20
|
|
|
20
|
|
6775
|
use WebService::Braintree::CreditCardVerification; |
|
20
|
|
|
|
|
59
|
|
|
20
|
|
|
|
|
769
|
|
14
|
20
|
|
|
20
|
|
6726
|
use WebService::Braintree::Nonce; |
|
20
|
|
|
|
|
58
|
|
|
20
|
|
|
|
|
10039
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $meta = __PACKAGE__->meta; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $response_objects = { |
19
|
|
|
|
|
|
|
address => "WebService::Braintree::Address", |
20
|
|
|
|
|
|
|
apple_pay => "WebService::Braintree::ApplePayCard", |
21
|
|
|
|
|
|
|
apple_pay_card => "WebService::Braintree::ApplePayCard", |
22
|
|
|
|
|
|
|
credit_card => "WebService::Braintree::CreditCard", |
23
|
|
|
|
|
|
|
customer => "WebService::Braintree::Customer", |
24
|
|
|
|
|
|
|
merchant_account => "WebService::Braintree::MerchantAccount", |
25
|
|
|
|
|
|
|
payment_method => { |
26
|
|
|
|
|
|
|
credit_card => "WebService::Braintree::CreditCard", |
27
|
|
|
|
|
|
|
paypal_account => "WebService::Braintree::PayPalAccount" |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
payment_method_nonce => 'WebService::Braintree::Nonce', |
30
|
|
|
|
|
|
|
settlement_batch_summary => "WebService::Braintree::SettlementBatchSummary", |
31
|
|
|
|
|
|
|
subscription => "WebService::Braintree::Subscription", |
32
|
|
|
|
|
|
|
transaction => "WebService::Braintree::Transaction", |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has response => ( is => 'ro' ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _get_response { |
38
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
39
|
0
|
|
0
|
|
|
0
|
return $self->response->{'api_error_response'} || $self->response; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub patch_in_response_accessors { |
43
|
40
|
|
|
40
|
0
|
73
|
my $field_rules = shift; |
44
|
40
|
|
|
|
|
211
|
while (my($key, $rule) = each(%$field_rules)) { |
45
|
260
|
100
|
|
|
|
8542
|
if (is_hashref($rule)) { |
46
|
|
|
|
|
|
|
$meta->add_method($key, sub { |
47
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $response = $self->_get_response(); |
49
|
0
|
|
|
|
|
0
|
while (my($subkey, $subrule) = each(%$rule)) { |
50
|
0
|
|
|
|
|
0
|
my $field_value = $self->$subkey; |
51
|
0
|
0
|
|
|
|
0
|
if ($field_value) { |
52
|
0
|
|
|
|
|
0
|
keys %$rule; |
53
|
0
|
|
|
|
|
0
|
return $field_value; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
return undef; |
58
|
20
|
|
|
|
|
125
|
}); |
59
|
|
|
|
|
|
|
|
60
|
20
|
|
|
|
|
782
|
patch_in_response_accessors($rule); |
61
|
|
|
|
|
|
|
} else { |
62
|
|
|
|
|
|
|
$meta->add_method($key, sub { |
63
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
64
|
0
|
|
|
|
|
|
my $response = $self->_get_response(); |
65
|
0
|
0
|
|
|
|
|
if (!$response->{$key}) { |
66
|
0
|
|
|
|
|
|
return undef; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $rule->new($response->{$key}); |
70
|
240
|
|
|
|
|
985
|
}); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
patch_in_response_accessors($response_objects); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub is_success { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
return if $self->response->{'api_error_response'}; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub api_error_response { |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
return $self->response->{'api_error_response'}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub message { |
91
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
92
|
0
|
0
|
|
|
|
|
return $self->api_error_response->{'message'} if $self->api_error_response; |
93
|
0
|
|
|
|
|
|
return ""; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub errors { |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
return WebService::Braintree::ValidationErrorCollection->new($self->api_error_response->{errors}); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub credit_card_verification { |
102
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
103
|
0
|
|
|
|
|
|
return WebService::Braintree::CreditCardVerification->new($self->api_error_response->{verification}); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
__END__ |