stripe_misc/tax_settings/
requests.rs1use 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#[derive(Clone, Debug, serde::Serialize)]
17pub struct RetrieveForMyAccountTaxSettings {
18 inner: RetrieveForMyAccountTaxSettingsBuilder,
19}
20impl RetrieveForMyAccountTaxSettings {
21 pub fn new() -> Self {
23 Self { inner: RetrieveForMyAccountTaxSettingsBuilder::new() }
24 }
25 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 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 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#[derive(Clone, Debug, serde::Serialize)]
77pub struct UpdateTaxSettingsDefaults {
78 #[serde(skip_serializing_if = "Option::is_none")]
82 pub tax_behavior: Option<UpdateTaxSettingsDefaultsTaxBehavior>,
83 #[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#[derive(Clone, Eq, PartialEq)]
101#[non_exhaustive]
102pub enum UpdateTaxSettingsDefaultsTaxBehavior {
103 Exclusive,
104 Inclusive,
105 InferredByCurrency,
106 Unknown(String),
108}
109impl UpdateTaxSettingsDefaultsTaxBehavior {
110 pub fn as_str(&self) -> &str {
111 use UpdateTaxSettingsDefaultsTaxBehavior::*;
112 match self {
113 Exclusive => "exclusive",
114 Inclusive => "inclusive",
115 InferredByCurrency => "inferred_by_currency",
116 Unknown(v) => v,
117 }
118 }
119}
120
121impl std::str::FromStr for UpdateTaxSettingsDefaultsTaxBehavior {
122 type Err = std::convert::Infallible;
123 fn from_str(s: &str) -> Result<Self, Self::Err> {
124 use UpdateTaxSettingsDefaultsTaxBehavior::*;
125 match s {
126 "exclusive" => Ok(Exclusive),
127 "inclusive" => Ok(Inclusive),
128 "inferred_by_currency" => Ok(InferredByCurrency),
129 v => {
130 tracing::warn!(
131 "Unknown value '{}' for enum '{}'",
132 v,
133 "UpdateTaxSettingsDefaultsTaxBehavior"
134 );
135 Ok(Unknown(v.to_owned()))
136 }
137 }
138 }
139}
140impl std::fmt::Display for UpdateTaxSettingsDefaultsTaxBehavior {
141 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
142 f.write_str(self.as_str())
143 }
144}
145
146impl std::fmt::Debug for UpdateTaxSettingsDefaultsTaxBehavior {
147 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
148 f.write_str(self.as_str())
149 }
150}
151impl serde::Serialize for UpdateTaxSettingsDefaultsTaxBehavior {
152 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
153 where
154 S: serde::Serializer,
155 {
156 serializer.serialize_str(self.as_str())
157 }
158}
159#[cfg(feature = "deserialize")]
160impl<'de> serde::Deserialize<'de> for UpdateTaxSettingsDefaultsTaxBehavior {
161 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
162 use std::str::FromStr;
163 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
164 Ok(Self::from_str(&s).expect("infallible"))
165 }
166}
167#[derive(Clone, Debug, serde::Serialize)]
169pub struct UpdateTaxSettingsHeadOffice {
170 pub address: UpdateTaxSettingsHeadOfficeAddress,
172}
173impl UpdateTaxSettingsHeadOffice {
174 pub fn new(address: impl Into<UpdateTaxSettingsHeadOfficeAddress>) -> Self {
175 Self { address: address.into() }
176 }
177}
178#[derive(Clone, Debug, serde::Serialize)]
180pub struct UpdateTaxSettingsHeadOfficeAddress {
181 #[serde(skip_serializing_if = "Option::is_none")]
183 pub city: Option<String>,
184 #[serde(skip_serializing_if = "Option::is_none")]
186 pub country: Option<String>,
187 #[serde(skip_serializing_if = "Option::is_none")]
189 pub line1: Option<String>,
190 #[serde(skip_serializing_if = "Option::is_none")]
192 pub line2: Option<String>,
193 #[serde(skip_serializing_if = "Option::is_none")]
195 pub postal_code: Option<String>,
196 #[serde(skip_serializing_if = "Option::is_none")]
198 pub state: Option<String>,
199}
200impl UpdateTaxSettingsHeadOfficeAddress {
201 pub fn new() -> Self {
202 Self { city: None, country: None, line1: None, line2: None, postal_code: None, state: None }
203 }
204}
205impl Default for UpdateTaxSettingsHeadOfficeAddress {
206 fn default() -> Self {
207 Self::new()
208 }
209}
210#[derive(Clone, Debug, serde::Serialize)]
213pub struct UpdateTaxSettings {
214 inner: UpdateTaxSettingsBuilder,
215}
216impl UpdateTaxSettings {
217 pub fn new() -> Self {
219 Self { inner: UpdateTaxSettingsBuilder::new() }
220 }
221 pub fn defaults(mut self, defaults: impl Into<UpdateTaxSettingsDefaults>) -> Self {
223 self.inner.defaults = Some(defaults.into());
224 self
225 }
226 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
228 self.inner.expand = Some(expand.into());
229 self
230 }
231 pub fn head_office(mut self, head_office: impl Into<UpdateTaxSettingsHeadOffice>) -> Self {
233 self.inner.head_office = Some(head_office.into());
234 self
235 }
236}
237impl Default for UpdateTaxSettings {
238 fn default() -> Self {
239 Self::new()
240 }
241}
242impl UpdateTaxSettings {
243 pub async fn send<C: StripeClient>(
245 &self,
246 client: &C,
247 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
248 self.customize().send(client).await
249 }
250
251 pub fn send_blocking<C: StripeBlockingClient>(
253 &self,
254 client: &C,
255 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
256 self.customize().send_blocking(client)
257 }
258}
259
260impl StripeRequest for UpdateTaxSettings {
261 type Output = stripe_misc::TaxSettings;
262
263 fn build(&self) -> RequestBuilder {
264 RequestBuilder::new(StripeMethod::Post, "/tax/settings").form(&self.inner)
265 }
266}