File Coverage

lib/Net/API/Stripe/Billing/Subscription/Item.pm
Criterion Covered Total %
statement 19 31 61.2
branch n/a
condition n/a
subroutine 7 19 36.8
pod 12 12 100.0
total 38 62 61.2


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Billing/Subscription/Item.pm
3             ## Version v0.1.1
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## https://stripe.com/docs/api/subscription_items/object
11             package Net::API::Stripe::Billing::Subscription::Item;
12             BEGIN
13             {
14 2     2   21227243 use strict;
  2         14  
  2         71  
15 2     2   17 use warnings;
  2         5  
  2         57  
16 2     2   9 use parent qw( Net::API::Stripe::Generic );
  2         4  
  2         16  
17 2     2   146 use vars qw( $VERSION );
  2         5  
  2         130  
18 2     2   42 our( $VERSION ) = 'v0.1.1';
19             };
20              
21 2     2   12 use strict;
  2         6  
  2         42  
22 2     2   10 use warnings;
  2         5  
  2         532  
23              
24 0     0 1   sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
25              
26 0     0 1   sub object { return( shift->_set_get_scalar( 'object', @_ ) ); }
27              
28 0     0 1   sub billing_thresholds { return( shift->_set_get_object( 'billing_thresholds', 'Net::API::Stripe::Billing::Thresholds', @_ ) ); }
29              
30             ## Used in upcoming invoice api calls
31 0     0 1   sub clear_usage { return( shift->_set_get_boolean( 'clear_usage', @_ ) ); }
32              
33 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
34              
35 0     0 1   sub deleted { return( shift->_set_get_boolean( 'deleted', @_ ) ); }
36              
37 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
38              
39 0     0 1   sub plan { return( shift->_set_get_object( 'plan', 'Net::API::Stripe::Billing::Plan', @_ ) ); }
40              
41 0     0 1   sub price { return( shift->_set_get_object( 'price', 'Net::API::Stripe::Price', @_ ) ); }
42              
43 0     0 1   sub quantity { return( shift->_set_get_number( 'quantity', @_ ) ); }
44              
45 0     0 1   sub subscription { return( shift->_set_get_scalar( 'subscription', @_ ) ); }
46              
47 0     0 1   sub tax_rates { return( shift->_set_get_object_array( 'tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); }
48              
49             1;
50              
51             __END__
52              
53             =encoding utf8
54              
55             =head1 NAME
56              
57             Net::API::Stripe::Billing::Subscription::Item - A Stripe Subscription Item Object
58              
59             =head1 SYNOPSIS
60              
61             my $item = $stripe->subscription_item({
62             clear_usage => 1,
63             metadata => { transaction_id => 1212, customer_id => 123 },
64             quantity => 1,
65             subscription => 'sub_fake123456789',
66             });
67              
68             =head1 VERSION
69              
70             v0.1.1
71              
72             =head1 DESCRIPTION
73              
74             Subscription items allow you to create customer subscriptions with more than one plan, making it easy to represent complex billing relationships.
75              
76             =head1 CONSTRUCTOR
77              
78             =head2 new( %ARG )
79              
80             Creates a new L<Net::API::Stripe::Billing::Subscription::Item> object.
81              
82             =head1 METHODS
83              
84             =head2 id string
85              
86             Unique identifier for the object.
87              
88             =head2 object string, value is "subscription_item"
89              
90             String representing the object’s type. Objects of the same type share the same value.
91              
92             =head2 billing_thresholds hash
93              
94             Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
95              
96             This is a L<Net::API::Stripe::Billing::Thresholds> object.
97              
98             =over 4
99              
100             =item I<usage_gte> integer
101              
102             Usage threshold that triggers the subscription to create an invoice
103              
104             =back
105              
106             =head2 clear_usage() optional
107              
108             Delete all usage for a given subscription item. Allowed only when deleted is set to true and the current plan’s usage_type is metered.
109              
110             This is used in making upcoming invoice items api calls as described here: L<https://stripe.com/docs/api/invoices/upcoming_invoice_lines>
111              
112             =head2 created integer
113              
114             Time at which the object was created. Measured in seconds since the Unix epoch.
115              
116             =head2 deleted optional
117              
118             A flag that, if set to true, will delete the specified item.
119              
120             This is used in making upcoming invoice items api calls as described here: L<https://stripe.com/docs/api/invoices/upcoming_invoice_lines>
121              
122             =head2 metadata hash
123              
124             Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
125              
126             =head2 plan hash, plan object
127              
128             Hash describing the plan the customer is subscribed to.
129              
130             This is a L<Net::API::Stripe::Billing::Plan> object.
131              
132             =head2 price object
133              
134             The price the customer is subscribed to.
135              
136             This is a L<Net::API::Stripe::Price> object.
137              
138             =head2 quantity positive integer or zero
139              
140             The quantity of the plan to which the customer should be subscribed.
141              
142             =head2 subscription string
143              
144             The subscription this subscription_item belongs to.
145              
146             =head2 tax_rates array of hashes
147              
148             The tax rates which apply to this subscription_item. When set, the default_tax_rates on the subscription do not apply to this subscription_item.
149              
150             This is an array of L<Net::API::Stripe::Tax::Rate> objects.
151              
152             =head1 API SAMPLE
153              
154             {
155             "id": "si_fake123456789",
156             "object": "subscription_item",
157             "billing_thresholds": null,
158             "created": 1571397912,
159             "metadata": {},
160             "plan": {
161             "id": "expert-monthly-jpy",
162             "object": "plan",
163             "active": true,
164             "aggregate_usage": null,
165             "amount": 8000,
166             "amount_decimal": "8000",
167             "billing_scheme": "per_unit",
168             "created": 1507273129,
169             "currency": "jpy",
170             "interval": "month",
171             "interval_count": 1,
172             "livemode": false,
173             "metadata": {},
174             "nickname": null,
175             "product": "prod_fake123456789",
176             "tiers": null,
177             "tiers_mode": null,
178             "transform_usage": null,
179             "trial_period_days": null,
180             "usage_type": "licensed"
181             },
182             "quantity": 1,
183             "subscription": "sub_fake123456789",
184             "tax_rates": []
185             }
186              
187             =head1 HISTORY
188              
189             =head2 v0.1
190              
191             Initial version
192              
193             =head2 v0.1.1
194              
195             Added the methods clear_usage and deleted used in making upcoming invoice item api calls as explained here L<https://stripe.com/docs/api/invoices/upcoming_invoice_lines>
196              
197             =head1 AUTHOR
198              
199             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
200              
201             =head1 SEE ALSO
202              
203             Stripe API documentation:
204              
205             L<https://stripe.com/docs/api/subscription_items>
206              
207             =head1 COPYRIGHT & LICENSE
208              
209             Copyright (c) 2020-2020 DEGUEST Pte. Ltd.
210              
211             You can use, copy, modify and redistribute this package and associated
212             files under the same terms as Perl itself.
213              
214             =cut