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,
103 self.transaction_type,
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(Copy, Clone, Eq, PartialEq)]
156pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
157 Invoice,
158 Subscription,
159}
160impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
161 pub fn as_str(self) -> &'static str {
162 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::*;
163 match self {
164 Invoice => "invoice",
165 Subscription => "subscription",
166 }
167 }
168}
169
170impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
171 type Err = stripe_types::StripeParseError;
172 fn from_str(s: &str) -> Result<Self, Self::Err> {
173 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::*;
174 match s {
175 "invoice" => Ok(Invoice),
176 "subscription" => Ok(Subscription),
177 _ => Err(stripe_types::StripeParseError),
178 }
179 }
180}
181impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
202 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
203 crate::Place::new(out)
204 }
205}
206
207impl miniserde::de::Visitor
208 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>
209{
210 fn string(&mut self, s: &str) -> miniserde::Result<()> {
211 use std::str::FromStr;
212 self.out = Some(
213 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::from_str(s)
214 .map_err(|_| miniserde::Error)?,
215 );
216 Ok(())
217 }
218}
219
220stripe_types::impl_from_val_with_from_str!(
221 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor
222);
223#[cfg(feature = "deserialize")]
224impl<'de> serde::Deserialize<'de>
225 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor
226{
227 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
228 use std::str::FromStr;
229 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
230 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor"))
231 }
232}
233#[derive(Copy, Clone, Eq, PartialEq)]
235pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
236 Combined,
237 Interval,
238 Sporadic,
239}
240impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
241 pub fn as_str(self) -> &'static str {
242 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
243 match self {
244 Combined => "combined",
245 Interval => "interval",
246 Sporadic => "sporadic",
247 }
248 }
249}
250
251impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
252 type Err = stripe_types::StripeParseError;
253 fn from_str(s: &str) -> Result<Self, Self::Err> {
254 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
255 match s {
256 "combined" => Ok(Combined),
257 "interval" => Ok(Interval),
258 "sporadic" => Ok(Sporadic),
259 _ => Err(stripe_types::StripeParseError),
260 }
261 }
262}
263impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
264 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
265 f.write_str(self.as_str())
266 }
267}
268
269impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
270 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
271 f.write_str(self.as_str())
272 }
273}
274#[cfg(feature = "serialize")]
275impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
276 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
277 where
278 S: serde::Serializer,
279 {
280 serializer.serialize_str(self.as_str())
281 }
282}
283impl miniserde::Deserialize
284 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
285{
286 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
287 crate::Place::new(out)
288 }
289}
290
291impl miniserde::de::Visitor
292 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>
293{
294 fn string(&mut self, s: &str) -> miniserde::Result<()> {
295 use std::str::FromStr;
296 self.out = Some(
297 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s)
298 .map_err(|_| miniserde::Error)?,
299 );
300 Ok(())
301 }
302}
303
304stripe_types::impl_from_val_with_from_str!(
305 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
306);
307#[cfg(feature = "deserialize")]
308impl<'de> serde::Deserialize<'de>
309 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
310{
311 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
312 use std::str::FromStr;
313 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
314 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule"))
315 }
316}
317#[derive(Copy, Clone, Eq, PartialEq)]
319pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
320 Business,
321 Personal,
322}
323impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
324 pub fn as_str(self) -> &'static str {
325 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
326 match self {
327 Business => "business",
328 Personal => "personal",
329 }
330 }
331}
332
333impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
334 type Err = stripe_types::StripeParseError;
335 fn from_str(s: &str) -> Result<Self, Self::Err> {
336 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
337 match s {
338 "business" => Ok(Business),
339 "personal" => Ok(Personal),
340 _ => Err(stripe_types::StripeParseError),
341 }
342 }
343}
344impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
345 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
346 f.write_str(self.as_str())
347 }
348}
349
350impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
351 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
352 f.write_str(self.as_str())
353 }
354}
355#[cfg(feature = "serialize")]
356impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
357 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
358 where
359 S: serde::Serializer,
360 {
361 serializer.serialize_str(self.as_str())
362 }
363}
364impl miniserde::Deserialize
365 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
366{
367 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
368 crate::Place::new(out)
369 }
370}
371
372impl miniserde::de::Visitor
373 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>
374{
375 fn string(&mut self, s: &str) -> miniserde::Result<()> {
376 use std::str::FromStr;
377 self.out = Some(
378 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s)
379 .map_err(|_| miniserde::Error)?,
380 );
381 Ok(())
382 }
383}
384
385stripe_types::impl_from_val_with_from_str!(
386 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
387);
388#[cfg(feature = "deserialize")]
389impl<'de> serde::Deserialize<'de>
390 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
391{
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(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType"))
396 }
397}