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::{Deserialize, Result, make_place};
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 _ => <dyn Visitor>::ignore(),
67 })
68 }
69
70 fn deser_default() -> Self {
71 Self {
72 custom_fields: Deserialize::default(),
73 default_payment_method: Deserialize::default(),
74 footer: Deserialize::default(),
75 rendering_options: Deserialize::default(),
76 }
77 }
78
79 fn take_out(&mut self) -> Option<Self::Out> {
80 let (
81 Some(custom_fields),
82 Some(default_payment_method),
83 Some(footer),
84 Some(rendering_options),
85 ) = (
86 self.custom_fields.take(),
87 self.default_payment_method.take(),
88 self.footer.take(),
89 self.rendering_options.take(),
90 )
91 else {
92 return None;
93 };
94 Some(Self::Out { custom_fields, default_payment_method, footer, rendering_options })
95 }
96 }
97
98 impl Map for Builder<'_> {
99 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
100 self.builder.key(k)
101 }
102
103 fn finish(&mut self) -> Result<()> {
104 *self.out = self.builder.take_out();
105 Ok(())
106 }
107 }
108
109 impl ObjectDeser for InvoiceSettingCustomerSetting {
110 type Builder = InvoiceSettingCustomerSettingBuilder;
111 }
112
113 impl FromValueOpt for InvoiceSettingCustomerSetting {
114 fn from_value(v: Value) -> Option<Self> {
115 let Value::Object(obj) = v else {
116 return None;
117 };
118 let mut b = InvoiceSettingCustomerSettingBuilder::deser_default();
119 for (k, v) in obj {
120 match k.as_str() {
121 "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
122 "default_payment_method" => {
123 b.default_payment_method = FromValueOpt::from_value(v)
124 }
125 "footer" => b.footer = FromValueOpt::from_value(v),
126 "rendering_options" => b.rendering_options = FromValueOpt::from_value(v),
127 _ => {}
128 }
129 }
130 b.take_out()
131 }
132 }
133};