File Coverage

lib/Net/API/Stripe/Order/SKU.pm
Criterion Covered Total %
statement 19 33 57.5
branch n/a
condition n/a
subroutine 7 21 33.3
pod 14 14 100.0
total 40 68 58.8


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Order/SKU.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 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/skus/object
11             package Net::API::Stripe::Order::SKU;
12             BEGIN
13             {
14 1     1   1072 use strict;
  1         2  
  1         32  
15 1     1   6 use warnings;
  1         7  
  1         33  
16 1     1   8 use parent qw( Net::API::Stripe::Generic );
  1         3  
  1         6  
17 1     1   93 use vars qw( $VERSION );
  1         2  
  1         52  
18 1     1   32 our( $VERSION ) = 'v0.100.0';
19             };
20              
21 1     1   6 use strict;
  1         2  
  1         22  
22 1     1   4 use warnings;
  1         3  
  1         411  
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_hash( 'attributes', @_ ) ); }
31              
32 0     0 1   sub created { return( shift->_set_get_datetime( 'created', @_ ) ); }
33              
34 0     0 1   sub currency { return( shift->_set_get_scalar( 'currency', @_ ) ); }
35              
36 0     0 1   sub image { return( shift->_set_get_uri( 'image', @_ ) ); }
37              
38 0     0 1   sub inventory { return( shift->_set_get_object( 'inventory', 'Net::API::Stripe::Order::SKU::Inventory', @_ ) ); }
39              
40 0     0 1   sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); }
41              
42 0     0 1   sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
43              
44 0     0 1   sub package_dimensions { return( shift->_set_get_object( 'package_dimensions', 'Net::API::Stripe::Order::SKU::PackageDimensions', @_ ) ); }
45              
46 0     0 1   sub price { return( shift->_set_get_number( 'price', @_ ) ); }
47              
48 0     0 1   sub product { return( shift->_set_get_scalar_or_object( 'product', 'Net::API::Stripe::Product', @_ ) ); }
49              
50 0     0 1   sub updated { return( shift->_set_get_datetime( 'updated', @_ ) ); }
51              
52             1;
53              
54             __END__
55              
56             =encoding utf8
57              
58             =head1 NAME
59              
60             Net::API::Stripe::Order::SKU - A Stripe SKU Object
61              
62             =head1 SYNOPSIS
63              
64             my $sku = $stripe->sku({
65             active => $stripe->true,
66             attributes =>
67             {
68             size => 'Medium',
69             gender => 'Unisex',
70             },
71             currency => 'jpy',
72             image => 'https://example.com/path/product.jpg',
73             inventory => $inventory_object,
74             metadata => { transaction_id => 123 },
75             package_dimensions =>
76             {
77             # In inches
78             height => 6,
79             length => 20,
80             # Ounce
81             weight => 21
82             width => 12
83             },
84             price => 2000,
85             product => $product_object,
86             });
87              
88             See documentation in L<Net::API::Stripe> for example to make api calls to Stripe to create those objects.
89              
90             =head1 VERSION
91              
92             v0.100.0
93              
94             =head1 DESCRIPTION
95              
96             Stores representations of stock keeping units (L<http://en.wikipedia.org/wiki/Stock_keeping_unit>). SKUs describe specific product variations, taking into account any combination of: attributes, currency, and cost. For example, a product may be a T-shirt, whereas a specific SKU represents the size: large, color: red version of that shirt.
97              
98             Can also be used to manage inventory.
99              
100             =head1 CONSTRUCTOR
101              
102             =head2 new( %ARG )
103              
104             Creates a new L<Net::API::Stripe::Order::SKU> object.
105             It may also take an hash like arguments, that also are method of the same name.
106              
107             =head1 METHODS
108              
109             =head2 id string
110              
111             Unique identifier for the object.
112              
113             =head2 object string, value is "sku"
114              
115             String representing the object’s type. Objects of the same type share the same value.
116              
117             =head2 active boolean
118              
119             Whether the SKU is available for purchase.
120              
121             =head2 attributes hash
122              
123             A dictionary of attributes and values for the attributes defined by the product. If, for example, a product’s attributes are ["size", "gender"], a valid SKU has the following dictionary of attributes: {"size": "Medium", "gender": "Unisex"}.
124              
125             =head2 created timestamp
126              
127             Time at which the object was created. Measured in seconds since the Unix epoch.
128              
129             =head2 currency currency
130              
131             Three-letter ISO currency code, in lowercase. Must be a supported currency.
132              
133             =head2 image string
134              
135             The URL of an image for this SKU, meant to be displayable to the customer.
136              
137             This is a L<URI> object.
138              
139             =head2 inventory hash
140              
141             Description of the SKU’s inventory.
142              
143             This is a L<Net::API::Stripe::Order::SKU::Inventory> object.
144              
145             =head2 livemode boolean
146              
147             Has the value true if the object exists in live mode or the value false if the object exists in test mode.
148              
149             =head2 metadata hash
150              
151             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.
152              
153             =head2 package_dimensions hash
154              
155             The dimensions of this SKU for shipping purposes.
156              
157             This is a L<Net::API::Stripe::Order::SKU::PackageDimensions> object.
158              
159             =head2 price positive integer or zero
160              
161             The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 100 to charge ¥100, Japanese Yen being a zero-decimal currency).
162              
163             =head2 product string (expandable)
164              
165             The ID of the product this SKU is associated with. The product must be currently active.
166              
167             When expanded, this is a L<Net::API::Stripe::Product> object.
168              
169             =head2 updated timestamp
170              
171             Time at which the object was last updated. Measured in seconds since the Unix epoch.
172              
173             =head1 API SAMPLE
174              
175             {
176             "id": "sku_fake123456789",
177             "object": "sku",
178             "active": true,
179             "attributes": {
180             "size": "Medium",
181             "gender": "Unisex"
182             },
183             "created": 1571480453,
184             "currency": "jpy",
185             "image": null,
186             "inventory": {
187             "quantity": 50,
188             "type": "finite",
189             "value": null
190             },
191             "livemode": false,
192             "metadata": {},
193             "package_dimensions": null,
194             "price": 1500,
195             "product": "prod_fake123456789",
196             "updated": 1571480453
197             }
198              
199             =head1 HISTORY
200              
201             =head2 v0.1
202              
203             Initial version
204              
205             =head1 AUTHOR
206              
207             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
208              
209             =head1 SEE ALSO
210              
211             Stripe API documentation:
212              
213             L<https://stripe.com/docs/api/skus>, L<https://stripe.com/docs/orders>
214              
215             =head1 COPYRIGHT & LICENSE
216              
217             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
218              
219             You can use, copy, modify and redistribute this package and associated
220             files under the same terms as Perl itself.
221              
222             =cut