stripe_misc/tax_settings/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct RetrieveForMyAccountTaxSettingsBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    expand: Option<Vec<String>>,
9}
10impl RetrieveForMyAccountTaxSettingsBuilder {
11    fn new() -> Self {
12        Self { expand: None }
13    }
14}
15/// Retrieves Tax `Settings` for a merchant.
16#[derive(Clone, Debug, serde::Serialize)]
17pub struct RetrieveForMyAccountTaxSettings {
18    inner: RetrieveForMyAccountTaxSettingsBuilder,
19}
20impl RetrieveForMyAccountTaxSettings {
21    /// Construct a new `RetrieveForMyAccountTaxSettings`.
22    pub fn new() -> Self {
23        Self { inner: RetrieveForMyAccountTaxSettingsBuilder::new() }
24    }
25    /// Specifies which fields in the response should be expanded.
26    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
27        self.inner.expand = Some(expand.into());
28        self
29    }
30}
31impl Default for RetrieveForMyAccountTaxSettings {
32    fn default() -> Self {
33        Self::new()
34    }
35}
36impl RetrieveForMyAccountTaxSettings {
37    /// Send the request and return the deserialized response.
38    pub async fn send<C: StripeClient>(
39        &self,
40        client: &C,
41    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
42        self.customize().send(client).await
43    }
44
45    /// Send the request and return the deserialized response, blocking until completion.
46    pub fn send_blocking<C: StripeBlockingClient>(
47        &self,
48        client: &C,
49    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
50        self.customize().send_blocking(client)
51    }
52}
53
54impl StripeRequest for RetrieveForMyAccountTaxSettings {
55    type Output = stripe_misc::TaxSettings;
56
57    fn build(&self) -> RequestBuilder {
58        RequestBuilder::new(StripeMethod::Get, "/tax/settings").query(&self.inner)
59    }
60}
61#[derive(Clone, Debug, serde::Serialize)]
62struct UpdateTaxSettingsBuilder {
63    #[serde(skip_serializing_if = "Option::is_none")]
64    defaults: Option<UpdateTaxSettingsDefaults>,
65    #[serde(skip_serializing_if = "Option::is_none")]
66    expand: Option<Vec<String>>,
67    #[serde(skip_serializing_if = "Option::is_none")]
68    head_office: Option<UpdateTaxSettingsHeadOffice>,
69}
70impl UpdateTaxSettingsBuilder {
71    fn new() -> Self {
72        Self { defaults: None, expand: None, head_office: None }
73    }
74}
75/// Default configuration to be used on Stripe Tax calculations.
76#[derive(Clone, Debug, serde::Serialize)]
77pub struct UpdateTaxSettingsDefaults {
78    /// Specifies the default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) to be used when the item's price has unspecified tax behavior.
79    /// One of inclusive, exclusive, or inferred_by_currency.
80    /// Once specified, it cannot be changed back to null.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub tax_behavior: Option<UpdateTaxSettingsDefaultsTaxBehavior>,
83    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub tax_code: Option<String>,
86}
87impl UpdateTaxSettingsDefaults {
88    pub fn new() -> Self {
89        Self { tax_behavior: None, tax_code: None }
90    }
91}
92impl Default for UpdateTaxSettingsDefaults {
93    fn default() -> Self {
94        Self::new()
95    }
96}
97/// Specifies the default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) to be used when the item's price has unspecified tax behavior.
98/// One of inclusive, exclusive, or inferred_by_currency.
99/// Once specified, it cannot be changed back to null.
100#[derive(Copy, Clone, Eq, PartialEq)]
101pub enum UpdateTaxSettingsDefaultsTaxBehavior {
102    Exclusive,
103    Inclusive,
104    InferredByCurrency,
105}
106impl UpdateTaxSettingsDefaultsTaxBehavior {
107    pub fn as_str(self) -> &'static str {
108        use UpdateTaxSettingsDefaultsTaxBehavior::*;
109        match self {
110            Exclusive => "exclusive",
111            Inclusive => "inclusive",
112            InferredByCurrency => "inferred_by_currency",
113        }
114    }
115}
116
117impl std::str::FromStr for UpdateTaxSettingsDefaultsTaxBehavior {
118    type Err = stripe_types::StripeParseError;
119    fn from_str(s: &str) -> Result<Self, Self::Err> {
120        use UpdateTaxSettingsDefaultsTaxBehavior::*;
121        match s {
122            "exclusive" => Ok(Exclusive),
123            "inclusive" => Ok(Inclusive),
124            "inferred_by_currency" => Ok(InferredByCurrency),
125            _ => Err(stripe_types::StripeParseError),
126        }
127    }
128}
129impl std::fmt::Display for UpdateTaxSettingsDefaultsTaxBehavior {
130    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
131        f.write_str(self.as_str())
132    }
133}
134
135impl std::fmt::Debug for UpdateTaxSettingsDefaultsTaxBehavior {
136    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
137        f.write_str(self.as_str())
138    }
139}
140impl serde::Serialize for UpdateTaxSettingsDefaultsTaxBehavior {
141    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
142    where
143        S: serde::Serializer,
144    {
145        serializer.serialize_str(self.as_str())
146    }
147}
148#[cfg(feature = "deserialize")]
149impl<'de> serde::Deserialize<'de> for UpdateTaxSettingsDefaultsTaxBehavior {
150    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
151        use std::str::FromStr;
152        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
153        Self::from_str(&s).map_err(|_| {
154            serde::de::Error::custom("Unknown value for UpdateTaxSettingsDefaultsTaxBehavior")
155        })
156    }
157}
158/// The place where your business is located.
159#[derive(Clone, Debug, serde::Serialize)]
160pub struct UpdateTaxSettingsHeadOffice {
161    /// The location of the business for tax purposes.
162    pub address: UpdateTaxSettingsHeadOfficeAddress,
163}
164impl UpdateTaxSettingsHeadOffice {
165    pub fn new(address: impl Into<UpdateTaxSettingsHeadOfficeAddress>) -> Self {
166        Self { address: address.into() }
167    }
168}
169/// The location of the business for tax purposes.
170#[derive(Clone, Debug, serde::Serialize)]
171pub struct UpdateTaxSettingsHeadOfficeAddress {
172    /// City, district, suburb, town, or village.
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub city: Option<String>,
175    /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
176    #[serde(skip_serializing_if = "Option::is_none")]
177    pub country: Option<String>,
178    /// Address line 1, such as the street, PO Box, or company name.
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub line1: Option<String>,
181    /// Address line 2, such as the apartment, suite, unit, or building.
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub line2: Option<String>,
184    /// ZIP or postal code.
185    #[serde(skip_serializing_if = "Option::is_none")]
186    pub postal_code: Option<String>,
187    /// State/province as an [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) subdivision code, without country prefix, such as "NY" or "TX".
188    #[serde(skip_serializing_if = "Option::is_none")]
189    pub state: Option<String>,
190}
191impl UpdateTaxSettingsHeadOfficeAddress {
192    pub fn new() -> Self {
193        Self { city: None, country: None, line1: None, line2: None, postal_code: None, state: None }
194    }
195}
196impl Default for UpdateTaxSettingsHeadOfficeAddress {
197    fn default() -> Self {
198        Self::new()
199    }
200}
201/// Updates Tax `Settings` parameters used in tax calculations.
202/// All parameters are editable but none can be removed once set.
203#[derive(Clone, Debug, serde::Serialize)]
204pub struct UpdateTaxSettings {
205    inner: UpdateTaxSettingsBuilder,
206}
207impl UpdateTaxSettings {
208    /// Construct a new `UpdateTaxSettings`.
209    pub fn new() -> Self {
210        Self { inner: UpdateTaxSettingsBuilder::new() }
211    }
212    /// Default configuration to be used on Stripe Tax calculations.
213    pub fn defaults(mut self, defaults: impl Into<UpdateTaxSettingsDefaults>) -> Self {
214        self.inner.defaults = Some(defaults.into());
215        self
216    }
217    /// Specifies which fields in the response should be expanded.
218    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
219        self.inner.expand = Some(expand.into());
220        self
221    }
222    /// The place where your business is located.
223    pub fn head_office(mut self, head_office: impl Into<UpdateTaxSettingsHeadOffice>) -> Self {
224        self.inner.head_office = Some(head_office.into());
225        self
226    }
227}
228impl Default for UpdateTaxSettings {
229    fn default() -> Self {
230        Self::new()
231    }
232}
233impl UpdateTaxSettings {
234    /// Send the request and return the deserialized response.
235    pub async fn send<C: StripeClient>(
236        &self,
237        client: &C,
238    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
239        self.customize().send(client).await
240    }
241
242    /// Send the request and return the deserialized response, blocking until completion.
243    pub fn send_blocking<C: StripeBlockingClient>(
244        &self,
245        client: &C,
246    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
247        self.customize().send_blocking(client)
248    }
249}
250
251impl StripeRequest for UpdateTaxSettings {
252    type Output = stripe_misc::TaxSettings;
253
254    fn build(&self) -> RequestBuilder {
255        RequestBuilder::new(StripeMethod::Post, "/tax/settings").form(&self.inner)
256    }
257}