1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct SetupIntentPaymentMethodOptionsMandateOptionsPayto {
6 pub amount: Option<i64>,
8 pub amount_type: Option<SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType>,
12 pub end_date: Option<String>,
14 pub payment_schedule: Option<SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule>,
16 pub payments_per_period: Option<i64>,
20 pub purpose: Option<SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose>,
22 pub start_date: Option<String>,
24}
25#[cfg(feature = "redact-generated-debug")]
26impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPayto {
27 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28 f.debug_struct("SetupIntentPaymentMethodOptionsMandateOptionsPayto").finish_non_exhaustive()
29 }
30}
31#[doc(hidden)]
32pub struct SetupIntentPaymentMethodOptionsMandateOptionsPaytoBuilder {
33 amount: Option<Option<i64>>,
34 amount_type: Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType>>,
35 end_date: Option<Option<String>>,
36 payment_schedule:
37 Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule>>,
38 payments_per_period: Option<Option<i64>>,
39 purpose: Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose>>,
40 start_date: Option<Option<String>>,
41}
42
43#[allow(
44 unused_variables,
45 irrefutable_let_patterns,
46 clippy::let_unit_value,
47 clippy::match_single_binding,
48 clippy::single_match
49)]
50const _: () = {
51 use miniserde::de::{Map, Visitor};
52 use miniserde::json::Value;
53 use miniserde::{Deserialize, Result, make_place};
54 use stripe_types::miniserde_helpers::FromValueOpt;
55 use stripe_types::{MapBuilder, ObjectDeser};
56
57 make_place!(Place);
58
59 impl Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsPayto {
60 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
61 Place::new(out)
62 }
63 }
64
65 struct Builder<'a> {
66 out: &'a mut Option<SetupIntentPaymentMethodOptionsMandateOptionsPayto>,
67 builder: SetupIntentPaymentMethodOptionsMandateOptionsPaytoBuilder,
68 }
69
70 impl Visitor for Place<SetupIntentPaymentMethodOptionsMandateOptionsPayto> {
71 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
72 Ok(Box::new(Builder {
73 out: &mut self.out,
74 builder: SetupIntentPaymentMethodOptionsMandateOptionsPaytoBuilder::deser_default(),
75 }))
76 }
77 }
78
79 impl MapBuilder for SetupIntentPaymentMethodOptionsMandateOptionsPaytoBuilder {
80 type Out = SetupIntentPaymentMethodOptionsMandateOptionsPayto;
81 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
82 Ok(match k {
83 "amount" => Deserialize::begin(&mut self.amount),
84 "amount_type" => Deserialize::begin(&mut self.amount_type),
85 "end_date" => Deserialize::begin(&mut self.end_date),
86 "payment_schedule" => Deserialize::begin(&mut self.payment_schedule),
87 "payments_per_period" => Deserialize::begin(&mut self.payments_per_period),
88 "purpose" => Deserialize::begin(&mut self.purpose),
89 "start_date" => Deserialize::begin(&mut self.start_date),
90 _ => <dyn Visitor>::ignore(),
91 })
92 }
93
94 fn deser_default() -> Self {
95 Self {
96 amount: Some(None),
97 amount_type: Some(None),
98 end_date: Some(None),
99 payment_schedule: Some(None),
100 payments_per_period: Some(None),
101 purpose: Some(None),
102 start_date: Some(None),
103 }
104 }
105
106 fn take_out(&mut self) -> Option<Self::Out> {
107 let (
108 Some(amount),
109 Some(amount_type),
110 Some(end_date),
111 Some(payment_schedule),
112 Some(payments_per_period),
113 Some(purpose),
114 Some(start_date),
115 ) = (
116 self.amount,
117 self.amount_type.take(),
118 self.end_date.take(),
119 self.payment_schedule.take(),
120 self.payments_per_period,
121 self.purpose.take(),
122 self.start_date.take(),
123 )
124 else {
125 return None;
126 };
127 Some(Self::Out {
128 amount,
129 amount_type,
130 end_date,
131 payment_schedule,
132 payments_per_period,
133 purpose,
134 start_date,
135 })
136 }
137 }
138
139 impl Map for Builder<'_> {
140 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
141 self.builder.key(k)
142 }
143
144 fn finish(&mut self) -> Result<()> {
145 *self.out = self.builder.take_out();
146 Ok(())
147 }
148 }
149
150 impl ObjectDeser for SetupIntentPaymentMethodOptionsMandateOptionsPayto {
151 type Builder = SetupIntentPaymentMethodOptionsMandateOptionsPaytoBuilder;
152 }
153
154 impl FromValueOpt for SetupIntentPaymentMethodOptionsMandateOptionsPayto {
155 fn from_value(v: Value) -> Option<Self> {
156 let Value::Object(obj) = v else {
157 return None;
158 };
159 let mut b = SetupIntentPaymentMethodOptionsMandateOptionsPaytoBuilder::deser_default();
160 for (k, v) in obj {
161 match k.as_str() {
162 "amount" => b.amount = FromValueOpt::from_value(v),
163 "amount_type" => b.amount_type = FromValueOpt::from_value(v),
164 "end_date" => b.end_date = FromValueOpt::from_value(v),
165 "payment_schedule" => b.payment_schedule = FromValueOpt::from_value(v),
166 "payments_per_period" => b.payments_per_period = FromValueOpt::from_value(v),
167 "purpose" => b.purpose = FromValueOpt::from_value(v),
168 "start_date" => b.start_date = FromValueOpt::from_value(v),
169 _ => {}
170 }
171 }
172 b.take_out()
173 }
174 }
175};
176#[derive(Clone, Eq, PartialEq)]
180#[non_exhaustive]
181pub enum SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
182 Fixed,
183 Maximum,
184 Unknown(String),
186}
187impl SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
188 pub fn as_str(&self) -> &str {
189 use SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType::*;
190 match self {
191 Fixed => "fixed",
192 Maximum => "maximum",
193 Unknown(v) => v,
194 }
195 }
196}
197
198impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
199 type Err = std::convert::Infallible;
200 fn from_str(s: &str) -> Result<Self, Self::Err> {
201 use SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType::*;
202 match s {
203 "fixed" => Ok(Fixed),
204 "maximum" => Ok(Maximum),
205 v => {
206 tracing::warn!(
207 "Unknown value '{}' for enum '{}'",
208 v,
209 "SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType"
210 );
211 Ok(Unknown(v.to_owned()))
212 }
213 }
214 }
215}
216impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
217 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
218 f.write_str(self.as_str())
219 }
220}
221
222#[cfg(not(feature = "redact-generated-debug"))]
223impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
224 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
225 f.write_str(self.as_str())
226 }
227}
228#[cfg(feature = "redact-generated-debug")]
229impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
230 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
231 f.debug_struct(stringify!(SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType))
232 .finish_non_exhaustive()
233 }
234}
235#[cfg(feature = "serialize")]
236impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
237 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
238 where
239 S: serde::Serializer,
240 {
241 serializer.serialize_str(self.as_str())
242 }
243}
244impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
245 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
246 crate::Place::new(out)
247 }
248}
249
250impl miniserde::de::Visitor
251 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType>
252{
253 fn string(&mut self, s: &str) -> miniserde::Result<()> {
254 use std::str::FromStr;
255 self.out = Some(
256 SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType::from_str(s)
257 .expect("infallible"),
258 );
259 Ok(())
260 }
261}
262
263stripe_types::impl_from_val_with_from_str!(
264 SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType
265);
266#[cfg(feature = "deserialize")]
267impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsPaytoAmountType {
268 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
269 use std::str::FromStr;
270 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
271 Ok(Self::from_str(&s).expect("infallible"))
272 }
273}
274#[derive(Clone, Eq, PartialEq)]
276#[non_exhaustive]
277pub enum SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
278 Adhoc,
279 Annual,
280 Daily,
281 Fortnightly,
282 Monthly,
283 Quarterly,
284 SemiAnnual,
285 Weekly,
286 Unknown(String),
288}
289impl SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
290 pub fn as_str(&self) -> &str {
291 use SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule::*;
292 match self {
293 Adhoc => "adhoc",
294 Annual => "annual",
295 Daily => "daily",
296 Fortnightly => "fortnightly",
297 Monthly => "monthly",
298 Quarterly => "quarterly",
299 SemiAnnual => "semi_annual",
300 Weekly => "weekly",
301 Unknown(v) => v,
302 }
303 }
304}
305
306impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
307 type Err = std::convert::Infallible;
308 fn from_str(s: &str) -> Result<Self, Self::Err> {
309 use SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule::*;
310 match s {
311 "adhoc" => Ok(Adhoc),
312 "annual" => Ok(Annual),
313 "daily" => Ok(Daily),
314 "fortnightly" => Ok(Fortnightly),
315 "monthly" => Ok(Monthly),
316 "quarterly" => Ok(Quarterly),
317 "semi_annual" => Ok(SemiAnnual),
318 "weekly" => Ok(Weekly),
319 v => {
320 tracing::warn!(
321 "Unknown value '{}' for enum '{}'",
322 v,
323 "SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule"
324 );
325 Ok(Unknown(v.to_owned()))
326 }
327 }
328 }
329}
330impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
331 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
332 f.write_str(self.as_str())
333 }
334}
335
336#[cfg(not(feature = "redact-generated-debug"))]
337impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
338 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
339 f.write_str(self.as_str())
340 }
341}
342#[cfg(feature = "redact-generated-debug")]
343impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
344 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
345 f.debug_struct(stringify!(
346 SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule
347 ))
348 .finish_non_exhaustive()
349 }
350}
351#[cfg(feature = "serialize")]
352impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
353 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
354 where
355 S: serde::Serializer,
356 {
357 serializer.serialize_str(self.as_str())
358 }
359}
360impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule {
361 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
362 crate::Place::new(out)
363 }
364}
365
366impl miniserde::de::Visitor
367 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule>
368{
369 fn string(&mut self, s: &str) -> miniserde::Result<()> {
370 use std::str::FromStr;
371 self.out = Some(
372 SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule::from_str(s)
373 .expect("infallible"),
374 );
375 Ok(())
376 }
377}
378
379stripe_types::impl_from_val_with_from_str!(
380 SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule
381);
382#[cfg(feature = "deserialize")]
383impl<'de> serde::Deserialize<'de>
384 for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPaymentSchedule
385{
386 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
387 use std::str::FromStr;
388 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
389 Ok(Self::from_str(&s).expect("infallible"))
390 }
391}
392#[derive(Clone, Eq, PartialEq)]
394#[non_exhaustive]
395pub enum SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
396 DependantSupport,
397 Government,
398 Loan,
399 Mortgage,
400 Other,
401 Pension,
402 Personal,
403 Retail,
404 Salary,
405 Tax,
406 Utility,
407 Unknown(String),
409}
410impl SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
411 pub fn as_str(&self) -> &str {
412 use SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose::*;
413 match self {
414 DependantSupport => "dependant_support",
415 Government => "government",
416 Loan => "loan",
417 Mortgage => "mortgage",
418 Other => "other",
419 Pension => "pension",
420 Personal => "personal",
421 Retail => "retail",
422 Salary => "salary",
423 Tax => "tax",
424 Utility => "utility",
425 Unknown(v) => v,
426 }
427 }
428}
429
430impl std::str::FromStr for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
431 type Err = std::convert::Infallible;
432 fn from_str(s: &str) -> Result<Self, Self::Err> {
433 use SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose::*;
434 match s {
435 "dependant_support" => Ok(DependantSupport),
436 "government" => Ok(Government),
437 "loan" => Ok(Loan),
438 "mortgage" => Ok(Mortgage),
439 "other" => Ok(Other),
440 "pension" => Ok(Pension),
441 "personal" => Ok(Personal),
442 "retail" => Ok(Retail),
443 "salary" => Ok(Salary),
444 "tax" => Ok(Tax),
445 "utility" => Ok(Utility),
446 v => {
447 tracing::warn!(
448 "Unknown value '{}' for enum '{}'",
449 v,
450 "SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose"
451 );
452 Ok(Unknown(v.to_owned()))
453 }
454 }
455 }
456}
457impl std::fmt::Display for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
458 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
459 f.write_str(self.as_str())
460 }
461}
462
463#[cfg(not(feature = "redact-generated-debug"))]
464impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
465 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
466 f.write_str(self.as_str())
467 }
468}
469#[cfg(feature = "redact-generated-debug")]
470impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
471 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
472 f.debug_struct(stringify!(SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose))
473 .finish_non_exhaustive()
474 }
475}
476#[cfg(feature = "serialize")]
477impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
478 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
479 where
480 S: serde::Serializer,
481 {
482 serializer.serialize_str(self.as_str())
483 }
484}
485impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
486 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
487 crate::Place::new(out)
488 }
489}
490
491impl miniserde::de::Visitor
492 for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose>
493{
494 fn string(&mut self, s: &str) -> miniserde::Result<()> {
495 use std::str::FromStr;
496 self.out = Some(
497 SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose::from_str(s)
498 .expect("infallible"),
499 );
500 Ok(())
501 }
502}
503
504stripe_types::impl_from_val_with_from_str!(
505 SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose
506);
507#[cfg(feature = "deserialize")]
508impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsPaytoPurpose {
509 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
510 use std::str::FromStr;
511 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
512 Ok(Self::from_str(&s).expect("infallible"))
513 }
514}