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.take(),
101 self.mandate_options.take(),
102 self.setup_future_usage.take(),
103 self.target_date.take(),
104 self.verification_method.take(),
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(Clone, Eq, PartialEq)]
156#[non_exhaustive]
157pub enum CheckoutAcssDebitPaymentMethodOptionsCurrency {
158 Cad,
159 Usd,
160 Unknown(String),
162}
163impl CheckoutAcssDebitPaymentMethodOptionsCurrency {
164 pub fn as_str(&self) -> &str {
165 use CheckoutAcssDebitPaymentMethodOptionsCurrency::*;
166 match self {
167 Cad => "cad",
168 Usd => "usd",
169 Unknown(v) => v,
170 }
171 }
172}
173
174impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsCurrency {
175 type Err = std::convert::Infallible;
176 fn from_str(s: &str) -> Result<Self, Self::Err> {
177 use CheckoutAcssDebitPaymentMethodOptionsCurrency::*;
178 match s {
179 "cad" => Ok(Cad),
180 "usd" => Ok(Usd),
181 v => {
182 tracing::warn!(
183 "Unknown value '{}' for enum '{}'",
184 v,
185 "CheckoutAcssDebitPaymentMethodOptionsCurrency"
186 );
187 Ok(Unknown(v.to_owned()))
188 }
189 }
190 }
191}
192impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsCurrency {
193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
194 f.write_str(self.as_str())
195 }
196}
197
198impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsCurrency {
199 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
200 f.write_str(self.as_str())
201 }
202}
203#[cfg(feature = "serialize")]
204impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsCurrency {
205 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
206 where
207 S: serde::Serializer,
208 {
209 serializer.serialize_str(self.as_str())
210 }
211}
212impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsCurrency {
213 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
214 crate::Place::new(out)
215 }
216}
217
218impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitPaymentMethodOptionsCurrency> {
219 fn string(&mut self, s: &str) -> miniserde::Result<()> {
220 use std::str::FromStr;
221 self.out =
222 Some(CheckoutAcssDebitPaymentMethodOptionsCurrency::from_str(s).expect("infallible"));
223 Ok(())
224 }
225}
226
227stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsCurrency);
228#[cfg(feature = "deserialize")]
229impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsCurrency {
230 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
231 use std::str::FromStr;
232 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
233 Ok(Self::from_str(&s).expect("infallible"))
234 }
235}
236#[derive(Clone, Eq, PartialEq)]
245#[non_exhaustive]
246pub enum CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
247 None,
248 OffSession,
249 OnSession,
250 Unknown(String),
252}
253impl CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
254 pub fn as_str(&self) -> &str {
255 use CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::*;
256 match self {
257 None => "none",
258 OffSession => "off_session",
259 OnSession => "on_session",
260 Unknown(v) => v,
261 }
262 }
263}
264
265impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
266 type Err = std::convert::Infallible;
267 fn from_str(s: &str) -> Result<Self, Self::Err> {
268 use CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::*;
269 match s {
270 "none" => Ok(None),
271 "off_session" => Ok(OffSession),
272 "on_session" => Ok(OnSession),
273 v => {
274 tracing::warn!(
275 "Unknown value '{}' for enum '{}'",
276 v,
277 "CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage"
278 );
279 Ok(Unknown(v.to_owned()))
280 }
281 }
282 }
283}
284impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
285 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
286 f.write_str(self.as_str())
287 }
288}
289
290impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
291 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
292 f.write_str(self.as_str())
293 }
294}
295#[cfg(feature = "serialize")]
296impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
297 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
298 where
299 S: serde::Serializer,
300 {
301 serializer.serialize_str(self.as_str())
302 }
303}
304impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
305 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
306 crate::Place::new(out)
307 }
308}
309
310impl miniserde::de::Visitor
311 for crate::Place<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>
312{
313 fn string(&mut self, s: &str) -> miniserde::Result<()> {
314 use std::str::FromStr;
315 self.out = Some(
316 CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::from_str(s).expect("infallible"),
317 );
318 Ok(())
319 }
320}
321
322stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage);
323#[cfg(feature = "deserialize")]
324impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
325 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
326 use std::str::FromStr;
327 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
328 Ok(Self::from_str(&s).expect("infallible"))
329 }
330}
331#[derive(Clone, Eq, PartialEq)]
333#[non_exhaustive]
334pub enum CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
335 Automatic,
336 Instant,
337 Microdeposits,
338 Unknown(String),
340}
341impl CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
342 pub fn as_str(&self) -> &str {
343 use CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::*;
344 match self {
345 Automatic => "automatic",
346 Instant => "instant",
347 Microdeposits => "microdeposits",
348 Unknown(v) => v,
349 }
350 }
351}
352
353impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
354 type Err = std::convert::Infallible;
355 fn from_str(s: &str) -> Result<Self, Self::Err> {
356 use CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::*;
357 match s {
358 "automatic" => Ok(Automatic),
359 "instant" => Ok(Instant),
360 "microdeposits" => Ok(Microdeposits),
361 v => {
362 tracing::warn!(
363 "Unknown value '{}' for enum '{}'",
364 v,
365 "CheckoutAcssDebitPaymentMethodOptionsVerificationMethod"
366 );
367 Ok(Unknown(v.to_owned()))
368 }
369 }
370 }
371}
372impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
373 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
374 f.write_str(self.as_str())
375 }
376}
377
378impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
379 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
380 f.write_str(self.as_str())
381 }
382}
383#[cfg(feature = "serialize")]
384impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
385 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
386 where
387 S: serde::Serializer,
388 {
389 serializer.serialize_str(self.as_str())
390 }
391}
392impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
393 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
394 crate::Place::new(out)
395 }
396}
397
398impl miniserde::de::Visitor
399 for crate::Place<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>
400{
401 fn string(&mut self, s: &str) -> miniserde::Result<()> {
402 use std::str::FromStr;
403 self.out = Some(
404 CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::from_str(s)
405 .expect("infallible"),
406 );
407 Ok(())
408 }
409}
410
411stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod);
412#[cfg(feature = "deserialize")]
413impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
414 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
415 use std::str::FromStr;
416 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
417 Ok(Self::from_str(&s).expect("infallible"))
418 }
419}