File Coverage

lib/Net/API/Stripe/Product.pm
Criterion Covered Total %
statement 19 42 45.2
branch n/a
condition n/a
subroutine 7 30 23.3
pod 23 23 100.0
total 49 95 51.5


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Product.pm
3             ## Version v0.101.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2022/10/29
8             ##
9             ##----------------------------------------------------------------------------
10             ## "A list of up to 5 attributes that each SKU can provide values for (e.g., ["color", "size"]). Only applicable to products of type=good."
11             package Net::API::Stripe::Product;
12             BEGIN
13             {
14 2     2   21167585 use strict;
  2         15  
  2         62  
15 2     2   10 use warnings;
  2         7  
  2         65  
16 2     2   14 use parent qw( Net::API::Stripe::Generic );
  2         6  
  2         9  
17 2     2   151 use vars qw( $VERSION );
  2         6  
  2         122  
18 2     2   38 our( $VERSION ) = 'v0.101.0';
19             };
20              
21 2     2   12 use strict;
  2         4  
  2         38  
22 2     2   9 use warnings;
  2         5  
  2         1148  
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 active { return( shift->_set_get_boolean( 'active', @_ ) ); }
29              
30 0     0 1   sub attributes { return( shift->_set_get_array( 'attributes', @_ ) ); }
31              
32 0     0 1   sub caption { return( shift->_set_get_scalar( 'caption', @_ ) ); }
33              
34 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
35              
36 0     0 1   sub deactivate_on { return( shift->_set_get_array( 'deactivate_on', @_ ) ); }
37              
38 0     0 1   sub default_price { return( shift->_set_get_scalar_or_object( 'default_price', 'Net::API::Stripe::Price', @_ ) ); }
39              
40 0     0 1   sub deleted { return( shift->_set_get_boolean( 'deleted', @_ ) ); }
41              
42 0     0 1   sub description { return( shift->_set_get_scalar( 'description', @_ ) ); }
43              
44 0     0 1   sub images { return( shift->_set_get_array( 'images', @_ ) ); }
45              
46 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
47              
48 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
49              
50 0     0 1   sub name { return( shift->_set_get_scalar( 'name', @_ ) ); }
51              
52 0     0 1   sub package_dimensions { return( shift->_set_get_object( 'package_dimensions', 'Net::API::Stripe::Product::PackageDimension', @_ ) ); }
53              
54 0     0 1   sub shippable { return( shift->_set_get_scalar( 'shippable', @_ ) ); }
55              
56             ## List of Net::API::Stripe::Order::SKU objects
57              
58 0     0 1   sub skus { return( shift->_set_get_object( 'Net::API::Stripe::List', @_ ) ); }
59              
60 0     0 1   sub statement_descriptor { return( shift->_set_get_scalar( 'statement_descriptor', @_ ) ); }
61              
62 0     0 1   sub tax_code { return( shift->_set_get_scalar_or_object( 'tax_code', 'Net::API::Stripe::Product::TaxCode', @_ ) ); }
63              
64 0     0 1   sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
65              
66 0     0 1   sub unit_label { return( shift->_set_get_scalar( 'unit_label', @_ ) ); }
67              
68 0     0 1   sub updated { return( shift->_set_get_datetime( 'updated', @_ ) ); }
69              
70 0     0 1   sub url { return( shift->_set_get_uri( 'url', @_ ) ); }
71              
72             1;
73              
74             __END__
75              
76             =encoding utf8
77              
78             =head1 NAME
79              
80             Net::API::Stripe::Product - A Stripe Product Object
81              
82             =head1 SYNOPSIS
83              
84             my $prod = $stripe->product({
85             active => $stripe->true,
86             attributes => [qw( colour size gender )],
87             caption => 'Fashionable T-shirt',
88             description => 'Product for limited edition t-shirt',
89             images => [qw(
90             https://img.example.com/p12/file1.jpg
91             https://img.example.com/p12/file2.jpg
92             https://img.example.com/p12/file3.jpg
93             )],
94             livemode => $stripe->false,
95             metadata => { product_id => 123, customer_id => 456 },
96             name => 'Limited Edition Shirt',
97             package_dimensions =>
98             {
99             use_metric => 1,
100             width => 30,
101             length => 50,
102             height => 15,
103             weight => 500,
104             },
105             shippable => $stripe->true,
106             type => 'good',
107             url => 'https://store.example.com/p12/',
108             });
109              
110             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
111              
112             =head1 VERSION
113              
114             v0.101.0
115              
116             =head1 DESCRIPTION
117              
118             Store representations of products you sell in Product objects, used in conjunction with L<SKUs|https://stripe.com/docs/api/products#skus>. Products may be physical goods, to be shipped, or digital.
119              
120             Documentation on Products for use with Subscriptions can be found at L<Subscription Products|https://stripe.com/docs/api/products#service_products>.
121              
122             =head1 CONSTRUCTOR
123              
124             =head2 new( %ARG )
125              
126             Creates a new L<Net::API::Stripe::Product> object.
127              
128             =head1 METHODS
129              
130             =head2 id string
131              
132             Unique identifier for the object.
133              
134             =head2 object string, value is "product"
135              
136             String representing the object’s type. Objects of the same type share the same value.
137              
138             =head2 active boolean
139              
140             Whether the product is currently available for purchase.
141              
142             =head2 attributes array containing strings
143              
144             A list of up to 5 attributes that each SKU can provide values for (e.g., ["color", "size"]). Only applicable to products of type=good.
145              
146             =head2 caption string
147              
148             A short one-line description of the product, meant to be displayable to the customer. Only applicable to products of type=good.
149              
150             =head2 created timestamp
151              
152             Time at which the object was created. Measured in seconds since the Unix epoch.
153              
154             =head2 deactivate_on array containing strings
155              
156             An array of connect application identifiers that cannot purchase this product. Only applicable to products of type=good.
157              
158             =head2 default_price expandable
159              
160             The ID of the L<Price|https://stripe.com/docs/api/prices> object that is the default price for this product.
161              
162             When expanded this is an L<Net::API::Stripe::Price> object.
163              
164             =head2 deleted boolean
165              
166             Set to true when the product has been deleted.
167              
168             =head2 description string
169              
170             The product’s description, meant to be displayable to the customer. Only applicable to products of type=good.
171              
172             =head2 images array containing strings
173              
174             A list of up to 8 URLs of images for this product, meant to be displayable to the customer. Only applicable to products of type=good.
175              
176             =head2 livemode boolean
177              
178             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
179              
180             =head2 metadata hash
181              
182             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.
183              
184             =head2 name string
185              
186             The product’s name, meant to be displayable to the customer. Applicable to both service and good types.
187              
188             =head2 package_dimensions hash
189              
190             The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own package_dimensions. Only applicable to products of type=good.
191              
192             This is a L<Net::API::Stripe::Product::PackageDimension> object.
193              
194             =head2 shippable boolean
195              
196             Whether this product is a shipped good. Only applicable to products of type=good.
197              
198             =head2 skus list
199              
200             This is a list (L<Net::API::Stripe::List>) of L<Net::API::Stripe::Order::SKU> objects.
201              
202             This is an undocumented property.
203              
204             =head2 statement_descriptor string
205              
206             Extra information about a product which will appear on your customer’s credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only available on products of type=service.
207              
208             =head2 tax_code expandable
209              
210             A L<tax code|https://stripe.com/docs/tax/tax-categories> ID.
211              
212             When expanded this is an L<Net::API::Stripe::Product::TaxCode> object.
213              
214             =head2 type string
215              
216             The type of the product. The product is either of type good, which is eligible for use with Orders and SKUs, or service, which is eligible for use with Subscriptions and Plans.
217              
218             =head2 unit_label string
219              
220             A label that represents units of this product, such as seat(s), in Stripe and on customers’ receipts and invoices. Only available on products of type=service.
221              
222             =head2 updated timestamp
223              
224             Time at which the object was last updated. Measured in seconds since the Unix epoch.
225              
226             =head2 url string
227              
228             A URL of a publicly-accessible webpage for this product. Only applicable to products of type=good
229              
230             This returns a L<URI> object.
231              
232             =head1 API SAMPLE
233              
234             {
235             "id": "prod_fake123456789",
236             "object": "product",
237             "active": true,
238             "attributes": [],
239             "caption": null,
240             "created": 1541833574,
241             "deactivate_on": [],
242             "description": null,
243             "images": [],
244             "livemode": false,
245             "metadata": {},
246             "name": "Provider, Inc investor yearly membership",
247             "package_dimensions": null,
248             "shippable": null,
249             "statement_descriptor": null,
250             "type": "service",
251             "unit_label": null,
252             "updated": 1565089803,
253             "url": null
254             }
255              
256             =head1 HISTORY
257              
258             =head2 v0.1
259              
260             Initial version
261              
262             =head1 STRIPE HISTORY
263              
264             =head2 2018-05-21
265              
266             Products no longer have SKU lists embedded.
267              
268             =head1 AUTHOR
269              
270             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
271              
272             =head1 SEE ALSO
273              
274             Stripe API documentation:
275              
276             L<https://stripe.com/docs/api/products>, L<https://stripe.com/docs/orders#define-products-skus>, L<https://stripe.com/docs/billing/subscriptions/products-and-plans#products>
277              
278             =head1 COPYRIGHT & LICENSE
279              
280             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
281              
282             You can use, copy, modify and redistribute this package and associated
283             files under the same terms as Perl itself.
284              
285             =cut