stripe_shared/
checkout_payment_method_options_mandate_options_sepa_debit.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct CheckoutPaymentMethodOptionsMandateOptionsSepaDebit {
5    /// Prefix used to generate the Mandate reference.
6    /// Must be at most 12 characters long.
7    /// Must consist of only uppercase letters, numbers, spaces, or the following special characters: '/', '_', '-', '&', '.'.
8    /// Cannot begin with 'STRIPE'.
9    pub reference_prefix: Option<String>,
10}
11#[doc(hidden)]
12pub struct CheckoutPaymentMethodOptionsMandateOptionsSepaDebitBuilder {
13    reference_prefix: Option<Option<String>>,
14}
15
16#[allow(
17    unused_variables,
18    irrefutable_let_patterns,
19    clippy::let_unit_value,
20    clippy::match_single_binding,
21    clippy::single_match
22)]
23const _: () = {
24    use miniserde::de::{Map, Visitor};
25    use miniserde::json::Value;
26    use miniserde::{make_place, Deserialize, Result};
27    use stripe_types::miniserde_helpers::FromValueOpt;
28    use stripe_types::{MapBuilder, ObjectDeser};
29
30    make_place!(Place);
31
32    impl Deserialize for CheckoutPaymentMethodOptionsMandateOptionsSepaDebit {
33        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
34            Place::new(out)
35        }
36    }
37
38    struct Builder<'a> {
39        out: &'a mut Option<CheckoutPaymentMethodOptionsMandateOptionsSepaDebit>,
40        builder: CheckoutPaymentMethodOptionsMandateOptionsSepaDebitBuilder,
41    }
42
43    impl Visitor for Place<CheckoutPaymentMethodOptionsMandateOptionsSepaDebit> {
44        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
45            Ok(Box::new(Builder {
46                out: &mut self.out,
47                builder: CheckoutPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default(
48                ),
49            }))
50        }
51    }
52
53    impl MapBuilder for CheckoutPaymentMethodOptionsMandateOptionsSepaDebitBuilder {
54        type Out = CheckoutPaymentMethodOptionsMandateOptionsSepaDebit;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "reference_prefix" => Deserialize::begin(&mut self.reference_prefix),
58
59                _ => <dyn Visitor>::ignore(),
60            })
61        }
62
63        fn deser_default() -> Self {
64            Self { reference_prefix: Deserialize::default() }
65        }
66
67        fn take_out(&mut self) -> Option<Self::Out> {
68            let (Some(reference_prefix),) = (self.reference_prefix.take(),) else {
69                return None;
70            };
71            Some(Self::Out { reference_prefix })
72        }
73    }
74
75    impl Map for Builder<'_> {
76        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
77            self.builder.key(k)
78        }
79
80        fn finish(&mut self) -> Result<()> {
81            *self.out = self.builder.take_out();
82            Ok(())
83        }
84    }
85
86    impl ObjectDeser for CheckoutPaymentMethodOptionsMandateOptionsSepaDebit {
87        type Builder = CheckoutPaymentMethodOptionsMandateOptionsSepaDebitBuilder;
88    }
89
90    impl FromValueOpt for CheckoutPaymentMethodOptionsMandateOptionsSepaDebit {
91        fn from_value(v: Value) -> Option<Self> {
92            let Value::Object(obj) = v else {
93                return None;
94            };
95            let mut b = CheckoutPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default();
96            for (k, v) in obj {
97                match k.as_str() {
98                    "reference_prefix" => b.reference_prefix = FromValueOpt::from_value(v),
99
100                    _ => {}
101                }
102            }
103            b.take_out()
104        }
105    }
106};