| 1 | # vim: sw=4 ts=4 ft=perl | ||
| 2 | |||
| 3 | package WebService::Braintree::Subscription; | ||
| 4 | 22 | $WebService::Braintree::Subscription::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::Subscription | ||
| 11 | |||
| 12 | =head1 PURPOSE | ||
| 13 | |||
| 14 | This class creates, finds, updates, cancels, retries charges on, searches for, | ||
| 15 | and lists all subscriptions. | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | 22 | ▶ | use WebService::Braintree::SubscriptionGateway; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 22 | ▶ | use WebService::Braintree::Subscription::Status; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | 22 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | 22 | with 'WebService::Braintree::Role::Interface'; | |
| 25 | |||
| 26 | =head1 CLASS METHODS | ||
| 27 | |||
| 28 | =head2 create() | ||
| 29 | |||
| 30 | This takes a hashref of parameters and returns the subscription created. | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | 0 | ▶ | sub create { |
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 35 | 0 | my ($class, $params) = @_; | |
| 36 | 0 | $class->gateway->subscription->create($params); | |
| 37 | } | ||
| 38 | |||
| 39 | =head2 find() | ||
| 40 | |||
| 41 | This takes a subscription_id and returns the subscription (if it exists). | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | 2 | ▶ | sub find { |
|
Subroutine
find: called CC=1 SCAR=0.0
Pod
documented
| |||
| 46 | 2 | my ($class, $id) = @_; | |
| 47 | 2 | $class->gateway->subscription->find($id); | |
| 48 | } | ||
| 49 | |||
| 50 | =head2 update() | ||
| 51 | |||
| 52 | This takes a subcsription_id and a hashref of parameters. It will update the | ||
| 53 | corresponding subscription (if found) and returns the updated subscription. | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 0 | ▶ | sub update { |
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 58 | 0 | my ($class, $id, $params) = @_; | |
| 59 | 0 | $class->gateway->subscription->update($id, $params); | |
| 60 | } | ||
| 61 | |||
| 62 | =head2 cancel() | ||
| 63 | |||
| 64 | This takes a subscription_id and cancels (aka, deletes) the corresponding | ||
| 65 | subscription (if found). | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | 0 | ▶ | sub cancel { |
|
Subroutine
cancel: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 70 | 0 | my ($class, $id) = @_; | |
| 71 | 0 | $class->gateway->subscription->cancel($id); | |
| 72 | } | ||
| 73 | |||
| 74 | =head2 retry_charge() | ||
| 75 | |||
| 76 | This takes a subscription_id and an amount and attempts to retry a charge for | ||
| 77 | that amount to that subscription (if found). | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | 0 | ▶ | sub retry_charge { |
|
Subroutine
retry_charge: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 82 | 0 | my ($class, $subscription_id, $amount) = @_; | |
| 83 | 0 | $class->gateway->transaction->retry_subscription_charge($subscription_id, $amount); | |
| 84 | } | ||
| 85 | |||
| 86 | =head2 search() | ||
| 87 | |||
| 88 | This takes a subref which is used to set the search parameters and returns a | ||
| 89 | subscription object. | ||
| 90 | |||
| 91 | Please see L<Searching|WebService::Braintree/SEARCHING> for more information on | ||
| 92 | the subref and how it works. | ||
| 93 | |||
| 94 | Please see L<WebService::Braintree::SubscriptionSearch> for the fields available | ||
| 95 | to be searched on. | ||
| 96 | |||
| 97 | =cut | ||
| 98 | |||
| 99 | 0 | ▶ | sub search { |
|
Subroutine
search: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 100 | 0 | my($class, $block) = @_; | |
| 101 | 0 | $class->gateway->subscription->search($block); | |
| 102 | } | ||
| 103 | |||
| 104 | =head2 all() | ||
| 105 | |||
| 106 | This returns all the subscriptions. | ||
| 107 | |||
| 108 | =cut | ||
| 109 | |||
| 110 | 0 | ▶ | sub all { |
|
Subroutine
all: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 111 | 0 | my $class = shift; | |
| 112 | 0 | $class->gateway->subscription->all; | |
| 113 | } | ||
| 114 | |||
| 115 | 22 | __PACKAGE__->meta->make_immutable; | |
| 116 | |||
| 117 | 22 | 1; | |
| 118 | __END__ | ||