| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||||
| 2 | |||||||||||||
| 3 | package WebService::Braintree::Customer; | ||||||||||||
| 4 | 22 | $WebService::Braintree::Customer::VERSION = '1.7'; | |||||||||||
| 5 | 22 | ▶ | use 5.010_001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 22 | ▶ | use strictures 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | =head1 NAME | ||||||||||||
| 9 | |||||||||||||
| 10 | WebService::Braintree::Customer | ||||||||||||
| 11 | |||||||||||||
| 12 | =head1 PURPOSE | ||||||||||||
| 13 | |||||||||||||
| 14 | This class creates, updates, deletes, and finds customers. | ||||||||||||
| 15 | |||||||||||||
| 16 | =cut | ||||||||||||
| 17 | |||||||||||||
| 18 | 22 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | |||||||||||||
| 20 | 22 | with 'WebService::Braintree::Role::Interface'; | |||||||||||
| 21 | |||||||||||||
| 22 | =head2 create() | ||||||||||||
| 23 | |||||||||||||
| 24 | This takes a hashref of parameters and returns a L<response|WebService::Braintee::Result> with the C<< customer() >> set. | ||||||||||||
| 25 | |||||||||||||
| 26 | =cut | ||||||||||||
| 27 | |||||||||||||
| 28 | 1 | ▶ | sub create { | ||||||||||
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 29 | 1 | my ($class, $params) = @_; | |||||||||||
| 30 | 1 | $class->gateway->customer->create($params); | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | =head2 find() | ||||||||||||
| 34 | |||||||||||||
| 35 | This takes a token and returns a L<response|WebService::Braintee::Result> with | ||||||||||||
| 36 | the C<< customer() >> set (if found). | ||||||||||||
| 37 | |||||||||||||
| 38 | =cut | ||||||||||||
| 39 | |||||||||||||
| 40 | 2 | ▶ | sub find { | ||||||||||
|
Subroutine
find: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 41 | 2 | my($class, $id) = @_; | |||||||||||
| 42 | 2 | $class->gateway->customer->find($id); | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | =head2 update() | ||||||||||||
| 46 | |||||||||||||
| 47 | This takes a customer_id and a hashref of parameters. It will update the corresponding | ||||||||||||
| 48 | credit card (if found) and return a L<response|WebService::Braintee::Result> | ||||||||||||
| 49 | with the C<< customer() >> set. | ||||||||||||
| 50 | |||||||||||||
| 51 | =cut | ||||||||||||
| 52 | |||||||||||||
| 53 | 0 | ▶ | sub update { | ||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 54 | 0 | my ($class, $id, $params) = @_; | |||||||||||
| 55 | 0 | $class->gateway->customer->update($id, $params); | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | =head2 delete() | ||||||||||||
| 59 | |||||||||||||
| 60 | This takes a customer_id. It will delete the corresponding customer (if found) | ||||||||||||
| 61 | and return a L<response|WebService::Braintee::Result> with the C<< customer() >> | ||||||||||||
| 62 | set. | ||||||||||||
| 63 | |||||||||||||
| 64 | =cut | ||||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | sub delete { | ||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 67 | 0 | my ($class, $id) = @_; | |||||||||||
| 68 | 0 | $class->gateway->customer->delete($id); | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | =head2 search() | ||||||||||||
| 72 | |||||||||||||
| 73 | This takes a subref which is used to set the search parameters and returns a | ||||||||||||
| 74 | L<collection|WebService::Braintree::ResourceCollection> of the matching | ||||||||||||
| 75 | L<customers|WebService::Braintree::_::Customer>. | ||||||||||||
| 76 | |||||||||||||
| 77 | Please see L<Searching|WebService::Braintree/SEARCHING> for more information on | ||||||||||||
| 78 | the subref and how it works. | ||||||||||||
| 79 | |||||||||||||
| 80 | Please see L<WebService::Braintree::CustomerSearch> for more | ||||||||||||
| 81 | information on what specfic fields you can set for this method. | ||||||||||||
| 82 | |||||||||||||
| 83 | =cut | ||||||||||||
| 84 | |||||||||||||
| 85 | 0 | ▶ | sub search { | ||||||||||
|
Subroutine
search: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 86 | 0 | my ($class, $block) = @_; | |||||||||||
| 87 | 0 | $class->gateway->customer->search($block); | |||||||||||
| 88 | } | ||||||||||||
| 89 | |||||||||||||
| 90 | =head2 all() | ||||||||||||
| 91 | |||||||||||||
| 92 | This returns a L<collection|WebService::Braintree::ResourceCollection> of all | ||||||||||||
| 93 | L<customers|WebService::Braintree::_::Customer>. | ||||||||||||
| 94 | |||||||||||||
| 95 | =cut | ||||||||||||
| 96 | |||||||||||||
| 97 | 0 | ▶ | sub all { | ||||||||||
|
Subroutine
all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 98 | 0 | my ($class) = @_; | |||||||||||
| 99 | 0 | $class->gateway->customer->all; | |||||||||||
| 100 | } | ||||||||||||
| 101 | |||||||||||||
| 102 | =head2 transactions() | ||||||||||||
| 103 | |||||||||||||
| 104 | This takes a customer_id. It returns a L<collection|WebService::Braintree::ResourceCollection> of all L<customers|WebService::Braintree::_::Transaction> for | ||||||||||||
| 105 | that customer. | ||||||||||||
| 106 | |||||||||||||
| 107 | =cut | ||||||||||||
| 108 | |||||||||||||
| 109 | 0 | ▶ | sub transactions { | ||||||||||
|
Subroutine
transactions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 110 | 0 | my ($class, $id) = @_; | |||||||||||
| 111 | 0 | $class->gateway->customer->transactions($id); | |||||||||||
| 112 | } | ||||||||||||
| 113 | |||||||||||||
| 114 | =head2 credit() | ||||||||||||
| 115 | |||||||||||||
| 116 | This takes a customer_id and an optional hashref of parameters. This delegates | ||||||||||||
| 117 | to L<WebService::Braintree::Transaction/credit>, setting the C<< customer_id >> | ||||||||||||
| 118 | appropriately. | ||||||||||||
| 119 | |||||||||||||
| 120 | =cut | ||||||||||||
| 121 | |||||||||||||
| 122 | 0 | ▶ | sub credit { | ||||||||||
|
Subroutine
credit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 123 | 0 | my ($class, $id, $params) = @_; | |||||||||||
| 124 | $class->gateway->transaction->credit({ | ||||||||||||
| 125 | 0 | ▶ | %{$params // {}}, | ||||||||||
|
Condition0%0/2
$params // {}
MC/DC0%0/1
$params // {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||
| 126 | customer_id => $id, | ||||||||||||
| 127 | }); | ||||||||||||
| 128 | } | ||||||||||||
| 129 | |||||||||||||
| 130 | =head2 sale() | ||||||||||||
| 131 | |||||||||||||
| 132 | This takes a customer_id and an optional hashref of parameters. This delegates | ||||||||||||
| 133 | to L<WebService::Braintree::Transaction/sale>, setting the C<< customer_id >> | ||||||||||||
| 134 | appropriately. | ||||||||||||
| 135 | |||||||||||||
| 136 | =cut | ||||||||||||
| 137 | |||||||||||||
| 138 | 0 | ▶ | sub sale { | ||||||||||
|
Subroutine
sale: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 139 | 0 | my ($class, $id, $params) = @_; | |||||||||||
| 140 | $class->gateway->transaction->sale({ | ||||||||||||
| 141 | 0 | ▶ | %{$params // {}}, | ||||||||||
|
Condition0%0/2
$params // {}
MC/DC0%0/1
$params // {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||
| 142 | customer_id => $id, | ||||||||||||
| 143 | }); | ||||||||||||
| 144 | } | ||||||||||||
| 145 | |||||||||||||
| 146 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 147 | |||||||||||||
| 148 | 22 | 1; | |||||||||||
| 149 | __END__ | ||||||||||||