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::{make_place, Deserialize, Result};
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
78 _ => <dyn Visitor>::ignore(),
79 })
80 }
81
82 fn deser_default() -> Self {
83 Self {
84 custom_mandate_url: Deserialize::default(),
85 default_for: Deserialize::default(),
86 interval_description: Deserialize::default(),
87 payment_schedule: Deserialize::default(),
88 transaction_type: Deserialize::default(),
89 }
90 }
91
92 fn take_out(&mut self) -> Option<Self::Out> {
93 let (
94 Some(custom_mandate_url),
95 Some(default_for),
96 Some(interval_description),
97 Some(payment_schedule),
98 Some(transaction_type),
99 ) = (
100 self.custom_mandate_url.take(),
101 self.default_for.take(),
102 self.interval_description.take(),
103 self.payment_schedule,
104 self.transaction_type,
105 )
106 else {
107 return None;
108 };
109 Some(Self::Out {
110 custom_mandate_url,
111 default_for,
112 interval_description,
113 payment_schedule,
114 transaction_type,
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 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit {
131 type Builder = SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder;
132 }
133
134 impl FromValueOpt for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit {
135 fn from_value(v: Value) -> Option<Self> {
136 let Value::Object(obj) = v else {
137 return None;
138 };
139 let mut b =
140 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default();
141 for (k, v) in obj {
142 match k.as_str() {
143 "custom_mandate_url" => b.custom_mandate_url = FromValueOpt::from_value(v),
144 "default_for" => b.default_for = FromValueOpt::from_value(v),
145 "interval_description" => b.interval_description = FromValueOpt::from_value(v),
146 "payment_schedule" => b.payment_schedule = FromValueOpt::from_value(v),
147 "transaction_type" => b.transaction_type = FromValueOpt::from_value(v),
148
149 _ => {}
150 }
151 }
152 b.take_out()
153 }
154 }
155};
156#[derive(Copy, Clone, Eq, PartialEq)]
158pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
159 Invoice,
160 Subscription,
161}
162impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
163 pub fn as_str(self) -> &'static str {
164 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::*;
165 match self {
166 Invoice => "invoice",
167 Subscription => "subscription",
168 }
169 }
170}
171
172impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
173 type Err = stripe_types::StripeParseError;
174 fn from_str(s: &str) -> Result<Self, Self::Err> {
175 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::*;
176 match s {
177 "invoice" => Ok(Invoice),
178 "subscription" => Ok(Subscription),
179 _ => Err(stripe_types::StripeParseError),
180 }
181 }
182}
183impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
184 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
185 f.write_str(self.as_str())
186 }
187}
188
189impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
190 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
191 f.write_str(self.as_str())
192 }
193}
194#[cfg(feature = "serialize")]
195impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
196 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
197 where
198 S: serde::Serializer,
199 {
200 serializer.serialize_str(self.as_str())
201 }
202}
203impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor {
204 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
205 crate::Place::new(out)
206 }
207}
208
209impl miniserde::de::Visitor
210 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>
211{
212 fn string(&mut self, s: &str) -> miniserde::Result<()> {
213 use std::str::FromStr;
214 self.out = Some(
215 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::from_str(s)
216 .map_err(|_| miniserde::Error)?,
217 );
218 Ok(())
219 }
220}
221
222stripe_types::impl_from_val_with_from_str!(
223 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor
224);
225#[cfg(feature = "deserialize")]
226impl<'de> serde::Deserialize<'de>
227 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor
228{
229 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
230 use std::str::FromStr;
231 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
232 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor"))
233 }
234}
235#[derive(Copy, Clone, Eq, PartialEq)]
237pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
238 Combined,
239 Interval,
240 Sporadic,
241}
242impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
243 pub fn as_str(self) -> &'static str {
244 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
245 match self {
246 Combined => "combined",
247 Interval => "interval",
248 Sporadic => "sporadic",
249 }
250 }
251}
252
253impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
254 type Err = stripe_types::StripeParseError;
255 fn from_str(s: &str) -> Result<Self, Self::Err> {
256 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
257 match s {
258 "combined" => Ok(Combined),
259 "interval" => Ok(Interval),
260 "sporadic" => Ok(Sporadic),
261 _ => Err(stripe_types::StripeParseError),
262 }
263 }
264}
265impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
266 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267 f.write_str(self.as_str())
268 }
269}
270
271impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
272 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
273 f.write_str(self.as_str())
274 }
275}
276#[cfg(feature = "serialize")]
277impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
278 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
279 where
280 S: serde::Serializer,
281 {
282 serializer.serialize_str(self.as_str())
283 }
284}
285impl miniserde::Deserialize
286 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
287{
288 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
289 crate::Place::new(out)
290 }
291}
292
293impl miniserde::de::Visitor
294 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>
295{
296 fn string(&mut self, s: &str) -> miniserde::Result<()> {
297 use std::str::FromStr;
298 self.out = Some(
299 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s)
300 .map_err(|_| miniserde::Error)?,
301 );
302 Ok(())
303 }
304}
305
306stripe_types::impl_from_val_with_from_str!(
307 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
308);
309#[cfg(feature = "deserialize")]
310impl<'de> serde::Deserialize<'de>
311 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
312{
313 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
314 use std::str::FromStr;
315 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
316 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule"))
317 }
318}
319#[derive(Copy, Clone, Eq, PartialEq)]
321pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
322 Business,
323 Personal,
324}
325impl SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
326 pub fn as_str(self) -> &'static str {
327 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
328 match self {
329 Business => "business",
330 Personal => "personal",
331 }
332 }
333}
334
335impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
336 type Err = stripe_types::StripeParseError;
337 fn from_str(s: &str) -> Result<Self, Self::Err> {
338 use SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
339 match s {
340 "business" => Ok(Business),
341 "personal" => Ok(Personal),
342 _ => Err(stripe_types::StripeParseError),
343 }
344 }
345}
346impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
347 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
348 f.write_str(self.as_str())
349 }
350}
351
352impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
353 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
354 f.write_str(self.as_str())
355 }
356}
357#[cfg(feature = "serialize")]
358impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
359 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
360 where
361 S: serde::Serializer,
362 {
363 serializer.serialize_str(self.as_str())
364 }
365}
366impl miniserde::Deserialize
367 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
368{
369 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
370 crate::Place::new(out)
371 }
372}
373
374impl miniserde::de::Visitor
375 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>
376{
377 fn string(&mut self, s: &str) -> miniserde::Result<()> {
378 use std::str::FromStr;
379 self.out = Some(
380 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s)
381 .map_err(|_| miniserde::Error)?,
382 );
383 Ok(())
384 }
385}
386
387stripe_types::impl_from_val_with_from_str!(
388 SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
389);
390#[cfg(feature = "deserialize")]
391impl<'de> serde::Deserialize<'de>
392 for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
393{
394 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
395 use std::str::FromStr;
396 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
397 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType"))
398 }
399}