stripe/resources/generated/
tax_code.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::TaxCodeId;
7use crate::params::{Expand, List, Object, Paginable};
8use serde::{Deserialize, Serialize};
9
10/// The resource representing a Stripe "TaxProductResourceTaxCode".
11///
12/// For more details see <https://stripe.com/docs/api/tax_codes/object>
13#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct TaxCode {
15    /// Unique identifier for the object.
16    pub id: TaxCodeId,
17
18    /// A detailed description of which types of products the tax code represents.
19    pub description: String,
20
21    /// A short name for the tax code.
22    pub name: String,
23}
24
25impl TaxCode {
26    /// A list of [all tax codes available](https://stripe.com/docs/tax/tax-categories) to add to Products in order to allow specific tax calculations.
27    pub fn list(client: &Client, params: &ListTaxCodes<'_>) -> Response<List<TaxCode>> {
28        client.get_query("/tax_codes", params)
29    }
30
31    /// Retrieves the details of an existing tax code.
32    ///
33    /// Supply the unique tax code ID and Stripe will return the corresponding tax code information.
34    pub fn retrieve(client: &Client, id: &TaxCodeId, expand: &[&str]) -> Response<TaxCode> {
35        client.get_query(&format!("/tax_codes/{}", id), Expand { expand })
36    }
37}
38
39impl Object for TaxCode {
40    type Id = TaxCodeId;
41    fn id(&self) -> Self::Id {
42        self.id.clone()
43    }
44    fn object(&self) -> &'static str {
45        "tax_code"
46    }
47}
48
49/// The parameters for `TaxCode::list`.
50#[derive(Clone, Debug, Serialize, Default)]
51pub struct ListTaxCodes<'a> {
52    /// A cursor for use in pagination.
53    ///
54    /// `ending_before` is an object ID that defines your place in the list.
55    /// 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.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub ending_before: Option<TaxCodeId>,
58
59    /// Specifies which fields in the response should be expanded.
60    #[serde(skip_serializing_if = "Expand::is_empty")]
61    pub expand: &'a [&'a str],
62
63    /// A limit on the number of objects to be returned.
64    ///
65    /// Limit can range between 1 and 100, and the default is 10.
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub limit: Option<u64>,
68
69    /// A cursor for use in pagination.
70    ///
71    /// `starting_after` is an object ID that defines your place in the list.
72    /// 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.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub starting_after: Option<TaxCodeId>,
75}
76
77impl<'a> ListTaxCodes<'a> {
78    pub fn new() -> Self {
79        ListTaxCodes {
80            ending_before: Default::default(),
81            expand: Default::default(),
82            limit: Default::default(),
83            starting_after: Default::default(),
84        }
85    }
86}
87impl Paginable for ListTaxCodes<'_> {
88    type O = TaxCode;
89    fn set_last(&mut self, item: Self::O) {
90        self.starting_after = Some(item.id());
91    }
92}