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