Skip to main content

stripe_shared/
payment_pages_checkout_session_invoice_settings.rs

1#[derive(Clone)]
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 PaymentPagesCheckoutSessionInvoiceSettings {
6    /// The account tax IDs associated with the invoice.
7    pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>,
8    /// Custom fields displayed on the invoice.
9    pub custom_fields: Option<Vec<stripe_shared::InvoiceSettingCustomField>>,
10    /// An arbitrary string attached to the object. Often useful for displaying to users.
11    pub description: Option<String>,
12    /// Footer displayed on the invoice.
13    pub footer: Option<String>,
14    /// The connected account that issues the invoice.
15    /// The invoice is presented with the branding and support information of the specified account.
16    pub issuer: Option<stripe_shared::ConnectAccountReference>,
17    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
18    /// This can be useful for storing additional information about the object in a structured format.
19    pub metadata: Option<std::collections::HashMap<String, String>>,
20    /// Options for invoice PDF rendering.
21    pub rendering_options: Option<stripe_shared::InvoiceSettingCheckoutRenderingOptions>,
22}
23#[cfg(feature = "redact-generated-debug")]
24impl std::fmt::Debug for PaymentPagesCheckoutSessionInvoiceSettings {
25    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
26        f.debug_struct("PaymentPagesCheckoutSessionInvoiceSettings").finish_non_exhaustive()
27    }
28}
29#[doc(hidden)]
30pub struct PaymentPagesCheckoutSessionInvoiceSettingsBuilder {
31    account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>,
32    custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>,
33    description: Option<Option<String>>,
34    footer: Option<Option<String>>,
35    issuer: Option<Option<stripe_shared::ConnectAccountReference>>,
36    metadata: Option<Option<std::collections::HashMap<String, String>>>,
37    rendering_options: Option<Option<stripe_shared::InvoiceSettingCheckoutRenderingOptions>>,
38}
39
40#[allow(
41    unused_variables,
42    irrefutable_let_patterns,
43    clippy::let_unit_value,
44    clippy::match_single_binding,
45    clippy::single_match
46)]
47const _: () = {
48    use miniserde::de::{Map, Visitor};
49    use miniserde::json::Value;
50    use miniserde::{Deserialize, Result, make_place};
51    use stripe_types::miniserde_helpers::FromValueOpt;
52    use stripe_types::{MapBuilder, ObjectDeser};
53
54    make_place!(Place);
55
56    impl Deserialize for PaymentPagesCheckoutSessionInvoiceSettings {
57        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
58            Place::new(out)
59        }
60    }
61
62    struct Builder<'a> {
63        out: &'a mut Option<PaymentPagesCheckoutSessionInvoiceSettings>,
64        builder: PaymentPagesCheckoutSessionInvoiceSettingsBuilder,
65    }
66
67    impl Visitor for Place<PaymentPagesCheckoutSessionInvoiceSettings> {
68        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
69            Ok(Box::new(Builder {
70                out: &mut self.out,
71                builder: PaymentPagesCheckoutSessionInvoiceSettingsBuilder::deser_default(),
72            }))
73        }
74    }
75
76    impl MapBuilder for PaymentPagesCheckoutSessionInvoiceSettingsBuilder {
77        type Out = PaymentPagesCheckoutSessionInvoiceSettings;
78        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
79            Ok(match k {
80                "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids),
81                "custom_fields" => Deserialize::begin(&mut self.custom_fields),
82                "description" => Deserialize::begin(&mut self.description),
83                "footer" => Deserialize::begin(&mut self.footer),
84                "issuer" => Deserialize::begin(&mut self.issuer),
85                "metadata" => Deserialize::begin(&mut self.metadata),
86                "rendering_options" => Deserialize::begin(&mut self.rendering_options),
87                _ => <dyn Visitor>::ignore(),
88            })
89        }
90
91        fn deser_default() -> Self {
92            Self {
93                account_tax_ids: Some(None),
94                custom_fields: Some(None),
95                description: Some(None),
96                footer: Some(None),
97                issuer: Some(None),
98                metadata: Some(None),
99                rendering_options: Some(None),
100            }
101        }
102
103        fn take_out(&mut self) -> Option<Self::Out> {
104            let (
105                Some(account_tax_ids),
106                Some(custom_fields),
107                Some(description),
108                Some(footer),
109                Some(issuer),
110                Some(metadata),
111                Some(rendering_options),
112            ) = (
113                self.account_tax_ids.take(),
114                self.custom_fields.take(),
115                self.description.take(),
116                self.footer.take(),
117                self.issuer.take(),
118                self.metadata.take(),
119                self.rendering_options.take(),
120            )
121            else {
122                return None;
123            };
124            Some(Self::Out {
125                account_tax_ids,
126                custom_fields,
127                description,
128                footer,
129                issuer,
130                metadata,
131                rendering_options,
132            })
133        }
134    }
135
136    impl Map for Builder<'_> {
137        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
138            self.builder.key(k)
139        }
140
141        fn finish(&mut self) -> Result<()> {
142            *self.out = self.builder.take_out();
143            Ok(())
144        }
145    }
146
147    impl ObjectDeser for PaymentPagesCheckoutSessionInvoiceSettings {
148        type Builder = PaymentPagesCheckoutSessionInvoiceSettingsBuilder;
149    }
150
151    impl FromValueOpt for PaymentPagesCheckoutSessionInvoiceSettings {
152        fn from_value(v: Value) -> Option<Self> {
153            let Value::Object(obj) = v else {
154                return None;
155            };
156            let mut b = PaymentPagesCheckoutSessionInvoiceSettingsBuilder::deser_default();
157            for (k, v) in obj {
158                match k.as_str() {
159                    "account_tax_ids" => b.account_tax_ids = FromValueOpt::from_value(v),
160                    "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
161                    "description" => b.description = FromValueOpt::from_value(v),
162                    "footer" => b.footer = FromValueOpt::from_value(v),
163                    "issuer" => b.issuer = FromValueOpt::from_value(v),
164                    "metadata" => b.metadata = FromValueOpt::from_value(v),
165                    "rendering_options" => b.rendering_options = FromValueOpt::from_value(v),
166                    _ => {}
167                }
168            }
169            b.take_out()
170        }
171    }
172};