Skip to main content

stripe_shared/
invoice_setting_customer_rendering_options.rs

1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct InvoiceSettingCustomerRenderingOptions {
6    /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
7    pub amount_tax_display: Option<String>,
8    /// ID of the invoice rendering template to be used for this customer's invoices.
9    /// If set, the template will be used on all invoices for this customer unless a template is set directly on the invoice.
10    pub template: Option<String>,
11}
12#[cfg(feature = "redact-generated-debug")]
13impl std::fmt::Debug for InvoiceSettingCustomerRenderingOptions {
14    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
15        f.debug_struct("InvoiceSettingCustomerRenderingOptions").finish_non_exhaustive()
16    }
17}
18#[doc(hidden)]
19pub struct InvoiceSettingCustomerRenderingOptionsBuilder {
20    amount_tax_display: Option<Option<String>>,
21    template: Option<Option<String>>,
22}
23
24#[allow(
25    unused_variables,
26    irrefutable_let_patterns,
27    clippy::let_unit_value,
28    clippy::match_single_binding,
29    clippy::single_match
30)]
31const _: () = {
32    use miniserde::de::{Map, Visitor};
33    use miniserde::json::Value;
34    use miniserde::{Deserialize, Result, make_place};
35    use stripe_types::miniserde_helpers::FromValueOpt;
36    use stripe_types::{MapBuilder, ObjectDeser};
37
38    make_place!(Place);
39
40    impl Deserialize for InvoiceSettingCustomerRenderingOptions {
41        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
42            Place::new(out)
43        }
44    }
45
46    struct Builder<'a> {
47        out: &'a mut Option<InvoiceSettingCustomerRenderingOptions>,
48        builder: InvoiceSettingCustomerRenderingOptionsBuilder,
49    }
50
51    impl Visitor for Place<InvoiceSettingCustomerRenderingOptions> {
52        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53            Ok(Box::new(Builder {
54                out: &mut self.out,
55                builder: InvoiceSettingCustomerRenderingOptionsBuilder::deser_default(),
56            }))
57        }
58    }
59
60    impl MapBuilder for InvoiceSettingCustomerRenderingOptionsBuilder {
61        type Out = InvoiceSettingCustomerRenderingOptions;
62        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63            Ok(match k {
64                "amount_tax_display" => Deserialize::begin(&mut self.amount_tax_display),
65                "template" => Deserialize::begin(&mut self.template),
66                _ => <dyn Visitor>::ignore(),
67            })
68        }
69
70        fn deser_default() -> Self {
71            Self { amount_tax_display: Some(None), template: Some(None) }
72        }
73
74        fn take_out(&mut self) -> Option<Self::Out> {
75            let (Some(amount_tax_display), Some(template)) =
76                (self.amount_tax_display.take(), self.template.take())
77            else {
78                return None;
79            };
80            Some(Self::Out { amount_tax_display, template })
81        }
82    }
83
84    impl Map for Builder<'_> {
85        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
86            self.builder.key(k)
87        }
88
89        fn finish(&mut self) -> Result<()> {
90            *self.out = self.builder.take_out();
91            Ok(())
92        }
93    }
94
95    impl ObjectDeser for InvoiceSettingCustomerRenderingOptions {
96        type Builder = InvoiceSettingCustomerRenderingOptionsBuilder;
97    }
98
99    impl FromValueOpt for InvoiceSettingCustomerRenderingOptions {
100        fn from_value(v: Value) -> Option<Self> {
101            let Value::Object(obj) = v else {
102                return None;
103            };
104            let mut b = InvoiceSettingCustomerRenderingOptionsBuilder::deser_default();
105            for (k, v) in obj {
106                match k.as_str() {
107                    "amount_tax_display" => b.amount_tax_display = FromValueOpt::from_value(v),
108                    "template" => b.template = FromValueOpt::from_value(v),
109                    _ => {}
110                }
111            }
112            b.take_out()
113        }
114    }
115};