stripe_shared/
payment_flows_amount_details_resource_tax.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentFlowsAmountDetailsResourceTax {
5    /// The total amount of tax on the transaction represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
6    /// Required for L2 rates.
7    /// An integer greater than or equal to 0.
8    ///
9    /// This field is mutually exclusive with the `amount_details[line_items][#][tax][total_tax_amount]` field.
10    pub total_tax_amount: Option<i64>,
11}
12#[doc(hidden)]
13pub struct PaymentFlowsAmountDetailsResourceTaxBuilder {
14    total_tax_amount: Option<Option<i64>>,
15}
16
17#[allow(
18    unused_variables,
19    irrefutable_let_patterns,
20    clippy::let_unit_value,
21    clippy::match_single_binding,
22    clippy::single_match
23)]
24const _: () = {
25    use miniserde::de::{Map, Visitor};
26    use miniserde::json::Value;
27    use miniserde::{Deserialize, Result, make_place};
28    use stripe_types::miniserde_helpers::FromValueOpt;
29    use stripe_types::{MapBuilder, ObjectDeser};
30
31    make_place!(Place);
32
33    impl Deserialize for PaymentFlowsAmountDetailsResourceTax {
34        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
35            Place::new(out)
36        }
37    }
38
39    struct Builder<'a> {
40        out: &'a mut Option<PaymentFlowsAmountDetailsResourceTax>,
41        builder: PaymentFlowsAmountDetailsResourceTaxBuilder,
42    }
43
44    impl Visitor for Place<PaymentFlowsAmountDetailsResourceTax> {
45        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
46            Ok(Box::new(Builder {
47                out: &mut self.out,
48                builder: PaymentFlowsAmountDetailsResourceTaxBuilder::deser_default(),
49            }))
50        }
51    }
52
53    impl MapBuilder for PaymentFlowsAmountDetailsResourceTaxBuilder {
54        type Out = PaymentFlowsAmountDetailsResourceTax;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "total_tax_amount" => Deserialize::begin(&mut self.total_tax_amount),
58                _ => <dyn Visitor>::ignore(),
59            })
60        }
61
62        fn deser_default() -> Self {
63            Self { total_tax_amount: Deserialize::default() }
64        }
65
66        fn take_out(&mut self) -> Option<Self::Out> {
67            let (Some(total_tax_amount),) = (self.total_tax_amount,) else {
68                return None;
69            };
70            Some(Self::Out { total_tax_amount })
71        }
72    }
73
74    impl Map for Builder<'_> {
75        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
76            self.builder.key(k)
77        }
78
79        fn finish(&mut self) -> Result<()> {
80            *self.out = self.builder.take_out();
81            Ok(())
82        }
83    }
84
85    impl ObjectDeser for PaymentFlowsAmountDetailsResourceTax {
86        type Builder = PaymentFlowsAmountDetailsResourceTaxBuilder;
87    }
88
89    impl FromValueOpt for PaymentFlowsAmountDetailsResourceTax {
90        fn from_value(v: Value) -> Option<Self> {
91            let Value::Object(obj) = v else {
92                return None;
93            };
94            let mut b = PaymentFlowsAmountDetailsResourceTaxBuilder::deser_default();
95            for (k, v) in obj {
96                match k.as_str() {
97                    "total_tax_amount" => b.total_tax_amount = FromValueOpt::from_value(v),
98                    _ => {}
99                }
100            }
101            b.take_out()
102        }
103    }
104};