stripe_shared/
payment_links_resource_invoice_settings.rs

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