File Coverage

blib/lib/Net/Braintree/WebhookNotification.pm
Criterion Covered Total %
statement 6 40 15.0
branch 0 16 0.0
condition n/a
subroutine 2 6 33.3
pod 0 4 0.0
total 8 66 12.1


line stmt bran cond sub pod time code
1             package Net::Braintree::WebhookNotification;
2              
3 1     1   359 use Net::Braintree::WebhookNotification::Kind;
  1         2  
  1         256  
4 1     1   8 use Moose;
  1         1  
  1         6  
5              
6             extends 'Net::Braintree::ResultObject';
7              
8             my $meta = __PACKAGE__->meta;
9              
10             sub BUILD {
11 0     0 0   my ($self, $attributes) = @_;
12              
13 0           my $wrapper_node = $attributes->{subject};
14              
15 0 0         if (ref($wrapper_node->{api_error_response}) eq 'HASH') {
16 0           $wrapper_node = $wrapper_node->{api_error_response};
17             }
18              
19 0 0         if (ref($wrapper_node->{subscription}) eq 'HASH') {
20 0           $meta->add_attribute('subscription', is => 'rw');
21 0           $self->subscription(Net::Braintree::Subscription->new($wrapper_node->{subscription}));
22             }
23              
24 0 0         if (ref($wrapper_node->{merchant_account}) eq 'HASH') {
25 0           $meta->add_attribute('merchant_account', is => 'rw');
26 0           $self->merchant_account(Net::Braintree::MerchantAccount->new($wrapper_node->{merchant_account}));
27             }
28              
29 0 0         if (ref($wrapper_node->{disbursement}) eq 'HASH') {
30 0           $meta->add_attribute('disbursement', is => 'rw');
31 0           $self->disbursement(Net::Braintree::Disbursement->new($wrapper_node->{disbursement}));
32             }
33              
34 0 0         if (ref($wrapper_node->{transaction}) eq 'HASH') {
35 0           $meta->add_attribute('transaction', is => 'rw');
36 0           $self->transaction(Net::Braintree::Transaction->new($wrapper_node->{transaction}));
37             }
38              
39 0 0         if (ref($wrapper_node->{partner_merchant}) eq 'HASH') {
40 0           $meta->add_attribute('partner_merchant', is => 'rw');
41 0           $self->partner_merchant(Net::Braintree::PartnerMerchant->new($wrapper_node->{partner_merchant}));
42             }
43              
44 0 0         if (ref($wrapper_node->{dispute}) eq 'HASH') {
45 0           $meta->add_attribute('dispute', is => 'rw');
46 0           $self->dispute(Net::Braintree::Dispute->new($wrapper_node->{dispute}));
47             }
48              
49 0 0         if (ref($wrapper_node->{errors}) eq 'HASH') {
50 0           $meta->add_attribute('errors', is => 'rw');
51 0           $meta->add_attribute('message', is => 'rw');
52 0           $self->errors(Net::Braintree::ValidationErrorCollection->new($wrapper_node->{errors}));
53 0           $self->message($wrapper_node->{message});
54             }
55              
56 0           delete($attributes->{subject});
57 0           $self->set_attributes_from_hash($self, $attributes);
58             }
59              
60             sub parse {
61 0     0 0   my ($class, $signature, $payload) = @_;
62 0           $class->gateway->webhook_notification->parse($signature, $payload);
63             }
64              
65             sub verify {
66 0     0 0   my ($class, $params) = @_;
67 0           $class->gateway->webhook_notification->verify($params);
68             }
69              
70             sub gateway {
71 0     0 0   return Net::Braintree->configuration->gateway;
72             }
73              
74             1;