1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsAcssDebit {
5 pub mandate_options:
6 Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
7 pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>,
16 pub target_date: Option<String>,
20 pub verification_method: Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>,
22}
23#[doc(hidden)]
24pub struct PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
25 mandate_options:
26 Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>>,
27 setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>>,
28 target_date: Option<Option<String>>,
29 verification_method:
30 Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>>,
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::{make_place, Deserialize, Result};
44 use stripe_types::miniserde_helpers::FromValueOpt;
45 use stripe_types::{MapBuilder, ObjectDeser};
46
47 make_place!(Place);
48
49 impl Deserialize for PaymentIntentPaymentMethodOptionsAcssDebit {
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<PaymentIntentPaymentMethodOptionsAcssDebit>,
57 builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder,
58 }
59
60 impl Visitor for Place<PaymentIntentPaymentMethodOptionsAcssDebit> {
61 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62 Ok(Box::new(Builder {
63 out: &mut self.out,
64 builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(),
65 }))
66 }
67 }
68
69 impl MapBuilder for PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
70 type Out = PaymentIntentPaymentMethodOptionsAcssDebit;
71 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72 Ok(match k {
73 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
74 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
75 "target_date" => Deserialize::begin(&mut self.target_date),
76 "verification_method" => Deserialize::begin(&mut self.verification_method),
77
78 _ => <dyn Visitor>::ignore(),
79 })
80 }
81
82 fn deser_default() -> Self {
83 Self {
84 mandate_options: Deserialize::default(),
85 setup_future_usage: Deserialize::default(),
86 target_date: Deserialize::default(),
87 verification_method: Deserialize::default(),
88 }
89 }
90
91 fn take_out(&mut self) -> Option<Self::Out> {
92 let (
93 Some(mandate_options),
94 Some(setup_future_usage),
95 Some(target_date),
96 Some(verification_method),
97 ) = (
98 self.mandate_options.take(),
99 self.setup_future_usage,
100 self.target_date.take(),
101 self.verification_method,
102 )
103 else {
104 return None;
105 };
106 Some(Self::Out {
107 mandate_options,
108 setup_future_usage,
109 target_date,
110 verification_method,
111 })
112 }
113 }
114
115 impl Map for Builder<'_> {
116 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
117 self.builder.key(k)
118 }
119
120 fn finish(&mut self) -> Result<()> {
121 *self.out = self.builder.take_out();
122 Ok(())
123 }
124 }
125
126 impl ObjectDeser for PaymentIntentPaymentMethodOptionsAcssDebit {
127 type Builder = PaymentIntentPaymentMethodOptionsAcssDebitBuilder;
128 }
129
130 impl FromValueOpt for PaymentIntentPaymentMethodOptionsAcssDebit {
131 fn from_value(v: Value) -> Option<Self> {
132 let Value::Object(obj) = v else {
133 return None;
134 };
135 let mut b = PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default();
136 for (k, v) in obj {
137 match k.as_str() {
138 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
139 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
140 "target_date" => b.target_date = FromValueOpt::from_value(v),
141 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
142
143 _ => {}
144 }
145 }
146 b.take_out()
147 }
148 }
149};
150#[derive(Copy, Clone, Eq, PartialEq)]
159pub enum PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
160 None,
161 OffSession,
162 OnSession,
163}
164impl PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
165 pub fn as_str(self) -> &'static str {
166 use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
167 match self {
168 None => "none",
169 OffSession => "off_session",
170 OnSession => "on_session",
171 }
172 }
173}
174
175impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
176 type Err = stripe_types::StripeParseError;
177 fn from_str(s: &str) -> Result<Self, Self::Err> {
178 use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
179 match s {
180 "none" => Ok(None),
181 "off_session" => Ok(OffSession),
182 "on_session" => Ok(OnSession),
183 _ => Err(stripe_types::StripeParseError),
184 }
185 }
186}
187impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
189 f.write_str(self.as_str())
190 }
191}
192
193impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
194 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
195 f.write_str(self.as_str())
196 }
197}
198#[cfg(feature = "serialize")]
199impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
200 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
201 where
202 S: serde::Serializer,
203 {
204 serializer.serialize_str(self.as_str())
205 }
206}
207impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
208 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
209 crate::Place::new(out)
210 }
211}
212
213impl miniserde::de::Visitor
214 for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>
215{
216 fn string(&mut self, s: &str) -> miniserde::Result<()> {
217 use std::str::FromStr;
218 self.out = Some(
219 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::from_str(s)
220 .map_err(|_| miniserde::Error)?,
221 );
222 Ok(())
223 }
224}
225
226stripe_types::impl_from_val_with_from_str!(
227 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage
228);
229#[cfg(feature = "deserialize")]
230impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
231 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
232 use std::str::FromStr;
233 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
234 Self::from_str(&s).map_err(|_| {
235 serde::de::Error::custom(
236 "Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage",
237 )
238 })
239 }
240}
241#[derive(Copy, Clone, Eq, PartialEq)]
243pub enum PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
244 Automatic,
245 Instant,
246 Microdeposits,
247}
248impl PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
249 pub fn as_str(self) -> &'static str {
250 use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
251 match self {
252 Automatic => "automatic",
253 Instant => "instant",
254 Microdeposits => "microdeposits",
255 }
256 }
257}
258
259impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
260 type Err = stripe_types::StripeParseError;
261 fn from_str(s: &str) -> Result<Self, Self::Err> {
262 use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
263 match s {
264 "automatic" => Ok(Automatic),
265 "instant" => Ok(Instant),
266 "microdeposits" => Ok(Microdeposits),
267 _ => Err(stripe_types::StripeParseError),
268 }
269 }
270}
271impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
272 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
273 f.write_str(self.as_str())
274 }
275}
276
277impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
278 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
279 f.write_str(self.as_str())
280 }
281}
282#[cfg(feature = "serialize")]
283impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
284 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
285 where
286 S: serde::Serializer,
287 {
288 serializer.serialize_str(self.as_str())
289 }
290}
291impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
292 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
293 crate::Place::new(out)
294 }
295}
296
297impl miniserde::de::Visitor
298 for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>
299{
300 fn string(&mut self, s: &str) -> miniserde::Result<()> {
301 use std::str::FromStr;
302 self.out = Some(
303 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s)
304 .map_err(|_| miniserde::Error)?,
305 );
306 Ok(())
307 }
308}
309
310stripe_types::impl_from_val_with_from_str!(
311 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod
312);
313#[cfg(feature = "deserialize")]
314impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
315 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
316 use std::str::FromStr;
317 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
318 Self::from_str(&s).map_err(|_| {
319 serde::de::Error::custom(
320 "Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod",
321 )
322 })
323 }
324}