1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct CheckoutAcssDebitPaymentMethodOptions {
6 pub currency: Option<CheckoutAcssDebitPaymentMethodOptionsCurrency>,
8 pub mandate_options: Option<stripe_shared::CheckoutAcssDebitMandateOptions>,
9 pub setup_future_usage: Option<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>,
18 pub target_date: Option<String>,
22 pub verification_method: Option<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>,
24}
25#[cfg(feature = "redact-generated-debug")]
26impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptions {
27 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28 f.debug_struct("CheckoutAcssDebitPaymentMethodOptions").finish_non_exhaustive()
29 }
30}
31#[doc(hidden)]
32pub struct CheckoutAcssDebitPaymentMethodOptionsBuilder {
33 currency: Option<Option<CheckoutAcssDebitPaymentMethodOptionsCurrency>>,
34 mandate_options: Option<Option<stripe_shared::CheckoutAcssDebitMandateOptions>>,
35 setup_future_usage: Option<Option<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>>,
36 target_date: Option<Option<String>>,
37 verification_method: Option<Option<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>>,
38}
39
40#[allow(
41 unused_variables,
42 irrefutable_let_patterns,
43 clippy::let_unit_value,
44 clippy::match_single_binding,
45 clippy::single_match
46)]
47const _: () = {
48 use miniserde::de::{Map, Visitor};
49 use miniserde::json::Value;
50 use miniserde::{Deserialize, Result, make_place};
51 use stripe_types::miniserde_helpers::FromValueOpt;
52 use stripe_types::{MapBuilder, ObjectDeser};
53
54 make_place!(Place);
55
56 impl Deserialize for CheckoutAcssDebitPaymentMethodOptions {
57 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
58 Place::new(out)
59 }
60 }
61
62 struct Builder<'a> {
63 out: &'a mut Option<CheckoutAcssDebitPaymentMethodOptions>,
64 builder: CheckoutAcssDebitPaymentMethodOptionsBuilder,
65 }
66
67 impl Visitor for Place<CheckoutAcssDebitPaymentMethodOptions> {
68 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
69 Ok(Box::new(Builder {
70 out: &mut self.out,
71 builder: CheckoutAcssDebitPaymentMethodOptionsBuilder::deser_default(),
72 }))
73 }
74 }
75
76 impl MapBuilder for CheckoutAcssDebitPaymentMethodOptionsBuilder {
77 type Out = CheckoutAcssDebitPaymentMethodOptions;
78 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
79 Ok(match k {
80 "currency" => Deserialize::begin(&mut self.currency),
81 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
82 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
83 "target_date" => Deserialize::begin(&mut self.target_date),
84 "verification_method" => Deserialize::begin(&mut self.verification_method),
85 _ => <dyn Visitor>::ignore(),
86 })
87 }
88
89 fn deser_default() -> Self {
90 Self {
91 currency: Some(None),
92 mandate_options: Some(None),
93 setup_future_usage: Some(None),
94 target_date: Some(None),
95 verification_method: Some(None),
96 }
97 }
98
99 fn take_out(&mut self) -> Option<Self::Out> {
100 let (
101 Some(currency),
102 Some(mandate_options),
103 Some(setup_future_usage),
104 Some(target_date),
105 Some(verification_method),
106 ) = (
107 self.currency.take(),
108 self.mandate_options.take(),
109 self.setup_future_usage.take(),
110 self.target_date.take(),
111 self.verification_method.take(),
112 )
113 else {
114 return None;
115 };
116 Some(Self::Out {
117 currency,
118 mandate_options,
119 setup_future_usage,
120 target_date,
121 verification_method,
122 })
123 }
124 }
125
126 impl Map for Builder<'_> {
127 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
128 self.builder.key(k)
129 }
130
131 fn finish(&mut self) -> Result<()> {
132 *self.out = self.builder.take_out();
133 Ok(())
134 }
135 }
136
137 impl ObjectDeser for CheckoutAcssDebitPaymentMethodOptions {
138 type Builder = CheckoutAcssDebitPaymentMethodOptionsBuilder;
139 }
140
141 impl FromValueOpt for CheckoutAcssDebitPaymentMethodOptions {
142 fn from_value(v: Value) -> Option<Self> {
143 let Value::Object(obj) = v else {
144 return None;
145 };
146 let mut b = CheckoutAcssDebitPaymentMethodOptionsBuilder::deser_default();
147 for (k, v) in obj {
148 match k.as_str() {
149 "currency" => b.currency = FromValueOpt::from_value(v),
150 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
151 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
152 "target_date" => b.target_date = FromValueOpt::from_value(v),
153 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
154 _ => {}
155 }
156 }
157 b.take_out()
158 }
159 }
160};
161#[derive(Clone, Eq, PartialEq)]
163#[non_exhaustive]
164pub enum CheckoutAcssDebitPaymentMethodOptionsCurrency {
165 Cad,
166 Usd,
167 Unknown(String),
169}
170impl CheckoutAcssDebitPaymentMethodOptionsCurrency {
171 pub fn as_str(&self) -> &str {
172 use CheckoutAcssDebitPaymentMethodOptionsCurrency::*;
173 match self {
174 Cad => "cad",
175 Usd => "usd",
176 Unknown(v) => v,
177 }
178 }
179}
180
181impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsCurrency {
182 type Err = std::convert::Infallible;
183 fn from_str(s: &str) -> Result<Self, Self::Err> {
184 use CheckoutAcssDebitPaymentMethodOptionsCurrency::*;
185 match s {
186 "cad" => Ok(Cad),
187 "usd" => Ok(Usd),
188 v => {
189 tracing::warn!(
190 "Unknown value '{}' for enum '{}'",
191 v,
192 "CheckoutAcssDebitPaymentMethodOptionsCurrency"
193 );
194 Ok(Unknown(v.to_owned()))
195 }
196 }
197 }
198}
199impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsCurrency {
200 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
201 f.write_str(self.as_str())
202 }
203}
204
205#[cfg(not(feature = "redact-generated-debug"))]
206impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsCurrency {
207 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
208 f.write_str(self.as_str())
209 }
210}
211#[cfg(feature = "redact-generated-debug")]
212impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsCurrency {
213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
214 f.debug_struct(stringify!(CheckoutAcssDebitPaymentMethodOptionsCurrency))
215 .finish_non_exhaustive()
216 }
217}
218#[cfg(feature = "serialize")]
219impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsCurrency {
220 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
221 where
222 S: serde::Serializer,
223 {
224 serializer.serialize_str(self.as_str())
225 }
226}
227impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsCurrency {
228 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
229 crate::Place::new(out)
230 }
231}
232
233impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitPaymentMethodOptionsCurrency> {
234 fn string(&mut self, s: &str) -> miniserde::Result<()> {
235 use std::str::FromStr;
236 self.out =
237 Some(CheckoutAcssDebitPaymentMethodOptionsCurrency::from_str(s).expect("infallible"));
238 Ok(())
239 }
240}
241
242stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsCurrency);
243#[cfg(feature = "deserialize")]
244impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsCurrency {
245 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
246 use std::str::FromStr;
247 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
248 Ok(Self::from_str(&s).expect("infallible"))
249 }
250}
251#[derive(Clone, Eq, PartialEq)]
260#[non_exhaustive]
261pub enum CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
262 None,
263 OffSession,
264 OnSession,
265 Unknown(String),
267}
268impl CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
269 pub fn as_str(&self) -> &str {
270 use CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::*;
271 match self {
272 None => "none",
273 OffSession => "off_session",
274 OnSession => "on_session",
275 Unknown(v) => v,
276 }
277 }
278}
279
280impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
281 type Err = std::convert::Infallible;
282 fn from_str(s: &str) -> Result<Self, Self::Err> {
283 use CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::*;
284 match s {
285 "none" => Ok(None),
286 "off_session" => Ok(OffSession),
287 "on_session" => Ok(OnSession),
288 v => {
289 tracing::warn!(
290 "Unknown value '{}' for enum '{}'",
291 v,
292 "CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage"
293 );
294 Ok(Unknown(v.to_owned()))
295 }
296 }
297 }
298}
299impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
300 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
301 f.write_str(self.as_str())
302 }
303}
304
305#[cfg(not(feature = "redact-generated-debug"))]
306impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
307 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
308 f.write_str(self.as_str())
309 }
310}
311#[cfg(feature = "redact-generated-debug")]
312impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
314 f.debug_struct(stringify!(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage))
315 .finish_non_exhaustive()
316 }
317}
318#[cfg(feature = "serialize")]
319impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
320 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
321 where
322 S: serde::Serializer,
323 {
324 serializer.serialize_str(self.as_str())
325 }
326}
327impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
328 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
329 crate::Place::new(out)
330 }
331}
332
333impl miniserde::de::Visitor
334 for crate::Place<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>
335{
336 fn string(&mut self, s: &str) -> miniserde::Result<()> {
337 use std::str::FromStr;
338 self.out = Some(
339 CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::from_str(s).expect("infallible"),
340 );
341 Ok(())
342 }
343}
344
345stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage);
346#[cfg(feature = "deserialize")]
347impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
348 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
349 use std::str::FromStr;
350 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
351 Ok(Self::from_str(&s).expect("infallible"))
352 }
353}
354#[derive(Clone, Eq, PartialEq)]
356#[non_exhaustive]
357pub enum CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
358 Automatic,
359 Instant,
360 Microdeposits,
361 Unknown(String),
363}
364impl CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
365 pub fn as_str(&self) -> &str {
366 use CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::*;
367 match self {
368 Automatic => "automatic",
369 Instant => "instant",
370 Microdeposits => "microdeposits",
371 Unknown(v) => v,
372 }
373 }
374}
375
376impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
377 type Err = std::convert::Infallible;
378 fn from_str(s: &str) -> Result<Self, Self::Err> {
379 use CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::*;
380 match s {
381 "automatic" => Ok(Automatic),
382 "instant" => Ok(Instant),
383 "microdeposits" => Ok(Microdeposits),
384 v => {
385 tracing::warn!(
386 "Unknown value '{}' for enum '{}'",
387 v,
388 "CheckoutAcssDebitPaymentMethodOptionsVerificationMethod"
389 );
390 Ok(Unknown(v.to_owned()))
391 }
392 }
393 }
394}
395impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
396 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
397 f.write_str(self.as_str())
398 }
399}
400
401#[cfg(not(feature = "redact-generated-debug"))]
402impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
403 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
404 f.write_str(self.as_str())
405 }
406}
407#[cfg(feature = "redact-generated-debug")]
408impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
409 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
410 f.debug_struct(stringify!(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod))
411 .finish_non_exhaustive()
412 }
413}
414#[cfg(feature = "serialize")]
415impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
416 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
417 where
418 S: serde::Serializer,
419 {
420 serializer.serialize_str(self.as_str())
421 }
422}
423impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
424 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
425 crate::Place::new(out)
426 }
427}
428
429impl miniserde::de::Visitor
430 for crate::Place<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>
431{
432 fn string(&mut self, s: &str) -> miniserde::Result<()> {
433 use std::str::FromStr;
434 self.out = Some(
435 CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::from_str(s)
436 .expect("infallible"),
437 );
438 Ok(())
439 }
440}
441
442stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod);
443#[cfg(feature = "deserialize")]
444impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
445 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
446 use std::str::FromStr;
447 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
448 Ok(Self::from_str(&s).expect("infallible"))
449 }
450}