stripe_shared/
setup_intent_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 SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit {
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 SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder {
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::{Deserialize, Result, make_place};
27    use stripe_types::miniserde_helpers::FromValueOpt;
28    use stripe_types::{MapBuilder, ObjectDeser};
29
30    make_place!(Place);
31
32    impl Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit {
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<SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit>,
40        builder: SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder,
41    }
42
43    impl Visitor for Place<SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit> {
44        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
45            Ok(Box::new(Builder {
46                out: &mut self.out,
47                builder:
48                    SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default(),
49            }))
50        }
51    }
52
53    impl MapBuilder for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder {
54        type Out = SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit;
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                _ => <dyn Visitor>::ignore(),
59            })
60        }
61
62        fn deser_default() -> Self {
63            Self { reference_prefix: Deserialize::default() }
64        }
65
66        fn take_out(&mut self) -> Option<Self::Out> {
67            let (Some(reference_prefix),) = (self.reference_prefix.take(),) else {
68                return None;
69            };
70            Some(Self::Out { reference_prefix })
71        }
72    }
73
74    impl Map for Builder<'_> {
75        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
76            self.builder.key(k)
77        }
78
79        fn finish(&mut self) -> Result<()> {
80            *self.out = self.builder.take_out();
81            Ok(())
82        }
83    }
84
85    impl ObjectDeser for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit {
86        type Builder = SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder;
87    }
88
89    impl FromValueOpt for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit {
90        fn from_value(v: Value) -> Option<Self> {
91            let Value::Object(obj) = v else {
92                return None;
93            };
94            let mut b =
95                SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder::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            b.take_out()
103        }
104    }
105};