stripe/resources/generated/
product.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use serde::{Deserialize, Serialize};
6
7use crate::client::{Client, Response};
8use crate::ids::{ProductId, TaxCodeId};
9use crate::params::{
10    CurrencyMap, Deleted, Expand, Expandable, List, Metadata, Object, Paginable, RangeQuery,
11    Timestamp,
12};
13use crate::resources::{Currency, Price, TaxCode, UpTo};
14
15/// The resource representing a Stripe "Product".
16///
17/// For more details see <https://stripe.com/docs/api/products/object>
18#[derive(Clone, Debug, Default, Deserialize, Serialize)]
19pub struct Product {
20    /// Unique identifier for the object.
21    pub id: ProductId,
22
23    /// Whether the product is currently available for purchase.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub active: Option<bool>,
26
27    /// Time at which the object was created.
28    ///
29    /// Measured in seconds since the Unix epoch.
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub created: Option<Timestamp>,
32
33    /// The ID of the [Price](https://stripe.com/docs/api/prices) object that is the default price for this product.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub default_price: Option<Expandable<Price>>,
36
37    // Always true for a deleted object
38    #[serde(default)]
39    pub deleted: bool,
40
41    /// The product's description, meant to be displayable to the customer.
42    ///
43    /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub description: Option<String>,
46
47    /// A list of up to 15 features for this product.
48    ///
49    /// These are displayed in [pricing tables](https://stripe.com/docs/payments/checkout/pricing-table).
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub features: Option<Vec<ProductFeature>>,
52
53    /// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub images: Option<Vec<String>>,
56
57    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub livemode: Option<bool>,
60
61    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
62    ///
63    /// This can be useful for storing additional information about the object in a structured format.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub metadata: Option<Metadata>,
66
67    /// The product's name, meant to be displayable to the customer.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub name: Option<String>,
70
71    /// The dimensions of this product for shipping purposes.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub package_dimensions: Option<PackageDimensions>,
74
75    /// Whether this product is shipped (i.e., physical goods).
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub shippable: Option<bool>,
78
79    /// Extra information about a product which will appear on your customer's credit card statement.
80    ///
81    /// In the case that multiple products are billed at once, the first statement descriptor will be used.
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub statement_descriptor: Option<String>,
84
85    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub tax_code: Option<Expandable<TaxCode>>,
88
89    /// The type of the product.
90    ///
91    /// 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.
92    #[serde(rename = "type")]
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub type_: Option<ProductType>,
95
96    /// A label that represents units of this product.
97    ///
98    /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub unit_label: Option<String>,
101
102    /// Time at which the object was last updated.
103    ///
104    /// Measured in seconds since the Unix epoch.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub updated: Option<Timestamp>,
107
108    /// A URL of a publicly-accessible webpage for this product.
109    #[serde(skip_serializing_if = "Option::is_none")]
110    pub url: Option<String>,
111}
112
113impl Product {
114    /// Returns a list of your products.
115    ///
116    /// The products are returned sorted by creation date, with the most recently created products appearing first.
117    pub fn list(client: &Client, params: &ListProducts<'_>) -> Response<List<Product>> {
118        client.get_query("/products", params)
119    }
120
121    /// Creates a new product object.
122    pub fn create(client: &Client, params: CreateProduct<'_>) -> Response<Product> {
123        #[allow(clippy::needless_borrows_for_generic_args)]
124        client.post_form("/products", &params)
125    }
126
127    /// Retrieves the details of an existing product.
128    ///
129    /// Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.
130    pub fn retrieve(client: &Client, id: &ProductId, expand: &[&str]) -> Response<Product> {
131        client.get_query(&format!("/products/{}", id), Expand { expand })
132    }
133
134    /// Updates the specific product by setting the values of the parameters passed.
135    ///
136    /// Any parameters not provided will be left unchanged.
137    pub fn update(client: &Client, id: &ProductId, params: UpdateProduct<'_>) -> Response<Product> {
138        #[allow(clippy::needless_borrows_for_generic_args)]
139        client.post_form(&format!("/products/{}", id), &params)
140    }
141
142    /// Delete a product.
143    ///
144    /// Deleting a product is only possible if it has no prices associated with it.
145    /// Additionally, deleting a product with `type=good` is only possible if it has no SKUs associated with it.
146    pub fn delete(client: &Client, id: &ProductId) -> Response<Deleted<ProductId>> {
147        client.delete(&format!("/products/{}", id))
148    }
149}
150
151impl Object for Product {
152    type Id = ProductId;
153    fn id(&self) -> Self::Id {
154        self.id.clone()
155    }
156    fn object(&self) -> &'static str {
157        "product"
158    }
159}
160
161#[derive(Clone, Debug, Default, Deserialize, Serialize)]
162pub struct PackageDimensions {
163    /// Height, in inches.
164    pub height: f64,
165
166    /// Length, in inches.
167    pub length: f64,
168
169    /// Weight, in ounces.
170    pub weight: f64,
171
172    /// Width, in inches.
173    pub width: f64,
174}
175
176#[derive(Clone, Debug, Default, Deserialize, Serialize)]
177pub struct ProductFeature {
178    /// The feature's name.
179    ///
180    /// Up to 80 characters long.
181    #[serde(skip_serializing_if = "Option::is_none")]
182    pub name: Option<String>,
183}
184
185/// The parameters for `Product::create`.
186#[derive(Clone, Debug, Serialize)]
187pub struct CreateProduct<'a> {
188    /// Whether the product is currently available for purchase.
189    ///
190    /// Defaults to `true`.
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub active: Option<bool>,
193
194    /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object.
195    ///
196    /// This Price will be set as the default price for this product.
197    #[serde(skip_serializing_if = "Option::is_none")]
198    pub default_price_data: Option<CreateProductDefaultPriceData>,
199
200    /// The product's description, meant to be displayable to the customer.
201    ///
202    /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
203    #[serde(skip_serializing_if = "Option::is_none")]
204    pub description: Option<&'a str>,
205
206    /// Specifies which fields in the response should be expanded.
207    #[serde(skip_serializing_if = "Expand::is_empty")]
208    pub expand: &'a [&'a str],
209
210    /// A list of up to 15 features for this product.
211    ///
212    /// These are displayed in [pricing tables](https://stripe.com/docs/payments/checkout/pricing-table).
213    #[serde(skip_serializing_if = "Option::is_none")]
214    pub features: Option<Vec<CreateProductFeatures>>,
215
216    /// An identifier will be randomly generated by Stripe.
217    ///
218    /// You can optionally override this ID, but the ID must be unique across all products in your Stripe account.
219    #[serde(skip_serializing_if = "Option::is_none")]
220    pub id: Option<&'a str>,
221
222    /// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
223    #[serde(skip_serializing_if = "Option::is_none")]
224    pub images: Option<Vec<String>>,
225
226    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
227    ///
228    /// This can be useful for storing additional information about the object in a structured format.
229    /// Individual keys can be unset by posting an empty value to them.
230    /// All keys can be unset by posting an empty value to `metadata`.
231    #[serde(skip_serializing_if = "Option::is_none")]
232    pub metadata: Option<Metadata>,
233
234    /// The product's name, meant to be displayable to the customer.
235    pub name: &'a str,
236
237    /// The dimensions of this product for shipping purposes.
238    #[serde(skip_serializing_if = "Option::is_none")]
239    pub package_dimensions: Option<PackageDimensions>,
240
241    /// Whether this product is shipped (i.e., physical goods).
242    #[serde(skip_serializing_if = "Option::is_none")]
243    pub shippable: Option<bool>,
244
245    /// An arbitrary string to be displayed on your customer's credit card or bank statement.
246    ///
247    /// While most banks display this information consistently, some may display it incorrectly or not at all.  This may be up to 22 characters.
248    /// The statement description may not include `<`, `>`, `\`, `"`, `'` characters, and will appear on your customer's statement in capital letters.
249    /// Non-ASCII characters are automatically stripped.  It must contain at least one letter.
250    #[serde(skip_serializing_if = "Option::is_none")]
251    pub statement_descriptor: Option<&'a str>,
252
253    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub tax_code: Option<TaxCodeId>,
256
257    /// The type of the product.
258    ///
259    /// Defaults to `service` if not explicitly specified, enabling use of this product with Subscriptions and Plans.
260    /// Set this parameter to `good` to use this product with Orders and SKUs.
261    /// On API versions before `2018-02-05`, this field defaults to `good` for compatibility reasons.
262    #[serde(rename = "type")]
263    #[serde(skip_serializing_if = "Option::is_none")]
264    pub type_: Option<ProductType>,
265
266    /// A label that represents units of this product.
267    ///
268    /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
269    #[serde(skip_serializing_if = "Option::is_none")]
270    pub unit_label: Option<&'a str>,
271
272    /// A URL of a publicly-accessible webpage for this product.
273    #[serde(skip_serializing_if = "Option::is_none")]
274    pub url: Option<&'a str>,
275}
276
277impl<'a> CreateProduct<'a> {
278    pub fn new(name: &'a str) -> Self {
279        CreateProduct {
280            active: Default::default(),
281            default_price_data: Default::default(),
282            description: Default::default(),
283            expand: Default::default(),
284            features: Default::default(),
285            id: Default::default(),
286            images: Default::default(),
287            metadata: Default::default(),
288            name,
289            package_dimensions: Default::default(),
290            shippable: Default::default(),
291            statement_descriptor: Default::default(),
292            tax_code: Default::default(),
293            type_: Default::default(),
294            unit_label: Default::default(),
295            url: Default::default(),
296        }
297    }
298}
299
300/// The parameters for `Product::list`.
301#[derive(Clone, Debug, Serialize, Default)]
302pub struct ListProducts<'a> {
303    /// Only return products that are active or inactive (e.g., pass `false` to list all inactive products).
304    #[serde(skip_serializing_if = "Option::is_none")]
305    pub active: Option<bool>,
306
307    /// Only return products that were created during the given date interval.
308    #[serde(skip_serializing_if = "Option::is_none")]
309    pub created: Option<RangeQuery<Timestamp>>,
310
311    /// A cursor for use in pagination.
312    ///
313    /// `ending_before` is an object ID that defines your place in the list.
314    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
315    #[serde(skip_serializing_if = "Option::is_none")]
316    pub ending_before: Option<ProductId>,
317
318    /// Specifies which fields in the response should be expanded.
319    #[serde(skip_serializing_if = "Expand::is_empty")]
320    pub expand: &'a [&'a str],
321
322    /// Only return products with the given IDs.
323    ///
324    /// Cannot be used with [starting_after](https://stripe.com/docs/api#list_products-starting_after) or [ending_before](https://stripe.com/docs/api#list_products-ending_before).
325    #[serde(skip_serializing_if = "Option::is_none")]
326    pub ids: Option<Vec<String>>,
327
328    /// A limit on the number of objects to be returned.
329    ///
330    /// Limit can range between 1 and 100, and the default is 10.
331    #[serde(skip_serializing_if = "Option::is_none")]
332    pub limit: Option<u64>,
333
334    /// Only return products that can be shipped (i.e., physical, not digital products).
335    #[serde(skip_serializing_if = "Option::is_none")]
336    pub shippable: Option<bool>,
337
338    /// A cursor for use in pagination.
339    ///
340    /// `starting_after` is an object ID that defines your place in the list.
341    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
342    #[serde(skip_serializing_if = "Option::is_none")]
343    pub starting_after: Option<ProductId>,
344
345    /// Only return products of this type.
346    #[serde(rename = "type")]
347    #[serde(skip_serializing_if = "Option::is_none")]
348    pub type_: Option<ProductType>,
349
350    /// Only return products with the given url.
351    #[serde(skip_serializing_if = "Option::is_none")]
352    pub url: Option<&'a str>,
353}
354
355impl<'a> ListProducts<'a> {
356    pub fn new() -> Self {
357        ListProducts {
358            active: Default::default(),
359            created: Default::default(),
360            ending_before: Default::default(),
361            expand: Default::default(),
362            ids: Default::default(),
363            limit: Default::default(),
364            shippable: Default::default(),
365            starting_after: Default::default(),
366            type_: Default::default(),
367            url: Default::default(),
368        }
369    }
370}
371impl Paginable for ListProducts<'_> {
372    type O = Product;
373    fn set_last(&mut self, item: Self::O) {
374        self.starting_after = Some(item.id());
375    }
376}
377/// The parameters for `Product::update`.
378#[derive(Clone, Debug, Serialize, Default)]
379pub struct UpdateProduct<'a> {
380    /// Whether the product is available for purchase.
381    #[serde(skip_serializing_if = "Option::is_none")]
382    pub active: Option<bool>,
383
384    /// The ID of the [Price](https://stripe.com/docs/api/prices) object that is the default price for this product.
385    #[serde(skip_serializing_if = "Option::is_none")]
386    pub default_price: Option<&'a str>,
387
388    /// The product's description, meant to be displayable to the customer.
389    ///
390    /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
391    #[serde(skip_serializing_if = "Option::is_none")]
392    pub description: Option<String>,
393
394    /// Specifies which fields in the response should be expanded.
395    #[serde(skip_serializing_if = "Expand::is_empty")]
396    pub expand: &'a [&'a str],
397
398    /// A list of up to 15 features for this product.
399    ///
400    /// These are displayed in [pricing tables](https://stripe.com/docs/payments/checkout/pricing-table).
401    #[serde(skip_serializing_if = "Option::is_none")]
402    pub features: Option<Vec<UpdateProductFeatures>>,
403
404    /// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
405    #[serde(skip_serializing_if = "Option::is_none")]
406    pub images: Option<Vec<String>>,
407
408    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
409    ///
410    /// This can be useful for storing additional information about the object in a structured format.
411    /// Individual keys can be unset by posting an empty value to them.
412    /// All keys can be unset by posting an empty value to `metadata`.
413    #[serde(skip_serializing_if = "Option::is_none")]
414    pub metadata: Option<Metadata>,
415
416    /// The product's name, meant to be displayable to the customer.
417    #[serde(skip_serializing_if = "Option::is_none")]
418    pub name: Option<&'a str>,
419
420    /// The dimensions of this product for shipping purposes.
421    #[serde(skip_serializing_if = "Option::is_none")]
422    pub package_dimensions: Option<PackageDimensions>,
423
424    /// Whether this product is shipped (i.e., physical goods).
425    #[serde(skip_serializing_if = "Option::is_none")]
426    pub shippable: Option<bool>,
427
428    /// An arbitrary string to be displayed on your customer's credit card or bank statement.
429    ///
430    /// While most banks display this information consistently, some may display it incorrectly or not at all.  This may be up to 22 characters.
431    /// The statement description may not include `<`, `>`, `\`, `"`, `'` characters, and will appear on your customer's statement in capital letters.
432    /// Non-ASCII characters are automatically stripped.  It must contain at least one letter.
433    /// May only be set if `type=service`.
434    #[serde(skip_serializing_if = "Option::is_none")]
435    pub statement_descriptor: Option<&'a str>,
436
437    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
438    #[serde(skip_serializing_if = "Option::is_none")]
439    pub tax_code: Option<String>,
440
441    /// A label that represents units of this product.
442    ///
443    /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
444    /// May only be set if `type=service`.
445    #[serde(skip_serializing_if = "Option::is_none")]
446    pub unit_label: Option<String>,
447
448    /// A URL of a publicly-accessible webpage for this product.
449    #[serde(skip_serializing_if = "Option::is_none")]
450    pub url: Option<String>,
451}
452
453impl<'a> UpdateProduct<'a> {
454    pub fn new() -> Self {
455        UpdateProduct {
456            active: Default::default(),
457            default_price: Default::default(),
458            description: Default::default(),
459            expand: Default::default(),
460            features: Default::default(),
461            images: Default::default(),
462            metadata: Default::default(),
463            name: Default::default(),
464            package_dimensions: Default::default(),
465            shippable: Default::default(),
466            statement_descriptor: Default::default(),
467            tax_code: Default::default(),
468            unit_label: Default::default(),
469            url: Default::default(),
470        }
471    }
472}
473
474#[derive(Clone, Debug, Default, Deserialize, Serialize)]
475pub struct CreateProductDefaultPriceData {
476    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
477    ///
478    /// Must be a [supported currency](https://stripe.com/docs/currencies).
479    pub currency: Currency,
480
481    /// Prices defined in each available currency option.
482    ///
483    /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
484    #[serde(skip_serializing_if = "Option::is_none")]
485    pub currency_options: Option<CurrencyMap<CreateProductDefaultPriceDataCurrencyOptions>>,
486
487    /// The recurring components of a price such as `interval` and `interval_count`.
488    #[serde(skip_serializing_if = "Option::is_none")]
489    pub recurring: Option<CreateProductDefaultPriceDataRecurring>,
490
491    /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings.
492    ///
493    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
494    /// One of `inclusive`, `exclusive`, or `unspecified`.
495    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
496    #[serde(skip_serializing_if = "Option::is_none")]
497    pub tax_behavior: Option<CreateProductDefaultPriceDataTaxBehavior>,
498
499    /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
500    ///
501    /// One of `unit_amount` or `unit_amount_decimal` is required.
502    #[serde(skip_serializing_if = "Option::is_none")]
503    pub unit_amount: Option<i64>,
504
505    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
506    ///
507    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
508    #[serde(skip_serializing_if = "Option::is_none")]
509    pub unit_amount_decimal: Option<String>,
510}
511
512#[derive(Clone, Debug, Default, Deserialize, Serialize)]
513pub struct CreateProductFeatures {
514    /// The feature's name.
515    ///
516    /// Up to 80 characters long.
517    pub name: String,
518}
519
520#[derive(Clone, Debug, Default, Deserialize, Serialize)]
521pub struct UpdateProductFeatures {
522    /// The feature's name.
523    ///
524    /// Up to 80 characters long.
525    pub name: String,
526}
527
528#[derive(Clone, Debug, Default, Deserialize, Serialize)]
529pub struct CreateProductDefaultPriceDataCurrencyOptions {
530    /// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links.
531    #[serde(skip_serializing_if = "Option::is_none")]
532    pub custom_unit_amount: Option<CreateProductDefaultPriceDataCurrencyOptionsCustomUnitAmount>,
533
534    /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings.
535    ///
536    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
537    /// One of `inclusive`, `exclusive`, or `unspecified`.
538    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
539    #[serde(skip_serializing_if = "Option::is_none")]
540    pub tax_behavior: Option<CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior>,
541
542    /// Each element represents a pricing tier.
543    ///
544    /// This parameter requires `billing_scheme` to be set to `tiered`.
545    /// See also the documentation for `billing_scheme`.
546    #[serde(skip_serializing_if = "Option::is_none")]
547    pub tiers: Option<Vec<CreateProductDefaultPriceDataCurrencyOptionsTiers>>,
548
549    /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
550    #[serde(skip_serializing_if = "Option::is_none")]
551    pub unit_amount: Option<i64>,
552
553    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
554    ///
555    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
556    #[serde(skip_serializing_if = "Option::is_none")]
557    pub unit_amount_decimal: Option<String>,
558}
559
560#[derive(Clone, Debug, Default, Deserialize, Serialize)]
561pub struct CreateProductDefaultPriceDataRecurring {
562    /// Specifies billing frequency.
563    ///
564    /// Either `day`, `week`, `month` or `year`.
565    pub interval: CreateProductDefaultPriceDataRecurringInterval,
566
567    /// The number of intervals between subscription billings.
568    ///
569    /// For example, `interval=month` and `interval_count=3` bills every 3 months.
570    /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
571    #[serde(skip_serializing_if = "Option::is_none")]
572    pub interval_count: Option<u64>,
573}
574
575#[derive(Clone, Debug, Default, Deserialize, Serialize)]
576pub struct CreateProductDefaultPriceDataCurrencyOptionsCustomUnitAmount {
577    /// Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`.
578    pub enabled: bool,
579
580    /// The maximum unit amount the customer can specify for this item.
581    #[serde(skip_serializing_if = "Option::is_none")]
582    pub maximum: Option<i64>,
583
584    /// The minimum unit amount the customer can specify for this item.
585    ///
586    /// Must be at least the minimum charge amount.
587    #[serde(skip_serializing_if = "Option::is_none")]
588    pub minimum: Option<i64>,
589
590    /// The starting unit amount which can be updated by the customer.
591    #[serde(skip_serializing_if = "Option::is_none")]
592    pub preset: Option<i64>,
593}
594
595#[derive(Clone, Debug, Default, Deserialize, Serialize)]
596pub struct CreateProductDefaultPriceDataCurrencyOptionsTiers {
597    /// The flat billing amount for an entire tier, regardless of the number of units in the tier.
598    #[serde(skip_serializing_if = "Option::is_none")]
599    pub flat_amount: Option<i64>,
600
601    /// Same as `flat_amount`, but accepts a decimal value representing an integer in the minor units of the currency.
602    ///
603    /// Only one of `flat_amount` and `flat_amount_decimal` can be set.
604    #[serde(skip_serializing_if = "Option::is_none")]
605    pub flat_amount_decimal: Option<String>,
606
607    /// The per unit billing amount for each individual unit for which this tier applies.
608    #[serde(skip_serializing_if = "Option::is_none")]
609    pub unit_amount: Option<i64>,
610
611    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
612    ///
613    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
614    #[serde(skip_serializing_if = "Option::is_none")]
615    pub unit_amount_decimal: Option<String>,
616
617    /// Specifies the upper bound of this tier.
618    ///
619    /// The lower bound of a tier is the upper bound of the previous tier adding one.
620    /// Use `inf` to define a fallback tier.
621    pub up_to: Option<UpTo>,
622}
623
624/// An enum representing the possible values of an `CreateProductDefaultPriceDataCurrencyOptions`'s `tax_behavior` field.
625#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
626#[serde(rename_all = "snake_case")]
627pub enum CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
628    Exclusive,
629    Inclusive,
630    Unspecified,
631}
632
633impl CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
634    pub fn as_str(self) -> &'static str {
635        match self {
636            CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior::Exclusive => "exclusive",
637            CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior::Inclusive => "inclusive",
638            CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior::Unspecified => "unspecified",
639        }
640    }
641}
642
643impl AsRef<str> for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
644    fn as_ref(&self) -> &str {
645        self.as_str()
646    }
647}
648
649impl std::fmt::Display for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
650    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
651        self.as_str().fmt(f)
652    }
653}
654impl std::default::Default for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
655    fn default() -> Self {
656        Self::Exclusive
657    }
658}
659
660/// An enum representing the possible values of an `CreateProductDefaultPriceDataRecurring`'s `interval` field.
661#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
662#[serde(rename_all = "snake_case")]
663pub enum CreateProductDefaultPriceDataRecurringInterval {
664    Day,
665    Month,
666    Week,
667    Year,
668}
669
670impl CreateProductDefaultPriceDataRecurringInterval {
671    pub fn as_str(self) -> &'static str {
672        match self {
673            CreateProductDefaultPriceDataRecurringInterval::Day => "day",
674            CreateProductDefaultPriceDataRecurringInterval::Month => "month",
675            CreateProductDefaultPriceDataRecurringInterval::Week => "week",
676            CreateProductDefaultPriceDataRecurringInterval::Year => "year",
677        }
678    }
679}
680
681impl AsRef<str> for CreateProductDefaultPriceDataRecurringInterval {
682    fn as_ref(&self) -> &str {
683        self.as_str()
684    }
685}
686
687impl std::fmt::Display for CreateProductDefaultPriceDataRecurringInterval {
688    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
689        self.as_str().fmt(f)
690    }
691}
692impl std::default::Default for CreateProductDefaultPriceDataRecurringInterval {
693    fn default() -> Self {
694        Self::Day
695    }
696}
697
698/// An enum representing the possible values of an `CreateProductDefaultPriceData`'s `tax_behavior` field.
699#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
700#[serde(rename_all = "snake_case")]
701pub enum CreateProductDefaultPriceDataTaxBehavior {
702    Exclusive,
703    Inclusive,
704    Unspecified,
705}
706
707impl CreateProductDefaultPriceDataTaxBehavior {
708    pub fn as_str(self) -> &'static str {
709        match self {
710            CreateProductDefaultPriceDataTaxBehavior::Exclusive => "exclusive",
711            CreateProductDefaultPriceDataTaxBehavior::Inclusive => "inclusive",
712            CreateProductDefaultPriceDataTaxBehavior::Unspecified => "unspecified",
713        }
714    }
715}
716
717impl AsRef<str> for CreateProductDefaultPriceDataTaxBehavior {
718    fn as_ref(&self) -> &str {
719        self.as_str()
720    }
721}
722
723impl std::fmt::Display for CreateProductDefaultPriceDataTaxBehavior {
724    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
725        self.as_str().fmt(f)
726    }
727}
728impl std::default::Default for CreateProductDefaultPriceDataTaxBehavior {
729    fn default() -> Self {
730        Self::Exclusive
731    }
732}
733
734/// An enum representing the possible values of an `Product`'s `type` field.
735#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
736#[serde(rename_all = "snake_case")]
737pub enum ProductType {
738    Good,
739    Service,
740}
741
742impl ProductType {
743    pub fn as_str(self) -> &'static str {
744        match self {
745            ProductType::Good => "good",
746            ProductType::Service => "service",
747        }
748    }
749}
750
751impl AsRef<str> for ProductType {
752    fn as_ref(&self) -> &str {
753        self.as_str()
754    }
755}
756
757impl std::fmt::Display for ProductType {
758    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
759        self.as_str().fmt(f)
760    }
761}
762impl std::default::Default for ProductType {
763    fn default() -> Self {
764        Self::Good
765    }
766}