stripe_shared/
payment_method_details_bacs_debit.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsBacsDebit {
5    /// Uniquely identifies this particular bank account.
6    /// You can use this attribute to check whether two bank accounts are the same.
7    pub fingerprint: Option<String>,
8    /// Last four digits of the bank account number.
9    pub last4: Option<String>,
10    /// ID of the mandate used to make this payment.
11    pub mandate: Option<String>,
12    /// Sort code of the bank account. (e.g., `10-20-30`)
13    pub sort_code: Option<String>,
14}
15#[doc(hidden)]
16pub struct PaymentMethodDetailsBacsDebitBuilder {
17    fingerprint: Option<Option<String>>,
18    last4: Option<Option<String>>,
19    mandate: Option<Option<String>>,
20    sort_code: Option<Option<String>>,
21}
22
23#[allow(
24    unused_variables,
25    irrefutable_let_patterns,
26    clippy::let_unit_value,
27    clippy::match_single_binding,
28    clippy::single_match
29)]
30const _: () = {
31    use miniserde::de::{Map, Visitor};
32    use miniserde::json::Value;
33    use miniserde::{make_place, Deserialize, Result};
34    use stripe_types::miniserde_helpers::FromValueOpt;
35    use stripe_types::{MapBuilder, ObjectDeser};
36
37    make_place!(Place);
38
39    impl Deserialize for PaymentMethodDetailsBacsDebit {
40        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
41            Place::new(out)
42        }
43    }
44
45    struct Builder<'a> {
46        out: &'a mut Option<PaymentMethodDetailsBacsDebit>,
47        builder: PaymentMethodDetailsBacsDebitBuilder,
48    }
49
50    impl Visitor for Place<PaymentMethodDetailsBacsDebit> {
51        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
52            Ok(Box::new(Builder {
53                out: &mut self.out,
54                builder: PaymentMethodDetailsBacsDebitBuilder::deser_default(),
55            }))
56        }
57    }
58
59    impl MapBuilder for PaymentMethodDetailsBacsDebitBuilder {
60        type Out = PaymentMethodDetailsBacsDebit;
61        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
62            Ok(match k {
63                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
64                "last4" => Deserialize::begin(&mut self.last4),
65                "mandate" => Deserialize::begin(&mut self.mandate),
66                "sort_code" => Deserialize::begin(&mut self.sort_code),
67
68                _ => <dyn Visitor>::ignore(),
69            })
70        }
71
72        fn deser_default() -> Self {
73            Self {
74                fingerprint: Deserialize::default(),
75                last4: Deserialize::default(),
76                mandate: Deserialize::default(),
77                sort_code: Deserialize::default(),
78            }
79        }
80
81        fn take_out(&mut self) -> Option<Self::Out> {
82            let (Some(fingerprint), Some(last4), Some(mandate), Some(sort_code)) = (
83                self.fingerprint.take(),
84                self.last4.take(),
85                self.mandate.take(),
86                self.sort_code.take(),
87            ) else {
88                return None;
89            };
90            Some(Self::Out { fingerprint, last4, mandate, sort_code })
91        }
92    }
93
94    impl<'a> Map for Builder<'a> {
95        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96            self.builder.key(k)
97        }
98
99        fn finish(&mut self) -> Result<()> {
100            *self.out = self.builder.take_out();
101            Ok(())
102        }
103    }
104
105    impl ObjectDeser for PaymentMethodDetailsBacsDebit {
106        type Builder = PaymentMethodDetailsBacsDebitBuilder;
107    }
108
109    impl FromValueOpt for PaymentMethodDetailsBacsDebit {
110        fn from_value(v: Value) -> Option<Self> {
111            let Value::Object(obj) = v else {
112                return None;
113            };
114            let mut b = PaymentMethodDetailsBacsDebitBuilder::deser_default();
115            for (k, v) in obj {
116                match k.as_str() {
117                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
118                    "last4" => b.last4 = FromValueOpt::from_value(v),
119                    "mandate" => b.mandate = FromValueOpt::from_value(v),
120                    "sort_code" => b.sort_code = FromValueOpt::from_value(v),
121
122                    _ => {}
123                }
124            }
125            b.take_out()
126        }
127    }
128};