Skip to main content

stripe_shared/
setup_intent_payment_method_options_mandate_options_sepa_debit.rs

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