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