1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsCardMandateOptions {
5 pub amount: i64,
7 pub amount_type: SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType,
11 pub currency: stripe_types::Currency,
14 pub description: Option<String>,
16 pub end_date: Option<stripe_types::Timestamp>,
20 pub interval: SetupIntentPaymentMethodOptionsCardMandateOptionsInterval,
22 pub interval_count: Option<u64>,
27 pub reference: String,
29 pub start_date: stripe_types::Timestamp,
31 pub supported_types:
33 Option<Vec<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes>>,
34}
35#[doc(hidden)]
36pub struct SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder {
37 amount: Option<i64>,
38 amount_type: Option<SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType>,
39 currency: Option<stripe_types::Currency>,
40 description: Option<Option<String>>,
41 end_date: Option<Option<stripe_types::Timestamp>>,
42 interval: Option<SetupIntentPaymentMethodOptionsCardMandateOptionsInterval>,
43 interval_count: Option<Option<u64>>,
44 reference: Option<String>,
45 start_date: Option<stripe_types::Timestamp>,
46 supported_types:
47 Option<Option<Vec<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes>>>,
48}
49
50#[allow(
51 unused_variables,
52 irrefutable_let_patterns,
53 clippy::let_unit_value,
54 clippy::match_single_binding,
55 clippy::single_match
56)]
57const _: () = {
58 use miniserde::de::{Map, Visitor};
59 use miniserde::json::Value;
60 use miniserde::{Deserialize, Result, make_place};
61 use stripe_types::miniserde_helpers::FromValueOpt;
62 use stripe_types::{MapBuilder, ObjectDeser};
63
64 make_place!(Place);
65
66 impl Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptions {
67 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
68 Place::new(out)
69 }
70 }
71
72 struct Builder<'a> {
73 out: &'a mut Option<SetupIntentPaymentMethodOptionsCardMandateOptions>,
74 builder: SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder,
75 }
76
77 impl Visitor for Place<SetupIntentPaymentMethodOptionsCardMandateOptions> {
78 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
79 Ok(Box::new(Builder {
80 out: &mut self.out,
81 builder: SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder::deser_default(),
82 }))
83 }
84 }
85
86 impl MapBuilder for SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder {
87 type Out = SetupIntentPaymentMethodOptionsCardMandateOptions;
88 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89 Ok(match k {
90 "amount" => Deserialize::begin(&mut self.amount),
91 "amount_type" => Deserialize::begin(&mut self.amount_type),
92 "currency" => Deserialize::begin(&mut self.currency),
93 "description" => Deserialize::begin(&mut self.description),
94 "end_date" => Deserialize::begin(&mut self.end_date),
95 "interval" => Deserialize::begin(&mut self.interval),
96 "interval_count" => Deserialize::begin(&mut self.interval_count),
97 "reference" => Deserialize::begin(&mut self.reference),
98 "start_date" => Deserialize::begin(&mut self.start_date),
99 "supported_types" => Deserialize::begin(&mut self.supported_types),
100 _ => <dyn Visitor>::ignore(),
101 })
102 }
103
104 fn deser_default() -> Self {
105 Self {
106 amount: Deserialize::default(),
107 amount_type: Deserialize::default(),
108 currency: Deserialize::default(),
109 description: Deserialize::default(),
110 end_date: Deserialize::default(),
111 interval: Deserialize::default(),
112 interval_count: Deserialize::default(),
113 reference: Deserialize::default(),
114 start_date: Deserialize::default(),
115 supported_types: Deserialize::default(),
116 }
117 }
118
119 fn take_out(&mut self) -> Option<Self::Out> {
120 let (
121 Some(amount),
122 Some(amount_type),
123 Some(currency),
124 Some(description),
125 Some(end_date),
126 Some(interval),
127 Some(interval_count),
128 Some(reference),
129 Some(start_date),
130 Some(supported_types),
131 ) = (
132 self.amount,
133 self.amount_type.take(),
134 self.currency.take(),
135 self.description.take(),
136 self.end_date,
137 self.interval.take(),
138 self.interval_count,
139 self.reference.take(),
140 self.start_date,
141 self.supported_types.take(),
142 )
143 else {
144 return None;
145 };
146 Some(Self::Out {
147 amount,
148 amount_type,
149 currency,
150 description,
151 end_date,
152 interval,
153 interval_count,
154 reference,
155 start_date,
156 supported_types,
157 })
158 }
159 }
160
161 impl Map for Builder<'_> {
162 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
163 self.builder.key(k)
164 }
165
166 fn finish(&mut self) -> Result<()> {
167 *self.out = self.builder.take_out();
168 Ok(())
169 }
170 }
171
172 impl ObjectDeser for SetupIntentPaymentMethodOptionsCardMandateOptions {
173 type Builder = SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder;
174 }
175
176 impl FromValueOpt for SetupIntentPaymentMethodOptionsCardMandateOptions {
177 fn from_value(v: Value) -> Option<Self> {
178 let Value::Object(obj) = v else {
179 return None;
180 };
181 let mut b = SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder::deser_default();
182 for (k, v) in obj {
183 match k.as_str() {
184 "amount" => b.amount = FromValueOpt::from_value(v),
185 "amount_type" => b.amount_type = FromValueOpt::from_value(v),
186 "currency" => b.currency = FromValueOpt::from_value(v),
187 "description" => b.description = FromValueOpt::from_value(v),
188 "end_date" => b.end_date = FromValueOpt::from_value(v),
189 "interval" => b.interval = FromValueOpt::from_value(v),
190 "interval_count" => b.interval_count = FromValueOpt::from_value(v),
191 "reference" => b.reference = FromValueOpt::from_value(v),
192 "start_date" => b.start_date = FromValueOpt::from_value(v),
193 "supported_types" => b.supported_types = FromValueOpt::from_value(v),
194 _ => {}
195 }
196 }
197 b.take_out()
198 }
199 }
200};
201#[derive(Clone, Eq, PartialEq)]
205#[non_exhaustive]
206pub enum SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
207 Fixed,
208 Maximum,
209 Unknown(String),
211}
212impl SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
213 pub fn as_str(&self) -> &str {
214 use SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType::*;
215 match self {
216 Fixed => "fixed",
217 Maximum => "maximum",
218 Unknown(v) => v,
219 }
220 }
221}
222
223impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
224 type Err = std::convert::Infallible;
225 fn from_str(s: &str) -> Result<Self, Self::Err> {
226 use SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType::*;
227 match s {
228 "fixed" => Ok(Fixed),
229 "maximum" => Ok(Maximum),
230 v => {
231 tracing::warn!(
232 "Unknown value '{}' for enum '{}'",
233 v,
234 "SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType"
235 );
236 Ok(Unknown(v.to_owned()))
237 }
238 }
239 }
240}
241impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
242 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
243 f.write_str(self.as_str())
244 }
245}
246
247impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
248 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
249 f.write_str(self.as_str())
250 }
251}
252#[cfg(feature = "serialize")]
253impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
254 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
255 where
256 S: serde::Serializer,
257 {
258 serializer.serialize_str(self.as_str())
259 }
260}
261impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
262 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
263 crate::Place::new(out)
264 }
265}
266
267impl miniserde::de::Visitor
268 for crate::Place<SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType>
269{
270 fn string(&mut self, s: &str) -> miniserde::Result<()> {
271 use std::str::FromStr;
272 self.out = Some(
273 SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType::from_str(s)
274 .expect("infallible"),
275 );
276 Ok(())
277 }
278}
279
280stripe_types::impl_from_val_with_from_str!(
281 SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType
282);
283#[cfg(feature = "deserialize")]
284impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType {
285 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
286 use std::str::FromStr;
287 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
288 Ok(Self::from_str(&s).expect("infallible"))
289 }
290}
291#[derive(Clone, Eq, PartialEq)]
293#[non_exhaustive]
294pub enum SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
295 Day,
296 Month,
297 Sporadic,
298 Week,
299 Year,
300 Unknown(String),
302}
303impl SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
304 pub fn as_str(&self) -> &str {
305 use SetupIntentPaymentMethodOptionsCardMandateOptionsInterval::*;
306 match self {
307 Day => "day",
308 Month => "month",
309 Sporadic => "sporadic",
310 Week => "week",
311 Year => "year",
312 Unknown(v) => v,
313 }
314 }
315}
316
317impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
318 type Err = std::convert::Infallible;
319 fn from_str(s: &str) -> Result<Self, Self::Err> {
320 use SetupIntentPaymentMethodOptionsCardMandateOptionsInterval::*;
321 match s {
322 "day" => Ok(Day),
323 "month" => Ok(Month),
324 "sporadic" => Ok(Sporadic),
325 "week" => Ok(Week),
326 "year" => Ok(Year),
327 v => {
328 tracing::warn!(
329 "Unknown value '{}' for enum '{}'",
330 v,
331 "SetupIntentPaymentMethodOptionsCardMandateOptionsInterval"
332 );
333 Ok(Unknown(v.to_owned()))
334 }
335 }
336 }
337}
338impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
339 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
340 f.write_str(self.as_str())
341 }
342}
343
344impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
345 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
346 f.write_str(self.as_str())
347 }
348}
349#[cfg(feature = "serialize")]
350impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
351 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
352 where
353 S: serde::Serializer,
354 {
355 serializer.serialize_str(self.as_str())
356 }
357}
358impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
359 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
360 crate::Place::new(out)
361 }
362}
363
364impl miniserde::de::Visitor
365 for crate::Place<SetupIntentPaymentMethodOptionsCardMandateOptionsInterval>
366{
367 fn string(&mut self, s: &str) -> miniserde::Result<()> {
368 use std::str::FromStr;
369 self.out = Some(
370 SetupIntentPaymentMethodOptionsCardMandateOptionsInterval::from_str(s)
371 .expect("infallible"),
372 );
373 Ok(())
374 }
375}
376
377stripe_types::impl_from_val_with_from_str!(
378 SetupIntentPaymentMethodOptionsCardMandateOptionsInterval
379);
380#[cfg(feature = "deserialize")]
381impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval {
382 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
383 use std::str::FromStr;
384 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
385 Ok(Self::from_str(&s).expect("infallible"))
386 }
387}
388#[derive(Clone, Eq, PartialEq)]
390#[non_exhaustive]
391pub enum SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
392 India,
393 Unknown(String),
395}
396impl SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
397 pub fn as_str(&self) -> &str {
398 use SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes::*;
399 match self {
400 India => "india",
401 Unknown(v) => v,
402 }
403 }
404}
405
406impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
407 type Err = std::convert::Infallible;
408 fn from_str(s: &str) -> Result<Self, Self::Err> {
409 use SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes::*;
410 match s {
411 "india" => Ok(India),
412 v => {
413 tracing::warn!(
414 "Unknown value '{}' for enum '{}'",
415 v,
416 "SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes"
417 );
418 Ok(Unknown(v.to_owned()))
419 }
420 }
421 }
422}
423impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
424 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
425 f.write_str(self.as_str())
426 }
427}
428
429impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
430 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
431 f.write_str(self.as_str())
432 }
433}
434#[cfg(feature = "serialize")]
435impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
436 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
437 where
438 S: serde::Serializer,
439 {
440 serializer.serialize_str(self.as_str())
441 }
442}
443impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes {
444 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
445 crate::Place::new(out)
446 }
447}
448
449impl miniserde::de::Visitor
450 for crate::Place<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes>
451{
452 fn string(&mut self, s: &str) -> miniserde::Result<()> {
453 use std::str::FromStr;
454 self.out = Some(
455 SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes::from_str(s)
456 .expect("infallible"),
457 );
458 Ok(())
459 }
460}
461
462stripe_types::impl_from_val_with_from_str!(
463 SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes
464);
465#[cfg(feature = "deserialize")]
466impl<'de> serde::Deserialize<'de>
467 for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes
468{
469 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
470 use std::str::FromStr;
471 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
472 Ok(Self::from_str(&s).expect("infallible"))
473 }
474}