File Coverage

lib/WebService/Braintree/AddressGateway.pm
Criterion Covered Total %
statement 20 32 62.5
branch 0 6 0.0
condition 0 3 0.0
subroutine 7 11 63.6
pod 0 4 0.0
total 27 56 48.2


line stmt bran cond sub pod time code
1             package WebService::Braintree::AddressGateway;
2             $WebService::Braintree::AddressGateway::VERSION = '0.94';
3 20     20   283 use 5.010_001;
  20         61  
4 20     20   93 use strictures 1;
  20         101  
  20         614  
5              
6 20     20   1607 use Moose;
  20         40  
  20         111  
7             with 'WebService::Braintree::Role::MakeRequest';
8              
9 20     20   120573 use Carp qw(confess);
  20         58  
  20         1191  
10 20     20   5954 use WebService::Braintree::Validations qw(verify_params address_signature);
  20         48  
  20         1217  
11 20     20   130 use WebService::Braintree::Util qw(validate_id);
  20         39  
  20         703  
12 20     20   4865 use WebService::Braintree::Result;
  20         68  
  20         5763  
13              
14             has 'gateway' => (is => 'ro');
15              
16             sub create {
17 0     0 0   my($self, $params) = @_;
18 0           my $customer_id = delete($params->{'customer_id'});
19 0 0         confess "ArgumentError" unless verify_params($params, address_signature());
20 0           $self->_make_request("/customers/$customer_id/addresses", "post", {address => $params});
21             }
22              
23             sub find {
24 0     0 0   my ($self, $customer_id, $address_id) = @_;
25 0 0 0       confess "NotFoundError" unless (validate_id($address_id) && validate_id($customer_id));
26 0           $self->_make_request("/customers/$customer_id/addresses/$address_id", "get")->address;
27             }
28              
29             sub update {
30 0     0 0   my ($self, $customer_id, $address_id, $params) = @_;
31 0 0         confess "ArgumentError" unless verify_params($params, address_signature());
32 0           $self->_make_request("/customers/$customer_id/addresses/$address_id", "put", {address => $params});
33             }
34              
35             sub delete {
36 0     0 0   my ($self, $customer_id, $address_id) = @_;
37 0           $self->_make_request("/customers/$customer_id/addresses/$address_id", "delete");
38             }
39              
40             __PACKAGE__->meta->make_immutable;
41              
42             1;
43             __END__