1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct BillingBillResourceInvoicingTaxesTax {
5 pub amount: i64,
7 pub tax_behavior: BillingBillResourceInvoicingTaxesTaxTaxBehavior,
9 pub tax_rate_details: Option<stripe_shared::BillingBillResourceInvoicingTaxesTaxRateDetails>,
11 pub taxability_reason: BillingBillResourceInvoicingTaxesTaxTaxabilityReason,
14 pub taxable_amount: Option<i64>,
16 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
18 pub type_: BillingBillResourceInvoicingTaxesTaxType,
19}
20#[doc(hidden)]
21pub struct BillingBillResourceInvoicingTaxesTaxBuilder {
22 amount: Option<i64>,
23 tax_behavior: Option<BillingBillResourceInvoicingTaxesTaxTaxBehavior>,
24 tax_rate_details:
25 Option<Option<stripe_shared::BillingBillResourceInvoicingTaxesTaxRateDetails>>,
26 taxability_reason: Option<BillingBillResourceInvoicingTaxesTaxTaxabilityReason>,
27 taxable_amount: Option<Option<i64>>,
28 type_: Option<BillingBillResourceInvoicingTaxesTaxType>,
29}
30
31#[allow(
32 unused_variables,
33 irrefutable_let_patterns,
34 clippy::let_unit_value,
35 clippy::match_single_binding,
36 clippy::single_match
37)]
38const _: () = {
39 use miniserde::de::{Map, Visitor};
40 use miniserde::json::Value;
41 use miniserde::{Deserialize, Result, make_place};
42 use stripe_types::miniserde_helpers::FromValueOpt;
43 use stripe_types::{MapBuilder, ObjectDeser};
44
45 make_place!(Place);
46
47 impl Deserialize for BillingBillResourceInvoicingTaxesTax {
48 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
49 Place::new(out)
50 }
51 }
52
53 struct Builder<'a> {
54 out: &'a mut Option<BillingBillResourceInvoicingTaxesTax>,
55 builder: BillingBillResourceInvoicingTaxesTaxBuilder,
56 }
57
58 impl Visitor for Place<BillingBillResourceInvoicingTaxesTax> {
59 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
60 Ok(Box::new(Builder {
61 out: &mut self.out,
62 builder: BillingBillResourceInvoicingTaxesTaxBuilder::deser_default(),
63 }))
64 }
65 }
66
67 impl MapBuilder for BillingBillResourceInvoicingTaxesTaxBuilder {
68 type Out = BillingBillResourceInvoicingTaxesTax;
69 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
70 Ok(match k {
71 "amount" => Deserialize::begin(&mut self.amount),
72 "tax_behavior" => Deserialize::begin(&mut self.tax_behavior),
73 "tax_rate_details" => Deserialize::begin(&mut self.tax_rate_details),
74 "taxability_reason" => Deserialize::begin(&mut self.taxability_reason),
75 "taxable_amount" => Deserialize::begin(&mut self.taxable_amount),
76 "type" => Deserialize::begin(&mut self.type_),
77 _ => <dyn Visitor>::ignore(),
78 })
79 }
80
81 fn deser_default() -> Self {
82 Self {
83 amount: Deserialize::default(),
84 tax_behavior: Deserialize::default(),
85 tax_rate_details: Deserialize::default(),
86 taxability_reason: Deserialize::default(),
87 taxable_amount: Deserialize::default(),
88 type_: Deserialize::default(),
89 }
90 }
91
92 fn take_out(&mut self) -> Option<Self::Out> {
93 let (
94 Some(amount),
95 Some(tax_behavior),
96 Some(tax_rate_details),
97 Some(taxability_reason),
98 Some(taxable_amount),
99 Some(type_),
100 ) = (
101 self.amount,
102 self.tax_behavior.take(),
103 self.tax_rate_details.take(),
104 self.taxability_reason.take(),
105 self.taxable_amount,
106 self.type_.take(),
107 )
108 else {
109 return None;
110 };
111 Some(Self::Out {
112 amount,
113 tax_behavior,
114 tax_rate_details,
115 taxability_reason,
116 taxable_amount,
117 type_,
118 })
119 }
120 }
121
122 impl Map for Builder<'_> {
123 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
124 self.builder.key(k)
125 }
126
127 fn finish(&mut self) -> Result<()> {
128 *self.out = self.builder.take_out();
129 Ok(())
130 }
131 }
132
133 impl ObjectDeser for BillingBillResourceInvoicingTaxesTax {
134 type Builder = BillingBillResourceInvoicingTaxesTaxBuilder;
135 }
136
137 impl FromValueOpt for BillingBillResourceInvoicingTaxesTax {
138 fn from_value(v: Value) -> Option<Self> {
139 let Value::Object(obj) = v else {
140 return None;
141 };
142 let mut b = BillingBillResourceInvoicingTaxesTaxBuilder::deser_default();
143 for (k, v) in obj {
144 match k.as_str() {
145 "amount" => b.amount = FromValueOpt::from_value(v),
146 "tax_behavior" => b.tax_behavior = FromValueOpt::from_value(v),
147 "tax_rate_details" => b.tax_rate_details = FromValueOpt::from_value(v),
148 "taxability_reason" => b.taxability_reason = FromValueOpt::from_value(v),
149 "taxable_amount" => b.taxable_amount = FromValueOpt::from_value(v),
150 "type" => b.type_ = FromValueOpt::from_value(v),
151 _ => {}
152 }
153 }
154 b.take_out()
155 }
156 }
157};
158#[derive(Clone, Eq, PartialEq)]
160#[non_exhaustive]
161pub enum BillingBillResourceInvoicingTaxesTaxTaxBehavior {
162 Exclusive,
163 Inclusive,
164 Unknown(String),
166}
167impl BillingBillResourceInvoicingTaxesTaxTaxBehavior {
168 pub fn as_str(&self) -> &str {
169 use BillingBillResourceInvoicingTaxesTaxTaxBehavior::*;
170 match self {
171 Exclusive => "exclusive",
172 Inclusive => "inclusive",
173 Unknown(v) => v,
174 }
175 }
176}
177
178impl std::str::FromStr for BillingBillResourceInvoicingTaxesTaxTaxBehavior {
179 type Err = std::convert::Infallible;
180 fn from_str(s: &str) -> Result<Self, Self::Err> {
181 use BillingBillResourceInvoicingTaxesTaxTaxBehavior::*;
182 match s {
183 "exclusive" => Ok(Exclusive),
184 "inclusive" => Ok(Inclusive),
185 v => {
186 tracing::warn!(
187 "Unknown value '{}' for enum '{}'",
188 v,
189 "BillingBillResourceInvoicingTaxesTaxTaxBehavior"
190 );
191 Ok(Unknown(v.to_owned()))
192 }
193 }
194 }
195}
196impl std::fmt::Display for BillingBillResourceInvoicingTaxesTaxTaxBehavior {
197 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
198 f.write_str(self.as_str())
199 }
200}
201
202impl std::fmt::Debug for BillingBillResourceInvoicingTaxesTaxTaxBehavior {
203 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
204 f.write_str(self.as_str())
205 }
206}
207#[cfg(feature = "serialize")]
208impl serde::Serialize for BillingBillResourceInvoicingTaxesTaxTaxBehavior {
209 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
210 where
211 S: serde::Serializer,
212 {
213 serializer.serialize_str(self.as_str())
214 }
215}
216impl miniserde::Deserialize for BillingBillResourceInvoicingTaxesTaxTaxBehavior {
217 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
218 crate::Place::new(out)
219 }
220}
221
222impl miniserde::de::Visitor for crate::Place<BillingBillResourceInvoicingTaxesTaxTaxBehavior> {
223 fn string(&mut self, s: &str) -> miniserde::Result<()> {
224 use std::str::FromStr;
225 self.out =
226 Some(BillingBillResourceInvoicingTaxesTaxTaxBehavior::from_str(s).expect("infallible"));
227 Ok(())
228 }
229}
230
231stripe_types::impl_from_val_with_from_str!(BillingBillResourceInvoicingTaxesTaxTaxBehavior);
232#[cfg(feature = "deserialize")]
233impl<'de> serde::Deserialize<'de> for BillingBillResourceInvoicingTaxesTaxTaxBehavior {
234 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
235 use std::str::FromStr;
236 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
237 Ok(Self::from_str(&s).expect("infallible"))
238 }
239}
240#[derive(Clone, Eq, PartialEq)]
243#[non_exhaustive]
244pub enum BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
245 CustomerExempt,
246 NotAvailable,
247 NotCollecting,
248 NotSubjectToTax,
249 NotSupported,
250 PortionProductExempt,
251 PortionReducedRated,
252 PortionStandardRated,
253 ProductExempt,
254 ProductExemptHoliday,
255 ProportionallyRated,
256 ReducedRated,
257 ReverseCharge,
258 StandardRated,
259 TaxableBasisReduced,
260 ZeroRated,
261 Unknown(String),
263}
264impl BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
265 pub fn as_str(&self) -> &str {
266 use BillingBillResourceInvoicingTaxesTaxTaxabilityReason::*;
267 match self {
268 CustomerExempt => "customer_exempt",
269 NotAvailable => "not_available",
270 NotCollecting => "not_collecting",
271 NotSubjectToTax => "not_subject_to_tax",
272 NotSupported => "not_supported",
273 PortionProductExempt => "portion_product_exempt",
274 PortionReducedRated => "portion_reduced_rated",
275 PortionStandardRated => "portion_standard_rated",
276 ProductExempt => "product_exempt",
277 ProductExemptHoliday => "product_exempt_holiday",
278 ProportionallyRated => "proportionally_rated",
279 ReducedRated => "reduced_rated",
280 ReverseCharge => "reverse_charge",
281 StandardRated => "standard_rated",
282 TaxableBasisReduced => "taxable_basis_reduced",
283 ZeroRated => "zero_rated",
284 Unknown(v) => v,
285 }
286 }
287}
288
289impl std::str::FromStr for BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
290 type Err = std::convert::Infallible;
291 fn from_str(s: &str) -> Result<Self, Self::Err> {
292 use BillingBillResourceInvoicingTaxesTaxTaxabilityReason::*;
293 match s {
294 "customer_exempt" => Ok(CustomerExempt),
295 "not_available" => Ok(NotAvailable),
296 "not_collecting" => Ok(NotCollecting),
297 "not_subject_to_tax" => Ok(NotSubjectToTax),
298 "not_supported" => Ok(NotSupported),
299 "portion_product_exempt" => Ok(PortionProductExempt),
300 "portion_reduced_rated" => Ok(PortionReducedRated),
301 "portion_standard_rated" => Ok(PortionStandardRated),
302 "product_exempt" => Ok(ProductExempt),
303 "product_exempt_holiday" => Ok(ProductExemptHoliday),
304 "proportionally_rated" => Ok(ProportionallyRated),
305 "reduced_rated" => Ok(ReducedRated),
306 "reverse_charge" => Ok(ReverseCharge),
307 "standard_rated" => Ok(StandardRated),
308 "taxable_basis_reduced" => Ok(TaxableBasisReduced),
309 "zero_rated" => Ok(ZeroRated),
310 v => {
311 tracing::warn!(
312 "Unknown value '{}' for enum '{}'",
313 v,
314 "BillingBillResourceInvoicingTaxesTaxTaxabilityReason"
315 );
316 Ok(Unknown(v.to_owned()))
317 }
318 }
319 }
320}
321impl std::fmt::Display for BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
322 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
323 f.write_str(self.as_str())
324 }
325}
326
327impl std::fmt::Debug for BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
328 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
329 f.write_str(self.as_str())
330 }
331}
332#[cfg(feature = "serialize")]
333impl serde::Serialize for BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
334 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
335 where
336 S: serde::Serializer,
337 {
338 serializer.serialize_str(self.as_str())
339 }
340}
341impl miniserde::Deserialize for BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
342 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
343 crate::Place::new(out)
344 }
345}
346
347impl miniserde::de::Visitor for crate::Place<BillingBillResourceInvoicingTaxesTaxTaxabilityReason> {
348 fn string(&mut self, s: &str) -> miniserde::Result<()> {
349 use std::str::FromStr;
350 self.out = Some(
351 BillingBillResourceInvoicingTaxesTaxTaxabilityReason::from_str(s).expect("infallible"),
352 );
353 Ok(())
354 }
355}
356
357stripe_types::impl_from_val_with_from_str!(BillingBillResourceInvoicingTaxesTaxTaxabilityReason);
358#[cfg(feature = "deserialize")]
359impl<'de> serde::Deserialize<'de> for BillingBillResourceInvoicingTaxesTaxTaxabilityReason {
360 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
361 use std::str::FromStr;
362 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
363 Ok(Self::from_str(&s).expect("infallible"))
364 }
365}
366#[derive(Clone, Eq, PartialEq)]
368#[non_exhaustive]
369pub enum BillingBillResourceInvoicingTaxesTaxType {
370 TaxRateDetails,
371 Unknown(String),
373}
374impl BillingBillResourceInvoicingTaxesTaxType {
375 pub fn as_str(&self) -> &str {
376 use BillingBillResourceInvoicingTaxesTaxType::*;
377 match self {
378 TaxRateDetails => "tax_rate_details",
379 Unknown(v) => v,
380 }
381 }
382}
383
384impl std::str::FromStr for BillingBillResourceInvoicingTaxesTaxType {
385 type Err = std::convert::Infallible;
386 fn from_str(s: &str) -> Result<Self, Self::Err> {
387 use BillingBillResourceInvoicingTaxesTaxType::*;
388 match s {
389 "tax_rate_details" => Ok(TaxRateDetails),
390 v => {
391 tracing::warn!(
392 "Unknown value '{}' for enum '{}'",
393 v,
394 "BillingBillResourceInvoicingTaxesTaxType"
395 );
396 Ok(Unknown(v.to_owned()))
397 }
398 }
399 }
400}
401impl std::fmt::Display for BillingBillResourceInvoicingTaxesTaxType {
402 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
403 f.write_str(self.as_str())
404 }
405}
406
407impl std::fmt::Debug for BillingBillResourceInvoicingTaxesTaxType {
408 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
409 f.write_str(self.as_str())
410 }
411}
412#[cfg(feature = "serialize")]
413impl serde::Serialize for BillingBillResourceInvoicingTaxesTaxType {
414 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
415 where
416 S: serde::Serializer,
417 {
418 serializer.serialize_str(self.as_str())
419 }
420}
421impl miniserde::Deserialize for BillingBillResourceInvoicingTaxesTaxType {
422 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
423 crate::Place::new(out)
424 }
425}
426
427impl miniserde::de::Visitor for crate::Place<BillingBillResourceInvoicingTaxesTaxType> {
428 fn string(&mut self, s: &str) -> miniserde::Result<()> {
429 use std::str::FromStr;
430 self.out = Some(BillingBillResourceInvoicingTaxesTaxType::from_str(s).expect("infallible"));
431 Ok(())
432 }
433}
434
435stripe_types::impl_from_val_with_from_str!(BillingBillResourceInvoicingTaxesTaxType);
436#[cfg(feature = "deserialize")]
437impl<'de> serde::Deserialize<'de> for BillingBillResourceInvoicingTaxesTaxType {
438 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
439 use std::str::FromStr;
440 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
441 Ok(Self::from_str(&s).expect("infallible"))
442 }
443}