File Coverage

lib/WebService/Braintree/Address.pm
Criterion Covered Total %
statement 8 21 38.1
branch n/a
condition n/a
subroutine 3 10 30.0
pod 5 7 71.4
total 16 38 42.1


line stmt bran cond sub pod time code
1             package WebService::Braintree::Address;
2             $WebService::Braintree::Address::VERSION = '0.94';
3 20     20   276 use 5.010_001;
  20         57  
4 20     20   88 use strictures 1;
  20         98  
  20         615  
5              
6             =head1 NAME
7              
8             WebService::Braintree::Address
9              
10             =head1 PURPOSE
11              
12             This class creates, updates, deletes, and finds addresses.
13              
14             =cut
15              
16 20     20   7554 use Moose;
  20         6928428  
  20         117  
17             extends 'WebService::Braintree::ResultObject';
18              
19             =head1 CLASS METHODS
20              
21             =head2 create()
22              
23             This takes a hashref of parameters and returns the address created.
24              
25             =cut
26              
27             sub create {
28 0     0 1   my($class, $params) = @_;
29 0           $class->gateway->address->create($params);
30             }
31              
32             =head2 find()
33              
34             This takes a customer_id and an address_id and returns the address (if it
35             exists).
36              
37             =cut
38              
39             sub find {
40 0     0 1   my ($class, $customer_id, $address_id) = @_;
41 0           $class->gateway->address->find($customer_id, $address_id);
42             }
43              
44             =head2 update()
45              
46             This takes a customer_id, an address_id, and a hashref of parameters. It will
47             update the corresponding address (if found) and returns the updated address.
48              
49             =cut
50              
51             sub update {
52 0     0 1   my ($class, $customer_id, $address_id, $params) = @_;
53 0           $class->gateway->address->update($customer_id, $address_id, $params);
54             }
55              
56             =head2 delete()
57              
58             This takes a customer_id and an address_id and deletes the corresponding
59             address (if found).
60              
61             =cut
62              
63             sub delete {
64 0     0 1   my ($class, $customer_id, $address_id) = @_;
65 0           $class->gateway->address->delete($customer_id, $address_id);
66             }
67              
68             sub gateway {
69 0     0 0   return WebService::Braintree->configuration->gateway;
70             }
71              
72             sub BUILD {
73 0     0 0   my ($self, $attributes) = @_;
74 0           $self->set_attributes_from_hash($self, $attributes);
75             }
76              
77             =head1 OBJECT METHODS
78              
79             In addition to the methods provided by the keys returned from Braintree, this
80             class provides the following methods:
81              
82             =head2 full_name()
83              
84             This returns the full name of this address. This is the first_name and the
85             last_name concatenated with a space.
86              
87             =cut
88              
89             sub full_name {
90 0     0 1   my $self = shift;
91 0           return $self->first_name . " " . $self->last_name
92             }
93              
94             __PACKAGE__->meta->make_immutable;
95              
96             1;
97             __END__
98              
99             =head1 TODO
100              
101             =over 4
102              
103             =item Need to document the keys and values that are returned
104              
105             =item Need to document the required and optional input parameters
106              
107             =item Need to document the possible errors/exceptions
108              
109             =back
110              
111             =cut