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::{make_place, Deserialize, Result};
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
60                _ => <dyn Visitor>::ignore(),
61            })
62        }
63
64        fn deser_default() -> Self {
65            Self { amount_tax_display: Deserialize::default(), template: Deserialize::default() }
66        }
67
68        fn take_out(&mut self) -> Option<Self::Out> {
69            let (Some(amount_tax_display), Some(template)) =
70                (self.amount_tax_display.take(), self.template.take())
71            else {
72                return None;
73            };
74            Some(Self::Out { amount_tax_display, template })
75        }
76    }
77
78    impl<'a> Map for Builder<'a> {
79        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
80            self.builder.key(k)
81        }
82
83        fn finish(&mut self) -> Result<()> {
84            *self.out = self.builder.take_out();
85            Ok(())
86        }
87    }
88
89    impl ObjectDeser for InvoiceSettingCustomerRenderingOptions {
90        type Builder = InvoiceSettingCustomerRenderingOptionsBuilder;
91    }
92
93    impl FromValueOpt for InvoiceSettingCustomerRenderingOptions {
94        fn from_value(v: Value) -> Option<Self> {
95            let Value::Object(obj) = v else {
96                return None;
97            };
98            let mut b = InvoiceSettingCustomerRenderingOptionsBuilder::deser_default();
99            for (k, v) in obj {
100                match k.as_str() {
101                    "amount_tax_display" => b.amount_tax_display = FromValueOpt::from_value(v),
102                    "template" => b.template = FromValueOpt::from_value(v),
103
104                    _ => {}
105                }
106            }
107            b.take_out()
108        }
109    }
110};