stripe_shared/
invoice_setting_customer_setting.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct InvoiceSettingCustomerSetting {
5 pub custom_fields: Option<Vec<stripe_shared::InvoiceSettingCustomField>>,
7 pub default_payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
9 pub footer: Option<String>,
11 pub rendering_options: Option<stripe_shared::InvoiceSettingCustomerRenderingOptions>,
13}
14#[doc(hidden)]
15pub struct InvoiceSettingCustomerSettingBuilder {
16 custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>,
17 default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
18 footer: Option<Option<String>>,
19 rendering_options: Option<Option<stripe_shared::InvoiceSettingCustomerRenderingOptions>>,
20}
21
22#[allow(
23 unused_variables,
24 irrefutable_let_patterns,
25 clippy::let_unit_value,
26 clippy::match_single_binding,
27 clippy::single_match
28)]
29const _: () = {
30 use miniserde::de::{Map, Visitor};
31 use miniserde::json::Value;
32 use miniserde::{make_place, Deserialize, Result};
33 use stripe_types::miniserde_helpers::FromValueOpt;
34 use stripe_types::{MapBuilder, ObjectDeser};
35
36 make_place!(Place);
37
38 impl Deserialize for InvoiceSettingCustomerSetting {
39 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
40 Place::new(out)
41 }
42 }
43
44 struct Builder<'a> {
45 out: &'a mut Option<InvoiceSettingCustomerSetting>,
46 builder: InvoiceSettingCustomerSettingBuilder,
47 }
48
49 impl Visitor for Place<InvoiceSettingCustomerSetting> {
50 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
51 Ok(Box::new(Builder {
52 out: &mut self.out,
53 builder: InvoiceSettingCustomerSettingBuilder::deser_default(),
54 }))
55 }
56 }
57
58 impl MapBuilder for InvoiceSettingCustomerSettingBuilder {
59 type Out = InvoiceSettingCustomerSetting;
60 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
61 Ok(match k {
62 "custom_fields" => Deserialize::begin(&mut self.custom_fields),
63 "default_payment_method" => Deserialize::begin(&mut self.default_payment_method),
64 "footer" => Deserialize::begin(&mut self.footer),
65 "rendering_options" => Deserialize::begin(&mut self.rendering_options),
66
67 _ => <dyn Visitor>::ignore(),
68 })
69 }
70
71 fn deser_default() -> Self {
72 Self {
73 custom_fields: Deserialize::default(),
74 default_payment_method: Deserialize::default(),
75 footer: Deserialize::default(),
76 rendering_options: Deserialize::default(),
77 }
78 }
79
80 fn take_out(&mut self) -> Option<Self::Out> {
81 let (
82 Some(custom_fields),
83 Some(default_payment_method),
84 Some(footer),
85 Some(rendering_options),
86 ) = (
87 self.custom_fields.take(),
88 self.default_payment_method.take(),
89 self.footer.take(),
90 self.rendering_options.take(),
91 )
92 else {
93 return None;
94 };
95 Some(Self::Out { custom_fields, default_payment_method, footer, rendering_options })
96 }
97 }
98
99 impl<'a> Map for Builder<'a> {
100 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
101 self.builder.key(k)
102 }
103
104 fn finish(&mut self) -> Result<()> {
105 *self.out = self.builder.take_out();
106 Ok(())
107 }
108 }
109
110 impl ObjectDeser for InvoiceSettingCustomerSetting {
111 type Builder = InvoiceSettingCustomerSettingBuilder;
112 }
113
114 impl FromValueOpt for InvoiceSettingCustomerSetting {
115 fn from_value(v: Value) -> Option<Self> {
116 let Value::Object(obj) = v else {
117 return None;
118 };
119 let mut b = InvoiceSettingCustomerSettingBuilder::deser_default();
120 for (k, v) in obj {
121 match k.as_str() {
122 "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
123 "default_payment_method" => {
124 b.default_payment_method = FromValueOpt::from_value(v)
125 }
126 "footer" => b.footer = FromValueOpt::from_value(v),
127 "rendering_options" => b.rendering_options = FromValueOpt::from_value(v),
128
129 _ => {}
130 }
131 }
132 b.take_out()
133 }
134 }
135};