File Coverage

blib/lib/WebService/Braintree/MerchantAccount.pm
Criterion Covered Total %
statement 33 50 66.0
branch 0 8 0.0
condition n/a
subroutine 11 16 68.7
pod 3 5 60.0
total 47 79 59.4


line stmt bran cond sub pod time code
1             package WebService::Braintree::MerchantAccount;
2             $WebService::Braintree::MerchantAccount::VERSION = '0.92';
3             =head1 NAME
4              
5             WebService::Braintree::Customer
6              
7             =head1 PURPOSE
8              
9             This class creates, updates, deletes, and finds merchant accounts.
10              
11             =cut
12              
13 1     1   241 use WebService::Braintree::MerchantAccount::IndividualDetails;
  1         3  
  1         29  
14 1     1   7 use WebService::Braintree::MerchantAccount::AddressDetails;
  1         1  
  1         16  
15 1     1   344 use WebService::Braintree::MerchantAccount::BusinessDetails;
  1         2  
  1         28  
16 1     1   315 use WebService::Braintree::MerchantAccount::FundingDetails;
  1         3  
  1         27  
17              
18 1     1   7 use Moose;
  1         2  
  1         3  
19             extends "WebService::Braintree::ResultObject";
20              
21             =head2 create()
22              
23             This takes a hashref of parameters and returns the merchant account created.
24              
25             =cut
26              
27             sub create {
28 0     0 1   my ($class, $params) = @_;
29 0           $class->gateway->merchant_account->create($params);
30             }
31              
32             =head2 find()
33              
34             This takes a merchant_account_id returns the merchant account (if it exists).
35              
36             =cut
37              
38             sub find {
39 0     0 1   my ($class, $merchant_account_id) = @_;
40 0           $class->gateway->merchant_account->find($merchant_account_id);
41             }
42              
43             =head2 update()
44              
45             This takes a merchant_account_id and a hashref of parameters. It will update the
46             corresponding merchant account (if found) and returns the updated merchant
47             account.
48              
49             =cut
50              
51             sub update {
52 0     0 1   my ($class, $merchant_account_id, $params) = @_;
53 0           $class->gateway->merchant_account->update($merchant_account_id, $params);
54             }
55              
56             sub gateway {
57 0     0 0   return WebService::Braintree->configuration->gateway;
58             }
59              
60             {
61             package WebService::Braintree::MerchantAccount::Status;
62             $WebService::Braintree::MerchantAccount::Status::VERSION = '0.92';
63 1     1   5231 use constant Active => "active";
  1         2  
  1         61  
64 1     1   5 use constant Pending => "pending";
  1         3  
  1         34  
65 1     1   5 use constant Suspended => "suspended";
  1         1  
  1         55  
66             }
67              
68             {
69             package WebService::Braintree::MerchantAccount::FundingDestination;
70             $WebService::Braintree::MerchantAccount::FundingDestination::VERSION = '0.92';
71 1     1   5 use constant Bank => "bank";
  1         2  
  1         37  
72 1     1   5 use constant Email => "email";
  1         2  
  1         32  
73 1     1   5 use constant MobilePhone => "mobile_phone";
  1         2  
  1         224  
74             }
75              
76             =head1 OBJECT METHODS
77              
78             In addition to the methods provided by the keys returned from Braintree, this
79             class provides the following methods:
80              
81             =head2 master_merchant_account()
82              
83             This returns the master merchant account (if it exists). It will be a
84             L<WebService::Braintree::MerchantAccount> object.
85              
86             =cut
87              
88             has master_merchant_account => (is => 'rw');
89              
90             =head2 individual_details()
91              
92             This returns the individual details of this merchant account (if they exist). It
93             will be a L<WebService::Braintree::MerchantAccount::IndividualDetails> object.
94              
95             =cut
96              
97             has individual_details => (is => 'rw');
98              
99             =head2 business_details()
100              
101             This returns the business details of this merchant account (if they exist). It
102             will be a L<WebService::Braintree::MerchantAccount::BusinessDetails> object.
103              
104             =cut
105              
106             has business_details => (is => 'rw');
107              
108             =head2 funding_details()
109              
110             This returns the funding details of this merchant account (if they exist). It
111             will be a L<WebService::Braintree::MerchantAccount::FundingDetails> object.
112              
113             =cut
114              
115             has funding_details => (is => 'rw');
116              
117             sub BUILD {
118 0     0 0   my ($self, $attributes) = @_;
119              
120 0 0         $self->master_merchant_account(WebService::Braintree::MerchantAccount->new($attributes->{master_merchant_account})) if ref($attributes->{master_merchant_account}) eq 'HASH';
121 0           delete($attributes->{master_merchant_account});
122              
123              
124 0 0         $self->individual_details(WebService::Braintree::MerchantAccount::IndividualDetails->new($attributes->{individual})) if ref($attributes->{individual}) eq 'HASH';
125 0           delete($attributes->{individual});
126              
127              
128 0 0         $self->business_details(WebService::Braintree::MerchantAccount::BusinessDetails->new($attributes->{business})) if ref($attributes->{business}) eq 'HASH';
129 0           delete($attributes->{business});
130              
131              
132 0 0         $self->funding_details(WebService::Braintree::MerchantAccount::FundingDetails->new($attributes->{funding})) if ref($attributes->{funding}) eq 'HASH';
133 0           delete($attributes->{funding});
134              
135 0           $self->set_attributes_from_hash($self, $attributes);
136             }
137              
138             __PACKAGE__->meta->make_immutable;
139              
140             1;
141             __END__
142              
143             =head1 TODO
144              
145             =over 4
146              
147             =item Need to document the keys and values that are returned
148              
149             =item Need to document the required and optional input parameters
150              
151             =item Need to document the possible errors/exceptions
152              
153             =back
154              
155             =cut