stripe/resources/generated/
shipping_rate.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::{ShippingRateId, TaxCodeId};
7use crate::params::{
8    CurrencyMap, Expand, Expandable, List, Metadata, Object, Paginable, RangeQuery, Timestamp,
9};
10use crate::resources::{Currency, TaxCode};
11use serde::{Deserialize, Serialize};
12
13/// The resource representing a Stripe "ShippingRate".
14///
15/// For more details see <https://stripe.com/docs/api/shipping_rates/object>
16#[derive(Clone, Debug, Default, Deserialize, Serialize)]
17pub struct ShippingRate {
18    /// Unique identifier for the object.
19    pub id: ShippingRateId,
20
21    /// Whether the shipping rate can be used for new purchases.
22    ///
23    /// Defaults to `true`.
24    pub active: bool,
25
26    /// Time at which the object was created.
27    ///
28    /// Measured in seconds since the Unix epoch.
29    pub created: Timestamp,
30
31    /// The estimated range for how long shipping will take, meant to be displayable to the customer.
32    ///
33    /// This will appear on CheckoutSessions.
34    pub delivery_estimate: Option<ShippingRateDeliveryEstimate>,
35
36    /// The name of the shipping rate, meant to be displayable to the customer.
37    ///
38    /// This will appear on CheckoutSessions.
39    pub display_name: Option<String>,
40
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub fixed_amount: Option<ShippingRateFixedAmount>,
43
44    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
45    pub livemode: bool,
46
47    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
48    ///
49    /// This can be useful for storing additional information about the object in a structured format.
50    pub metadata: Metadata,
51
52    /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes.
53    ///
54    /// One of `inclusive`, `exclusive`, or `unspecified`.
55    pub tax_behavior: Option<ShippingRateTaxBehavior>,
56
57    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
58    ///
59    /// The Shipping tax code is `txcd_92010001`.
60    pub tax_code: Option<Expandable<TaxCode>>,
61
62    /// The type of calculation to use on the shipping rate.
63    ///
64    /// Can only be `fixed_amount` for now.
65    #[serde(rename = "type")]
66    pub type_: ShippingRateType,
67}
68
69impl ShippingRate {
70    /// Returns a list of your shipping rates.
71    pub fn list(client: &Client, params: &ListShippingRates<'_>) -> Response<List<ShippingRate>> {
72        client.get_query("/shipping_rates", params)
73    }
74
75    /// Creates a new shipping rate object.
76    pub fn create(client: &Client, params: CreateShippingRate<'_>) -> Response<ShippingRate> {
77        #[allow(clippy::needless_borrows_for_generic_args)]
78        client.post_form("/shipping_rates", &params)
79    }
80
81    /// Returns the shipping rate object with the given ID.
82    pub fn retrieve(
83        client: &Client,
84        id: &ShippingRateId,
85        expand: &[&str],
86    ) -> Response<ShippingRate> {
87        client.get_query(&format!("/shipping_rates/{}", id), Expand { expand })
88    }
89
90    /// Updates an existing shipping rate object.
91    pub fn update(
92        client: &Client,
93        id: &ShippingRateId,
94        params: UpdateShippingRate<'_>,
95    ) -> Response<ShippingRate> {
96        #[allow(clippy::needless_borrows_for_generic_args)]
97        client.post_form(&format!("/shipping_rates/{}", id), &params)
98    }
99}
100
101impl Object for ShippingRate {
102    type Id = ShippingRateId;
103    fn id(&self) -> Self::Id {
104        self.id.clone()
105    }
106    fn object(&self) -> &'static str {
107        "shipping_rate"
108    }
109}
110
111#[derive(Clone, Debug, Default, Deserialize, Serialize)]
112pub struct ShippingRateDeliveryEstimate {
113    /// The upper bound of the estimated range.
114    ///
115    /// If empty, represents no upper bound i.e., infinite.
116    pub maximum: Option<ShippingRateDeliveryEstimateBound>,
117
118    /// The lower bound of the estimated range.
119    ///
120    /// If empty, represents no lower bound.
121    pub minimum: Option<ShippingRateDeliveryEstimateBound>,
122}
123
124#[derive(Clone, Debug, Default, Deserialize, Serialize)]
125pub struct ShippingRateDeliveryEstimateBound {
126    /// A unit of time.
127    pub unit: ShippingRateDeliveryEstimateBoundUnit,
128
129    /// Must be greater than 0.
130    pub value: i64,
131}
132
133#[derive(Clone, Debug, Default, Deserialize, Serialize)]
134pub struct ShippingRateFixedAmount {
135    /// A non-negative integer in cents representing how much to charge.
136    pub amount: i64,
137
138    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
139    ///
140    /// Must be a [supported currency](https://stripe.com/docs/currencies).
141    pub currency: Currency,
142
143    /// Shipping rates defined in each available currency option.
144    ///
145    /// 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).
146    #[serde(skip_serializing_if = "Option::is_none")]
147    pub currency_options: Option<CurrencyMap<ShippingRateCurrencyOption>>,
148}
149
150#[derive(Clone, Debug, Default, Deserialize, Serialize)]
151pub struct ShippingRateCurrencyOption {
152    /// A non-negative integer in cents representing how much to charge.
153    pub amount: i64,
154
155    /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes.
156    ///
157    /// One of `inclusive`, `exclusive`, or `unspecified`.
158    pub tax_behavior: ShippingRateCurrencyOptionTaxBehavior,
159}
160
161/// The parameters for `ShippingRate::create`.
162#[derive(Clone, Debug, Serialize)]
163pub struct CreateShippingRate<'a> {
164    /// The estimated range for how long shipping will take, meant to be displayable to the customer.
165    ///
166    /// This will appear on CheckoutSessions.
167    #[serde(skip_serializing_if = "Option::is_none")]
168    pub delivery_estimate: Option<CreateShippingRateDeliveryEstimate>,
169
170    /// The name of the shipping rate, meant to be displayable to the customer.
171    ///
172    /// This will appear on CheckoutSessions.
173    pub display_name: &'a str,
174
175    /// Specifies which fields in the response should be expanded.
176    #[serde(skip_serializing_if = "Expand::is_empty")]
177    pub expand: &'a [&'a str],
178
179    /// Describes a fixed amount to charge for shipping.
180    ///
181    /// Must be present if type is `fixed_amount`.
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub fixed_amount: Option<CreateShippingRateFixedAmount>,
184
185    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
186    ///
187    /// This can be useful for storing additional information about the object in a structured format.
188    /// Individual keys can be unset by posting an empty value to them.
189    /// All keys can be unset by posting an empty value to `metadata`.
190    #[serde(skip_serializing_if = "Option::is_none")]
191    pub metadata: Option<Metadata>,
192
193    /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes.
194    ///
195    /// One of `inclusive`, `exclusive`, or `unspecified`.
196    #[serde(skip_serializing_if = "Option::is_none")]
197    pub tax_behavior: Option<ShippingRateTaxBehavior>,
198
199    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
200    ///
201    /// The Shipping tax code is `txcd_92010001`.
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub tax_code: Option<TaxCodeId>,
204
205    /// The type of calculation to use on the shipping rate.
206    ///
207    /// Can only be `fixed_amount` for now.
208    #[serde(rename = "type")]
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub type_: Option<ShippingRateType>,
211}
212
213impl<'a> CreateShippingRate<'a> {
214    pub fn new(display_name: &'a str) -> Self {
215        CreateShippingRate {
216            delivery_estimate: Default::default(),
217            display_name,
218            expand: Default::default(),
219            fixed_amount: Default::default(),
220            metadata: Default::default(),
221            tax_behavior: Default::default(),
222            tax_code: Default::default(),
223            type_: Default::default(),
224        }
225    }
226}
227
228/// The parameters for `ShippingRate::list`.
229#[derive(Clone, Debug, Serialize, Default)]
230pub struct ListShippingRates<'a> {
231    /// Only return shipping rates that are active or inactive.
232    #[serde(skip_serializing_if = "Option::is_none")]
233    pub active: Option<bool>,
234
235    /// A filter on the list, based on the object `created` field.
236    ///
237    /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options.
238    #[serde(skip_serializing_if = "Option::is_none")]
239    pub created: Option<RangeQuery<Timestamp>>,
240
241    /// Only return shipping rates for the given currency.
242    #[serde(skip_serializing_if = "Option::is_none")]
243    pub currency: Option<Currency>,
244
245    /// A cursor for use in pagination.
246    ///
247    /// `ending_before` is an object ID that defines your place in the list.
248    /// 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.
249    #[serde(skip_serializing_if = "Option::is_none")]
250    pub ending_before: Option<ShippingRateId>,
251
252    /// Specifies which fields in the response should be expanded.
253    #[serde(skip_serializing_if = "Expand::is_empty")]
254    pub expand: &'a [&'a str],
255
256    /// A limit on the number of objects to be returned.
257    ///
258    /// Limit can range between 1 and 100, and the default is 10.
259    #[serde(skip_serializing_if = "Option::is_none")]
260    pub limit: Option<u64>,
261
262    /// A cursor for use in pagination.
263    ///
264    /// `starting_after` is an object ID that defines your place in the list.
265    /// 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.
266    #[serde(skip_serializing_if = "Option::is_none")]
267    pub starting_after: Option<ShippingRateId>,
268}
269
270impl<'a> ListShippingRates<'a> {
271    pub fn new() -> Self {
272        ListShippingRates {
273            active: Default::default(),
274            created: Default::default(),
275            currency: Default::default(),
276            ending_before: Default::default(),
277            expand: Default::default(),
278            limit: Default::default(),
279            starting_after: Default::default(),
280        }
281    }
282}
283impl Paginable for ListShippingRates<'_> {
284    type O = ShippingRate;
285    fn set_last(&mut self, item: Self::O) {
286        self.starting_after = Some(item.id());
287    }
288}
289/// The parameters for `ShippingRate::update`.
290#[derive(Clone, Debug, Serialize, Default)]
291pub struct UpdateShippingRate<'a> {
292    /// Whether the shipping rate can be used for new purchases.
293    ///
294    /// Defaults to `true`.
295    #[serde(skip_serializing_if = "Option::is_none")]
296    pub active: Option<bool>,
297
298    /// Specifies which fields in the response should be expanded.
299    #[serde(skip_serializing_if = "Expand::is_empty")]
300    pub expand: &'a [&'a str],
301
302    /// Describes a fixed amount to charge for shipping.
303    ///
304    /// Must be present if type is `fixed_amount`.
305    #[serde(skip_serializing_if = "Option::is_none")]
306    pub fixed_amount: Option<UpdateShippingRateFixedAmount>,
307
308    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
309    ///
310    /// This can be useful for storing additional information about the object in a structured format.
311    /// Individual keys can be unset by posting an empty value to them.
312    /// All keys can be unset by posting an empty value to `metadata`.
313    #[serde(skip_serializing_if = "Option::is_none")]
314    pub metadata: Option<Metadata>,
315
316    /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes.
317    ///
318    /// One of `inclusive`, `exclusive`, or `unspecified`.
319    #[serde(skip_serializing_if = "Option::is_none")]
320    pub tax_behavior: Option<ShippingRateTaxBehavior>,
321}
322
323impl<'a> UpdateShippingRate<'a> {
324    pub fn new() -> Self {
325        UpdateShippingRate {
326            active: Default::default(),
327            expand: Default::default(),
328            fixed_amount: Default::default(),
329            metadata: Default::default(),
330            tax_behavior: Default::default(),
331        }
332    }
333}
334
335#[derive(Clone, Debug, Default, Deserialize, Serialize)]
336pub struct CreateShippingRateDeliveryEstimate {
337    /// The upper bound of the estimated range.
338    ///
339    /// If empty, represents no upper bound i.e., infinite.
340    #[serde(skip_serializing_if = "Option::is_none")]
341    pub maximum: Option<CreateShippingRateDeliveryEstimateMaximum>,
342
343    /// The lower bound of the estimated range.
344    ///
345    /// If empty, represents no lower bound.
346    #[serde(skip_serializing_if = "Option::is_none")]
347    pub minimum: Option<CreateShippingRateDeliveryEstimateMinimum>,
348}
349
350#[derive(Clone, Debug, Default, Deserialize, Serialize)]
351pub struct CreateShippingRateFixedAmount {
352    /// A non-negative integer in cents representing how much to charge.
353    pub amount: i64,
354
355    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
356    ///
357    /// Must be a [supported currency](https://stripe.com/docs/currencies).
358    pub currency: Currency,
359
360    /// Shipping rates defined in each available currency option.
361    ///
362    /// 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).
363    #[serde(skip_serializing_if = "Option::is_none")]
364    pub currency_options: Option<CurrencyMap<CreateShippingRateFixedAmountCurrencyOptions>>,
365}
366
367#[derive(Clone, Debug, Default, Deserialize, Serialize)]
368pub struct UpdateShippingRateFixedAmount {
369    /// Shipping rates defined in each available currency option.
370    ///
371    /// 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).
372    #[serde(skip_serializing_if = "Option::is_none")]
373    pub currency_options: Option<CurrencyMap<UpdateShippingRateFixedAmountCurrencyOptions>>,
374}
375
376#[derive(Clone, Debug, Default, Deserialize, Serialize)]
377pub struct CreateShippingRateDeliveryEstimateMaximum {
378    /// A unit of time.
379    pub unit: CreateShippingRateDeliveryEstimateMaximumUnit,
380
381    /// Must be greater than 0.
382    pub value: i64,
383}
384
385#[derive(Clone, Debug, Default, Deserialize, Serialize)]
386pub struct CreateShippingRateDeliveryEstimateMinimum {
387    /// A unit of time.
388    pub unit: CreateShippingRateDeliveryEstimateMinimumUnit,
389
390    /// Must be greater than 0.
391    pub value: i64,
392}
393
394#[derive(Clone, Debug, Default, Deserialize, Serialize)]
395pub struct CreateShippingRateFixedAmountCurrencyOptions {
396    /// A non-negative integer in cents representing how much to charge.
397    pub amount: i64,
398
399    /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes.
400    ///
401    /// One of `inclusive`, `exclusive`, or `unspecified`.
402    #[serde(skip_serializing_if = "Option::is_none")]
403    pub tax_behavior: Option<CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior>,
404}
405
406#[derive(Clone, Debug, Default, Deserialize, Serialize)]
407pub struct UpdateShippingRateFixedAmountCurrencyOptions {
408    /// A non-negative integer in cents representing how much to charge.
409    #[serde(skip_serializing_if = "Option::is_none")]
410    pub amount: Option<i64>,
411
412    /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes.
413    ///
414    /// One of `inclusive`, `exclusive`, or `unspecified`.
415    #[serde(skip_serializing_if = "Option::is_none")]
416    pub tax_behavior: Option<UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior>,
417}
418
419/// An enum representing the possible values of an `CreateShippingRateDeliveryEstimateMaximum`'s `unit` field.
420#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
421#[serde(rename_all = "snake_case")]
422pub enum CreateShippingRateDeliveryEstimateMaximumUnit {
423    BusinessDay,
424    Day,
425    Hour,
426    Month,
427    Week,
428}
429
430impl CreateShippingRateDeliveryEstimateMaximumUnit {
431    pub fn as_str(self) -> &'static str {
432        match self {
433            CreateShippingRateDeliveryEstimateMaximumUnit::BusinessDay => "business_day",
434            CreateShippingRateDeliveryEstimateMaximumUnit::Day => "day",
435            CreateShippingRateDeliveryEstimateMaximumUnit::Hour => "hour",
436            CreateShippingRateDeliveryEstimateMaximumUnit::Month => "month",
437            CreateShippingRateDeliveryEstimateMaximumUnit::Week => "week",
438        }
439    }
440}
441
442impl AsRef<str> for CreateShippingRateDeliveryEstimateMaximumUnit {
443    fn as_ref(&self) -> &str {
444        self.as_str()
445    }
446}
447
448impl std::fmt::Display for CreateShippingRateDeliveryEstimateMaximumUnit {
449    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
450        self.as_str().fmt(f)
451    }
452}
453impl std::default::Default for CreateShippingRateDeliveryEstimateMaximumUnit {
454    fn default() -> Self {
455        Self::BusinessDay
456    }
457}
458
459/// An enum representing the possible values of an `CreateShippingRateDeliveryEstimateMinimum`'s `unit` field.
460#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
461#[serde(rename_all = "snake_case")]
462pub enum CreateShippingRateDeliveryEstimateMinimumUnit {
463    BusinessDay,
464    Day,
465    Hour,
466    Month,
467    Week,
468}
469
470impl CreateShippingRateDeliveryEstimateMinimumUnit {
471    pub fn as_str(self) -> &'static str {
472        match self {
473            CreateShippingRateDeliveryEstimateMinimumUnit::BusinessDay => "business_day",
474            CreateShippingRateDeliveryEstimateMinimumUnit::Day => "day",
475            CreateShippingRateDeliveryEstimateMinimumUnit::Hour => "hour",
476            CreateShippingRateDeliveryEstimateMinimumUnit::Month => "month",
477            CreateShippingRateDeliveryEstimateMinimumUnit::Week => "week",
478        }
479    }
480}
481
482impl AsRef<str> for CreateShippingRateDeliveryEstimateMinimumUnit {
483    fn as_ref(&self) -> &str {
484        self.as_str()
485    }
486}
487
488impl std::fmt::Display for CreateShippingRateDeliveryEstimateMinimumUnit {
489    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
490        self.as_str().fmt(f)
491    }
492}
493impl std::default::Default for CreateShippingRateDeliveryEstimateMinimumUnit {
494    fn default() -> Self {
495        Self::BusinessDay
496    }
497}
498
499/// An enum representing the possible values of an `CreateShippingRateFixedAmountCurrencyOptions`'s `tax_behavior` field.
500#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
501#[serde(rename_all = "snake_case")]
502pub enum CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
503    Exclusive,
504    Inclusive,
505    Unspecified,
506}
507
508impl CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
509    pub fn as_str(self) -> &'static str {
510        match self {
511            CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior::Exclusive => "exclusive",
512            CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior::Inclusive => "inclusive",
513            CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior::Unspecified => "unspecified",
514        }
515    }
516}
517
518impl AsRef<str> for CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
519    fn as_ref(&self) -> &str {
520        self.as_str()
521    }
522}
523
524impl std::fmt::Display for CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
525    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
526        self.as_str().fmt(f)
527    }
528}
529impl std::default::Default for CreateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
530    fn default() -> Self {
531        Self::Exclusive
532    }
533}
534
535/// An enum representing the possible values of an `ShippingRateCurrencyOption`'s `tax_behavior` field.
536#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
537#[serde(rename_all = "snake_case")]
538pub enum ShippingRateCurrencyOptionTaxBehavior {
539    Exclusive,
540    Inclusive,
541    Unspecified,
542}
543
544impl ShippingRateCurrencyOptionTaxBehavior {
545    pub fn as_str(self) -> &'static str {
546        match self {
547            ShippingRateCurrencyOptionTaxBehavior::Exclusive => "exclusive",
548            ShippingRateCurrencyOptionTaxBehavior::Inclusive => "inclusive",
549            ShippingRateCurrencyOptionTaxBehavior::Unspecified => "unspecified",
550        }
551    }
552}
553
554impl AsRef<str> for ShippingRateCurrencyOptionTaxBehavior {
555    fn as_ref(&self) -> &str {
556        self.as_str()
557    }
558}
559
560impl std::fmt::Display for ShippingRateCurrencyOptionTaxBehavior {
561    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
562        self.as_str().fmt(f)
563    }
564}
565impl std::default::Default for ShippingRateCurrencyOptionTaxBehavior {
566    fn default() -> Self {
567        Self::Exclusive
568    }
569}
570
571/// An enum representing the possible values of an `ShippingRateDeliveryEstimateBound`'s `unit` field.
572#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
573#[serde(rename_all = "snake_case")]
574pub enum ShippingRateDeliveryEstimateBoundUnit {
575    BusinessDay,
576    Day,
577    Hour,
578    Month,
579    Week,
580}
581
582impl ShippingRateDeliveryEstimateBoundUnit {
583    pub fn as_str(self) -> &'static str {
584        match self {
585            ShippingRateDeliveryEstimateBoundUnit::BusinessDay => "business_day",
586            ShippingRateDeliveryEstimateBoundUnit::Day => "day",
587            ShippingRateDeliveryEstimateBoundUnit::Hour => "hour",
588            ShippingRateDeliveryEstimateBoundUnit::Month => "month",
589            ShippingRateDeliveryEstimateBoundUnit::Week => "week",
590        }
591    }
592}
593
594impl AsRef<str> for ShippingRateDeliveryEstimateBoundUnit {
595    fn as_ref(&self) -> &str {
596        self.as_str()
597    }
598}
599
600impl std::fmt::Display for ShippingRateDeliveryEstimateBoundUnit {
601    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
602        self.as_str().fmt(f)
603    }
604}
605impl std::default::Default for ShippingRateDeliveryEstimateBoundUnit {
606    fn default() -> Self {
607        Self::BusinessDay
608    }
609}
610
611/// An enum representing the possible values of an `ShippingRate`'s `tax_behavior` field.
612#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
613#[serde(rename_all = "snake_case")]
614pub enum ShippingRateTaxBehavior {
615    Exclusive,
616    Inclusive,
617    Unspecified,
618}
619
620impl ShippingRateTaxBehavior {
621    pub fn as_str(self) -> &'static str {
622        match self {
623            ShippingRateTaxBehavior::Exclusive => "exclusive",
624            ShippingRateTaxBehavior::Inclusive => "inclusive",
625            ShippingRateTaxBehavior::Unspecified => "unspecified",
626        }
627    }
628}
629
630impl AsRef<str> for ShippingRateTaxBehavior {
631    fn as_ref(&self) -> &str {
632        self.as_str()
633    }
634}
635
636impl std::fmt::Display for ShippingRateTaxBehavior {
637    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
638        self.as_str().fmt(f)
639    }
640}
641impl std::default::Default for ShippingRateTaxBehavior {
642    fn default() -> Self {
643        Self::Exclusive
644    }
645}
646
647/// An enum representing the possible values of an `ShippingRate`'s `type` field.
648#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
649#[serde(rename_all = "snake_case")]
650pub enum ShippingRateType {
651    FixedAmount,
652}
653
654impl ShippingRateType {
655    pub fn as_str(self) -> &'static str {
656        match self {
657            ShippingRateType::FixedAmount => "fixed_amount",
658        }
659    }
660}
661
662impl AsRef<str> for ShippingRateType {
663    fn as_ref(&self) -> &str {
664        self.as_str()
665    }
666}
667
668impl std::fmt::Display for ShippingRateType {
669    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
670        self.as_str().fmt(f)
671    }
672}
673impl std::default::Default for ShippingRateType {
674    fn default() -> Self {
675        Self::FixedAmount
676    }
677}
678
679/// An enum representing the possible values of an `UpdateShippingRateFixedAmountCurrencyOptions`'s `tax_behavior` field.
680#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
681#[serde(rename_all = "snake_case")]
682pub enum UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
683    Exclusive,
684    Inclusive,
685    Unspecified,
686}
687
688impl UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
689    pub fn as_str(self) -> &'static str {
690        match self {
691            UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior::Exclusive => "exclusive",
692            UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior::Inclusive => "inclusive",
693            UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior::Unspecified => "unspecified",
694        }
695    }
696}
697
698impl AsRef<str> for UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
699    fn as_ref(&self) -> &str {
700        self.as_str()
701    }
702}
703
704impl std::fmt::Display for UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
705    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
706        self.as_str().fmt(f)
707    }
708}
709impl std::default::Default for UpdateShippingRateFixedAmountCurrencyOptionsTaxBehavior {
710    fn default() -> Self {
711        Self::Exclusive
712    }
713}