1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsAcssDebit {
5 pub currency: Option<SetupIntentPaymentMethodOptionsAcssDebitCurrency>,
7 pub mandate_options:
8 Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
9 pub verification_method: Option<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>,
11}
12#[doc(hidden)]
13pub struct SetupIntentPaymentMethodOptionsAcssDebitBuilder {
14 currency: Option<Option<SetupIntentPaymentMethodOptionsAcssDebitCurrency>>,
15 mandate_options:
16 Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>>,
17 verification_method: Option<Option<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>>,
18}
19
20#[allow(
21 unused_variables,
22 irrefutable_let_patterns,
23 clippy::let_unit_value,
24 clippy::match_single_binding,
25 clippy::single_match
26)]
27const _: () = {
28 use miniserde::de::{Map, Visitor};
29 use miniserde::json::Value;
30 use miniserde::{Deserialize, Result, make_place};
31 use stripe_types::miniserde_helpers::FromValueOpt;
32 use stripe_types::{MapBuilder, ObjectDeser};
33
34 make_place!(Place);
35
36 impl Deserialize for SetupIntentPaymentMethodOptionsAcssDebit {
37 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
38 Place::new(out)
39 }
40 }
41
42 struct Builder<'a> {
43 out: &'a mut Option<SetupIntentPaymentMethodOptionsAcssDebit>,
44 builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder,
45 }
46
47 impl Visitor for Place<SetupIntentPaymentMethodOptionsAcssDebit> {
48 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
49 Ok(Box::new(Builder {
50 out: &mut self.out,
51 builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(),
52 }))
53 }
54 }
55
56 impl MapBuilder for SetupIntentPaymentMethodOptionsAcssDebitBuilder {
57 type Out = SetupIntentPaymentMethodOptionsAcssDebit;
58 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
59 Ok(match k {
60 "currency" => Deserialize::begin(&mut self.currency),
61 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
62 "verification_method" => Deserialize::begin(&mut self.verification_method),
63 _ => <dyn Visitor>::ignore(),
64 })
65 }
66
67 fn deser_default() -> Self {
68 Self {
69 currency: Deserialize::default(),
70 mandate_options: Deserialize::default(),
71 verification_method: Deserialize::default(),
72 }
73 }
74
75 fn take_out(&mut self) -> Option<Self::Out> {
76 let (Some(currency), Some(mandate_options), Some(verification_method)) = (
77 self.currency.take(),
78 self.mandate_options.take(),
79 self.verification_method.take(),
80 ) else {
81 return None;
82 };
83 Some(Self::Out { currency, mandate_options, verification_method })
84 }
85 }
86
87 impl Map for Builder<'_> {
88 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89 self.builder.key(k)
90 }
91
92 fn finish(&mut self) -> Result<()> {
93 *self.out = self.builder.take_out();
94 Ok(())
95 }
96 }
97
98 impl ObjectDeser for SetupIntentPaymentMethodOptionsAcssDebit {
99 type Builder = SetupIntentPaymentMethodOptionsAcssDebitBuilder;
100 }
101
102 impl FromValueOpt for SetupIntentPaymentMethodOptionsAcssDebit {
103 fn from_value(v: Value) -> Option<Self> {
104 let Value::Object(obj) = v else {
105 return None;
106 };
107 let mut b = SetupIntentPaymentMethodOptionsAcssDebitBuilder::deser_default();
108 for (k, v) in obj {
109 match k.as_str() {
110 "currency" => b.currency = FromValueOpt::from_value(v),
111 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
112 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};
120#[derive(Clone, Eq, PartialEq)]
122#[non_exhaustive]
123pub enum SetupIntentPaymentMethodOptionsAcssDebitCurrency {
124 Cad,
125 Usd,
126 Unknown(String),
128}
129impl SetupIntentPaymentMethodOptionsAcssDebitCurrency {
130 pub fn as_str(&self) -> &str {
131 use SetupIntentPaymentMethodOptionsAcssDebitCurrency::*;
132 match self {
133 Cad => "cad",
134 Usd => "usd",
135 Unknown(v) => v,
136 }
137 }
138}
139
140impl std::str::FromStr for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
141 type Err = std::convert::Infallible;
142 fn from_str(s: &str) -> Result<Self, Self::Err> {
143 use SetupIntentPaymentMethodOptionsAcssDebitCurrency::*;
144 match s {
145 "cad" => Ok(Cad),
146 "usd" => Ok(Usd),
147 v => {
148 tracing::warn!(
149 "Unknown value '{}' for enum '{}'",
150 v,
151 "SetupIntentPaymentMethodOptionsAcssDebitCurrency"
152 );
153 Ok(Unknown(v.to_owned()))
154 }
155 }
156 }
157}
158impl std::fmt::Display for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
159 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
160 f.write_str(self.as_str())
161 }
162}
163
164impl std::fmt::Debug for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
166 f.write_str(self.as_str())
167 }
168}
169#[cfg(feature = "serialize")]
170impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
171 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
172 where
173 S: serde::Serializer,
174 {
175 serializer.serialize_str(self.as_str())
176 }
177}
178impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
179 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
180 crate::Place::new(out)
181 }
182}
183
184impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsAcssDebitCurrency> {
185 fn string(&mut self, s: &str) -> miniserde::Result<()> {
186 use std::str::FromStr;
187 self.out = Some(
188 SetupIntentPaymentMethodOptionsAcssDebitCurrency::from_str(s).expect("infallible"),
189 );
190 Ok(())
191 }
192}
193
194stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsAcssDebitCurrency);
195#[cfg(feature = "deserialize")]
196impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
197 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
198 use std::str::FromStr;
199 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
200 Ok(Self::from_str(&s).expect("infallible"))
201 }
202}
203#[derive(Clone, Eq, PartialEq)]
205#[non_exhaustive]
206pub enum SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
207 Automatic,
208 Instant,
209 Microdeposits,
210 Unknown(String),
212}
213impl SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
214 pub fn as_str(&self) -> &str {
215 use SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
216 match self {
217 Automatic => "automatic",
218 Instant => "instant",
219 Microdeposits => "microdeposits",
220 Unknown(v) => v,
221 }
222 }
223}
224
225impl std::str::FromStr for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
226 type Err = std::convert::Infallible;
227 fn from_str(s: &str) -> Result<Self, Self::Err> {
228 use SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
229 match s {
230 "automatic" => Ok(Automatic),
231 "instant" => Ok(Instant),
232 "microdeposits" => Ok(Microdeposits),
233 v => {
234 tracing::warn!(
235 "Unknown value '{}' for enum '{}'",
236 v,
237 "SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod"
238 );
239 Ok(Unknown(v.to_owned()))
240 }
241 }
242 }
243}
244impl std::fmt::Display for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
245 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
246 f.write_str(self.as_str())
247 }
248}
249
250impl std::fmt::Debug for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
251 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
252 f.write_str(self.as_str())
253 }
254}
255#[cfg(feature = "serialize")]
256impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
257 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
258 where
259 S: serde::Serializer,
260 {
261 serializer.serialize_str(self.as_str())
262 }
263}
264impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
265 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
266 crate::Place::new(out)
267 }
268}
269
270impl miniserde::de::Visitor
271 for crate::Place<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>
272{
273 fn string(&mut self, s: &str) -> miniserde::Result<()> {
274 use std::str::FromStr;
275 self.out = Some(
276 SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s)
277 .expect("infallible"),
278 );
279 Ok(())
280 }
281}
282
283stripe_types::impl_from_val_with_from_str!(
284 SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod
285);
286#[cfg(feature = "deserialize")]
287impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
288 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
289 use std::str::FromStr;
290 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
291 Ok(Self::from_str(&s).expect("infallible"))
292 }
293}