stripe_shared/
invoice_setting_customer_rendering_options.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct InvoiceSettingCustomerRenderingOptions {
5    /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
6    pub amount_tax_display: Option<String>,
7    /// ID of the invoice rendering template to be used for this customer's invoices.
8    /// If set, the template will be used on all invoices for this customer unless a template is set directly on the invoice.
9    pub template: Option<String>,
10}
11#[doc(hidden)]
12pub struct InvoiceSettingCustomerRenderingOptionsBuilder {
13    amount_tax_display: Option<Option<String>>,
14    template: Option<Option<String>>,
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 InvoiceSettingCustomerRenderingOptions {
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<InvoiceSettingCustomerRenderingOptions>,
41        builder: InvoiceSettingCustomerRenderingOptionsBuilder,
42    }
43
44    impl Visitor for Place<InvoiceSettingCustomerRenderingOptions> {
45        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
46            Ok(Box::new(Builder {
47                out: &mut self.out,
48                builder: InvoiceSettingCustomerRenderingOptionsBuilder::deser_default(),
49            }))
50        }
51    }
52
53    impl MapBuilder for InvoiceSettingCustomerRenderingOptionsBuilder {
54        type Out = InvoiceSettingCustomerRenderingOptions;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "amount_tax_display" => Deserialize::begin(&mut self.amount_tax_display),
58                "template" => Deserialize::begin(&mut self.template),
59                _ => <dyn Visitor>::ignore(),
60            })
61        }
62
63        fn deser_default() -> Self {
64            Self { amount_tax_display: Deserialize::default(), template: Deserialize::default() }
65        }
66
67        fn take_out(&mut self) -> Option<Self::Out> {
68            let (Some(amount_tax_display), Some(template)) =
69                (self.amount_tax_display.take(), self.template.take())
70            else {
71                return None;
72            };
73            Some(Self::Out { amount_tax_display, template })
74        }
75    }
76
77    impl Map for Builder<'_> {
78        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
79            self.builder.key(k)
80        }
81
82        fn finish(&mut self) -> Result<()> {
83            *self.out = self.builder.take_out();
84            Ok(())
85        }
86    }
87
88    impl ObjectDeser for InvoiceSettingCustomerRenderingOptions {
89        type Builder = InvoiceSettingCustomerRenderingOptionsBuilder;
90    }
91
92    impl FromValueOpt for InvoiceSettingCustomerRenderingOptions {
93        fn from_value(v: Value) -> Option<Self> {
94            let Value::Object(obj) = v else {
95                return None;
96            };
97            let mut b = InvoiceSettingCustomerRenderingOptionsBuilder::deser_default();
98            for (k, v) in obj {
99                match k.as_str() {
100                    "amount_tax_display" => b.amount_tax_display = FromValueOpt::from_value(v),
101                    "template" => b.template = FromValueOpt::from_value(v),
102                    _ => {}
103                }
104            }
105            b.take_out()
106        }
107    }
108};