1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit {
5 pub custom_mandate_url: Option<String>,
7 pub default_for: Option<Vec<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>>,
9 pub interval_description: Option<String>,
12 pub payment_schedule:
14 Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>,
15 pub transaction_type:
17 Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>,
18}
19#[doc(hidden)]
20pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder {
21 custom_mandate_url: Option<Option<String>>,
22 default_for:
23 Option<Option<Vec<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>>>,
24 interval_description: Option<Option<String>>,
25 payment_schedule:
26 Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>>,
27 transaction_type:
28 Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>>,
29}
30
31#[allow(
32 unused_variables,
33 irrefutable_let_patterns,
34 clippy::let_unit_value,
35 clippy::match_single_binding,
36 clippy::single_match
37)]
38const _: () = {
39 use miniserde::de::{Map, Visitor};
40 use miniserde::json::Value;
41 use miniserde::{Deserialize, Result, make_place};
42 use stripe_types::miniserde_helpers::FromValueOpt;
43 use stripe_types::{MapBuilder, ObjectDeser};
44
45 make_place!(Place);
46
47 impl Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit {
48 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
49 Place::new(out)
50 }
51 }
52
53 struct Builder<'a> {
54 out: &'a mut Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
55 builder: SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder,
56 }
57
58 impl Visitor for Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit> {
59 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
60 Ok(Box::new(Builder {
61 out: &mut self.out,
62 builder:
63 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default(),
64 }))
65 }
66 }
67
68 impl MapBuilder for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder {
69 type Out = SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit;
70 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
71 Ok(match k {
72 "custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url),
73 "default_for" => Deserialize::begin(&mut self.default_for),
74 "interval_description" => Deserialize::begin(&mut self.interval_description),
75 "payment_schedule" => Deserialize::begin(&mut self.payment_schedule),
76 "transaction_type" => Deserialize::begin(&mut self.transaction_type),
77 _ => <dyn Visitor>::ignore(),
78 })
79 }
80
81 fn deser_default() -> Self {
82 Self {
83 custom_mandate_url: Deserialize::default(),
84 default_for: Deserialize::default(),
85 interval_description: Deserialize::default(),
86 payment_schedule: Deserialize::default(),
87 transaction_type: Deserialize::default(),
88 }
89 }
90
91 fn take_out(&mut self) -> Option<Self::Out> {
92 let (
93 Some(custom_mandate_url),
94 Some(default_for),
95 Some(interval_description),
96 Some(payment_schedule),
97 Some(transaction_type),
98 ) = (
99 self.custom_mandate_url.take(),
100 self.default_for.take(),
101 self.interval_description.take(),
102 self.payment_schedule.take(),
103 self.transaction_type.take(),
104 )
105 else {
106 return None;
107 };
108 Some(Self::Out {
109 custom_mandate_url,
110 default_for,
111 interval_description,
112 payment_schedule,
113 transaction_type,
114 })
115 }
116 }
117
118 impl Map for Builder<'_> {
119 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
120 self.builder.key(k)
121 }
122
123 fn finish(&mut self) -> Result<()> {
124 *self.out = self.builder.take_out();
125 Ok(())
126 }
127 }
128
129 impl ObjectDeser for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit {
130 type Builder = SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder;
131 }
132
133 impl FromValueOpt for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit {
134 fn from_value(v: Value) -> Option<Self> {
135 let Value::Object(obj) = v else {
136 return None;
137 };
138 let mut b =
139 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default();
140 for (k, v) in obj {
141 match k.as_str() {
142 "custom_mandate_url" => b.custom_mandate_url = FromValueOpt::from_value(v),
143 "default_for" => b.default_for = FromValueOpt::from_value(v),
144 "interval_description" => b.interval_description = FromValueOpt::from_value(v),
145 "payment_schedule" => b.payment_schedule = FromValueOpt::from_value(v),
146 "transaction_type" => b.transaction_type = FromValueOpt::from_value(v),
147 _ => {}
148 }
149 }
150 b.take_out()
151 }
152 }
153};
154#[derive(Clone, Eq, PartialEq)]
156#[non_exhaustive]
157pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
158 Invoice,
159 Subscription,
160 Unknown(String),
162}
163impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
164 pub fn as_str(&self) -> &str {
165 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::*;
166 match self {
167 Invoice => "invoice",
168 Subscription => "subscription",
169 Unknown(v) => v,
170 }
171 }
172}
173
174impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
175 type Err = std::convert::Infallible;
176 fn from_str(s: &str) -> Result<Self, Self::Err> {
177 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::*;
178 match s {
179 "invoice" => Ok(Invoice),
180 "subscription" => Ok(Subscription),
181 v => {
182 tracing::warn!(
183 "Unknown value '{}' for enum '{}'",
184 v,
185 "SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor"
186 );
187 Ok(Unknown(v.to_owned()))
188 }
189 }
190 }
191}
192impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
213 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
214 crate::Place::new(out)
215 }
216}
217
218impl miniserde::de::Visitor
219 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>
220{
221 fn string(&mut self, s: &str) -> miniserde::Result<()> {
222 use std::str::FromStr;
223 self.out = Some(
224 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::from_str(s)
225 .expect("infallible"),
226 );
227 Ok(())
228 }
229}
230
231stripe_types::impl_from_val_with_from_str!(
232 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor
233);
234#[cfg(feature = "deserialize")]
235impl<'de> serde::Deserialize<'de>
236 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor
237{
238 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
239 use std::str::FromStr;
240 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
241 Ok(Self::from_str(&s).expect("infallible"))
242 }
243}
244#[derive(Clone, Eq, PartialEq)]
246#[non_exhaustive]
247pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
248 Combined,
249 Interval,
250 Sporadic,
251 Unknown(String),
253}
254impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
255 pub fn as_str(&self) -> &str {
256 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
257 match self {
258 Combined => "combined",
259 Interval => "interval",
260 Sporadic => "sporadic",
261 Unknown(v) => v,
262 }
263 }
264}
265
266impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
267 type Err = std::convert::Infallible;
268 fn from_str(s: &str) -> Result<Self, Self::Err> {
269 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
270 match s {
271 "combined" => Ok(Combined),
272 "interval" => Ok(Interval),
273 "sporadic" => Ok(Sporadic),
274 v => {
275 tracing::warn!(
276 "Unknown value '{}' for enum '{}'",
277 v,
278 "SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule"
279 );
280 Ok(Unknown(v.to_owned()))
281 }
282 }
283 }
284}
285impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
286 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
287 f.write_str(self.as_str())
288 }
289}
290
291impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
292 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
293 f.write_str(self.as_str())
294 }
295}
296#[cfg(feature = "serialize")]
297impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
298 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
299 where
300 S: serde::Serializer,
301 {
302 serializer.serialize_str(self.as_str())
303 }
304}
305impl miniserde::Deserialize
306 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
307{
308 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
309 crate::Place::new(out)
310 }
311}
312
313impl miniserde::de::Visitor
314 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>
315{
316 fn string(&mut self, s: &str) -> miniserde::Result<()> {
317 use std::str::FromStr;
318 self.out = Some(
319 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s)
320 .expect("infallible"),
321 );
322 Ok(())
323 }
324}
325
326stripe_types::impl_from_val_with_from_str!(
327 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
328);
329#[cfg(feature = "deserialize")]
330impl<'de> serde::Deserialize<'de>
331 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
332{
333 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
334 use std::str::FromStr;
335 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
336 Ok(Self::from_str(&s).expect("infallible"))
337 }
338}
339#[derive(Clone, Eq, PartialEq)]
341#[non_exhaustive]
342pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
343 Business,
344 Personal,
345 Unknown(String),
347}
348impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
349 pub fn as_str(&self) -> &str {
350 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
351 match self {
352 Business => "business",
353 Personal => "personal",
354 Unknown(v) => v,
355 }
356 }
357}
358
359impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
360 type Err = std::convert::Infallible;
361 fn from_str(s: &str) -> Result<Self, Self::Err> {
362 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
363 match s {
364 "business" => Ok(Business),
365 "personal" => Ok(Personal),
366 v => {
367 tracing::warn!(
368 "Unknown value '{}' for enum '{}'",
369 v,
370 "SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType"
371 );
372 Ok(Unknown(v.to_owned()))
373 }
374 }
375 }
376}
377impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
378 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
379 f.write_str(self.as_str())
380 }
381}
382
383impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
384 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
385 f.write_str(self.as_str())
386 }
387}
388#[cfg(feature = "serialize")]
389impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
390 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
391 where
392 S: serde::Serializer,
393 {
394 serializer.serialize_str(self.as_str())
395 }
396}
397impl miniserde::Deserialize
398 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
399{
400 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
401 crate::Place::new(out)
402 }
403}
404
405impl miniserde::de::Visitor
406 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>
407{
408 fn string(&mut self, s: &str) -> miniserde::Result<()> {
409 use std::str::FromStr;
410 self.out = Some(
411 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s)
412 .expect("infallible"),
413 );
414 Ok(())
415 }
416}
417
418stripe_types::impl_from_val_with_from_str!(
419 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
420);
421#[cfg(feature = "deserialize")]
422impl<'de> serde::Deserialize<'de>
423 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
424{
425 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
426 use std::str::FromStr;
427 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
428 Ok(Self::from_str(&s).expect("infallible"))
429 }
430}