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