File Coverage

blib/lib/Net/API/Stripe/Product.pm
Criterion Covered Total %
statement 7 28 25.0
branch n/a
condition n/a
subroutine 3 24 12.5
pod 21 21 100.0
total 31 73 42.4


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