File Coverage

blib/lib/WebService/Braintree/AddressGateway.pm
Criterion Covered Total %
statement 15 27 55.5
branch 0 6 0.0
condition 0 3 0.0
subroutine 5 9 55.5
pod 0 4 0.0
total 20 49 40.8


line stmt bran cond sub pod time code
1             package WebService::Braintree::AddressGateway;
2             $WebService::Braintree::AddressGateway::VERSION = '0.93';
3 1     1   9 use Moose;
  1         3  
  1         12  
4             with 'WebService::Braintree::Role::MakeRequest';
5              
6 1     1   10677 use Carp qw(confess);
  1         4  
  1         103  
7 1     1   635 use WebService::Braintree::Validations qw(verify_params address_signature);
  1         4  
  1         84  
8 1     1   10 use WebService::Braintree::Util qw(validate_id);
  1         4  
  1         61  
9 1     1   409 use WebService::Braintree::Result;
  1         5  
  1         418  
10              
11             has 'gateway' => (is => 'ro');
12              
13             sub create {
14 0     0 0   my($self, $params) = @_;
15 0           my $customer_id = delete($params->{'customer_id'});
16 0 0         confess "ArgumentError" unless verify_params($params, address_signature());
17 0           $self->_make_request("/customers/$customer_id/addresses", "post", {address => $params});
18             }
19              
20             sub find {
21 0     0 0   my ($self, $customer_id, $address_id) = @_;
22 0 0 0       confess "NotFoundError" unless (validate_id($address_id) && validate_id($customer_id));
23 0           $self->_make_request("/customers/$customer_id/addresses/$address_id", "get")->address;
24             }
25              
26             sub update {
27 0     0 0   my ($self, $customer_id, $address_id, $params) = @_;
28 0 0         confess "ArgumentError" unless verify_params($params, address_signature());
29 0           $self->_make_request("/customers/$customer_id/addresses/$address_id", "put", {address => $params});
30             }
31              
32             sub delete {
33 0     0 0   my ($self, $customer_id, $address_id) = @_;
34 0           $self->_make_request("/customers/$customer_id/addresses/$address_id", "delete");
35             }
36              
37             __PACKAGE__->meta->make_immutable;
38             1;
39