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::{Deserialize, Result, make_place};
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 _ => <dyn Visitor>::ignore(),
78 })
79 }
80
81 fn deser_default() -> Self {
82 Self {
83 decline_on: Deserialize::default(),
84 statement_descriptor_prefix: Deserialize::default(),
85 statement_descriptor_prefix_kana: Deserialize::default(),
86 statement_descriptor_prefix_kanji: Deserialize::default(),
87 }
88 }
89
90 fn take_out(&mut self) -> Option<Self::Out> {
91 let (
92 Some(decline_on),
93 Some(statement_descriptor_prefix),
94 Some(statement_descriptor_prefix_kana),
95 Some(statement_descriptor_prefix_kanji),
96 ) = (
97 self.decline_on,
98 self.statement_descriptor_prefix.take(),
99 self.statement_descriptor_prefix_kana.take(),
100 self.statement_descriptor_prefix_kanji.take(),
101 )
102 else {
103 return None;
104 };
105 Some(Self::Out {
106 decline_on,
107 statement_descriptor_prefix,
108 statement_descriptor_prefix_kana,
109 statement_descriptor_prefix_kanji,
110 })
111 }
112 }
113
114 impl Map for Builder<'_> {
115 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
116 self.builder.key(k)
117 }
118
119 fn finish(&mut self) -> Result<()> {
120 *self.out = self.builder.take_out();
121 Ok(())
122 }
123 }
124
125 impl ObjectDeser for AccountCardPaymentsSettings {
126 type Builder = AccountCardPaymentsSettingsBuilder;
127 }
128
129 impl FromValueOpt for AccountCardPaymentsSettings {
130 fn from_value(v: Value) -> Option<Self> {
131 let Value::Object(obj) = v else {
132 return None;
133 };
134 let mut b = AccountCardPaymentsSettingsBuilder::deser_default();
135 for (k, v) in obj {
136 match k.as_str() {
137 "decline_on" => b.decline_on = FromValueOpt::from_value(v),
138 "statement_descriptor_prefix" => {
139 b.statement_descriptor_prefix = FromValueOpt::from_value(v)
140 }
141 "statement_descriptor_prefix_kana" => {
142 b.statement_descriptor_prefix_kana = FromValueOpt::from_value(v)
143 }
144 "statement_descriptor_prefix_kanji" => {
145 b.statement_descriptor_prefix_kanji = FromValueOpt::from_value(v)
146 }
147 _ => {}
148 }
149 }
150 b.take_out()
151 }
152 }
153};