File Coverage

blib/lib/Business/GoCardless/Subscription.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 5 0.0
total 27 32 84.3


line stmt bran cond sub pod time code
1             package Business::GoCardless::Subscription;
2              
3             =head1 NAME
4              
5             Business::GoCardless::Subscription
6              
7             =head1 DESCRIPTION
8              
9             A class for a gocardless subscription, extends L
10              
11             =cut
12              
13 19     19   149 use strict;
  19         48  
  19         590  
14 19     19   98 use warnings;
  19         39  
  19         460  
15              
16 19     19   94 use Moo;
  19         45  
  19         144  
17             extends 'Business::GoCardless::Resource';
18              
19             =head1 ATTRIBUTES
20              
21             amount
22             created_at
23             currency
24             day_of_month
25             description
26             expires_at
27             end_date
28             id
29             interval_length
30             interval_unit
31             interval
32             links
33             merchant_id
34             metadata
35             month
36             name
37             next_interval_start
38             payment_reference
39             setup_fee
40             start_at
41             start_date
42             status
43             sub_resource_uris
44             uri
45             user_id
46             upcoming_payments
47              
48             =cut
49              
50             has [ qw/
51             amount
52             created_at
53             currency
54             description
55             day_of_month
56             expires_at
57             end_date
58             id
59             interval_length
60             interval_unit
61             interval
62             links
63             merchant_id
64             metadata
65             month
66             name
67             next_interval_start
68             payment_reference
69             setup_fee
70             start_at
71             start_date
72             status
73             sub_resource_uris
74             uri
75             user_id
76             upcoming_payments
77             / ] => (
78             is => 'rw',
79             );
80              
81             =head1 Operations on a subscription
82              
83             cancel
84              
85             $Subscription->cancel
86              
87             Cancels a subscription.
88              
89             =cut
90              
91             sub cancel {
92 2     2 0 19782 my ( $self ) = @_;
93              
94 2 100       62 if ( $self->client->api_version > 1 ) {
95 1         20 return $self->_operation( undef,'api_post',undef,'actions/cancel' );
96             } else {
97 1         18 return $self->_operation( 'cancel','api_put' );
98             }
99             }
100              
101             =head1 Status checks on a subscription
102              
103             inactive
104             active
105             cancelled
106             expired
107              
108             if ( $Subscription->active ) {
109             ...
110             }
111              
112             =cut
113              
114 1     1 0 1908 sub inactive { return shift->status eq 'inactive' }
115 1     1 0 11 sub active { return shift->status eq 'active' }
116 3     3 0 19355 sub cancelled { return shift->status eq 'cancelled' }
117 1     1 0 16 sub expired { return shift->status eq 'expired' }
118              
119             =head1 AUTHOR
120              
121             Lee Johnson - C
122              
123             This library is free software; you can redistribute it and/or modify it under
124             the same terms as Perl itself. If you would like to contribute documentation,
125             features, bug fixes, or anything else then please raise an issue / pull request:
126              
127             https://github.com/Humanstate/business-gocardless
128              
129             =cut
130              
131             1;
132              
133             # vim: ts=4:sw=4:et