stripe_shared/
payment_method_ideal.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodIdeal {
5    /// The customer's bank, if provided.
6    /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `buut`, `finom`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`.
7    pub bank: Option<PaymentMethodIdealBank>,
8    /// The Bank Identifier Code of the customer's bank, if the bank was provided.
9    pub bic: Option<PaymentMethodIdealBic>,
10}
11#[doc(hidden)]
12pub struct PaymentMethodIdealBuilder {
13    bank: Option<Option<PaymentMethodIdealBank>>,
14    bic: Option<Option<PaymentMethodIdealBic>>,
15}
16
17#[allow(
18    unused_variables,
19    irrefutable_let_patterns,
20    clippy::let_unit_value,
21    clippy::match_single_binding,
22    clippy::single_match
23)]
24const _: () = {
25    use miniserde::de::{Map, Visitor};
26    use miniserde::json::Value;
27    use miniserde::{Deserialize, Result, make_place};
28    use stripe_types::miniserde_helpers::FromValueOpt;
29    use stripe_types::{MapBuilder, ObjectDeser};
30
31    make_place!(Place);
32
33    impl Deserialize for PaymentMethodIdeal {
34        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
35            Place::new(out)
36        }
37    }
38
39    struct Builder<'a> {
40        out: &'a mut Option<PaymentMethodIdeal>,
41        builder: PaymentMethodIdealBuilder,
42    }
43
44    impl Visitor for Place<PaymentMethodIdeal> {
45        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
46            Ok(Box::new(Builder {
47                out: &mut self.out,
48                builder: PaymentMethodIdealBuilder::deser_default(),
49            }))
50        }
51    }
52
53    impl MapBuilder for PaymentMethodIdealBuilder {
54        type Out = PaymentMethodIdeal;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "bank" => Deserialize::begin(&mut self.bank),
58                "bic" => Deserialize::begin(&mut self.bic),
59                _ => <dyn Visitor>::ignore(),
60            })
61        }
62
63        fn deser_default() -> Self {
64            Self { bank: Deserialize::default(), bic: Deserialize::default() }
65        }
66
67        fn take_out(&mut self) -> Option<Self::Out> {
68            let (Some(bank), Some(bic)) = (self.bank.take(), self.bic.take()) else {
69                return None;
70            };
71            Some(Self::Out { bank, bic })
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 PaymentMethodIdeal {
87        type Builder = PaymentMethodIdealBuilder;
88    }
89
90    impl FromValueOpt for PaymentMethodIdeal {
91        fn from_value(v: Value) -> Option<Self> {
92            let Value::Object(obj) = v else {
93                return None;
94            };
95            let mut b = PaymentMethodIdealBuilder::deser_default();
96            for (k, v) in obj {
97                match k.as_str() {
98                    "bank" => b.bank = FromValueOpt::from_value(v),
99                    "bic" => b.bic = FromValueOpt::from_value(v),
100                    _ => {}
101                }
102            }
103            b.take_out()
104        }
105    }
106};
107/// The customer's bank, if provided.
108/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `buut`, `finom`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`.
109#[derive(Clone, Eq, PartialEq)]
110#[non_exhaustive]
111pub enum PaymentMethodIdealBank {
112    AbnAmro,
113    AsnBank,
114    Bunq,
115    Buut,
116    Finom,
117    Handelsbanken,
118    Ing,
119    Knab,
120    Moneyou,
121    N26,
122    Nn,
123    Rabobank,
124    Regiobank,
125    Revolut,
126    SnsBank,
127    TriodosBank,
128    VanLanschot,
129    Yoursafe,
130    /// An unrecognized value from Stripe. Should not be used as a request parameter.
131    Unknown(String),
132}
133impl PaymentMethodIdealBank {
134    pub fn as_str(&self) -> &str {
135        use PaymentMethodIdealBank::*;
136        match self {
137            AbnAmro => "abn_amro",
138            AsnBank => "asn_bank",
139            Bunq => "bunq",
140            Buut => "buut",
141            Finom => "finom",
142            Handelsbanken => "handelsbanken",
143            Ing => "ing",
144            Knab => "knab",
145            Moneyou => "moneyou",
146            N26 => "n26",
147            Nn => "nn",
148            Rabobank => "rabobank",
149            Regiobank => "regiobank",
150            Revolut => "revolut",
151            SnsBank => "sns_bank",
152            TriodosBank => "triodos_bank",
153            VanLanschot => "van_lanschot",
154            Yoursafe => "yoursafe",
155            Unknown(v) => v,
156        }
157    }
158}
159
160impl std::str::FromStr for PaymentMethodIdealBank {
161    type Err = std::convert::Infallible;
162    fn from_str(s: &str) -> Result<Self, Self::Err> {
163        use PaymentMethodIdealBank::*;
164        match s {
165            "abn_amro" => Ok(AbnAmro),
166            "asn_bank" => Ok(AsnBank),
167            "bunq" => Ok(Bunq),
168            "buut" => Ok(Buut),
169            "finom" => Ok(Finom),
170            "handelsbanken" => Ok(Handelsbanken),
171            "ing" => Ok(Ing),
172            "knab" => Ok(Knab),
173            "moneyou" => Ok(Moneyou),
174            "n26" => Ok(N26),
175            "nn" => Ok(Nn),
176            "rabobank" => Ok(Rabobank),
177            "regiobank" => Ok(Regiobank),
178            "revolut" => Ok(Revolut),
179            "sns_bank" => Ok(SnsBank),
180            "triodos_bank" => Ok(TriodosBank),
181            "van_lanschot" => Ok(VanLanschot),
182            "yoursafe" => Ok(Yoursafe),
183            v => {
184                tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentMethodIdealBank");
185                Ok(Unknown(v.to_owned()))
186            }
187        }
188    }
189}
190impl std::fmt::Display for PaymentMethodIdealBank {
191    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
192        f.write_str(self.as_str())
193    }
194}
195
196impl std::fmt::Debug for PaymentMethodIdealBank {
197    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
198        f.write_str(self.as_str())
199    }
200}
201#[cfg(feature = "serialize")]
202impl serde::Serialize for PaymentMethodIdealBank {
203    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
204    where
205        S: serde::Serializer,
206    {
207        serializer.serialize_str(self.as_str())
208    }
209}
210impl miniserde::Deserialize for PaymentMethodIdealBank {
211    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
212        crate::Place::new(out)
213    }
214}
215
216impl miniserde::de::Visitor for crate::Place<PaymentMethodIdealBank> {
217    fn string(&mut self, s: &str) -> miniserde::Result<()> {
218        use std::str::FromStr;
219        self.out = Some(PaymentMethodIdealBank::from_str(s).expect("infallible"));
220        Ok(())
221    }
222}
223
224stripe_types::impl_from_val_with_from_str!(PaymentMethodIdealBank);
225#[cfg(feature = "deserialize")]
226impl<'de> serde::Deserialize<'de> for PaymentMethodIdealBank {
227    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
228        use std::str::FromStr;
229        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
230        Ok(Self::from_str(&s).expect("infallible"))
231    }
232}
233/// The Bank Identifier Code of the customer's bank, if the bank was provided.
234#[derive(Clone, Eq, PartialEq)]
235#[non_exhaustive]
236pub enum PaymentMethodIdealBic {
237    Abnanl2a,
238    Asnbnl21,
239    Bitsnl2a,
240    Bunqnl2a,
241    Buutnl2a,
242    Fnomnl22,
243    Fvlbnl22,
244    Handnl2a,
245    Ingbnl2a,
246    Knabnl2h,
247    Moyonl21,
248    Nnbanl2g,
249    Ntsbdeb1,
250    Rabonl2u,
251    Rbrbnl21,
252    Revoie23,
253    Revolt21,
254    Snsbnl2a,
255    Trionl2u,
256    /// An unrecognized value from Stripe. Should not be used as a request parameter.
257    Unknown(String),
258}
259impl PaymentMethodIdealBic {
260    pub fn as_str(&self) -> &str {
261        use PaymentMethodIdealBic::*;
262        match self {
263            Abnanl2a => "ABNANL2A",
264            Asnbnl21 => "ASNBNL21",
265            Bitsnl2a => "BITSNL2A",
266            Bunqnl2a => "BUNQNL2A",
267            Buutnl2a => "BUUTNL2A",
268            Fnomnl22 => "FNOMNL22",
269            Fvlbnl22 => "FVLBNL22",
270            Handnl2a => "HANDNL2A",
271            Ingbnl2a => "INGBNL2A",
272            Knabnl2h => "KNABNL2H",
273            Moyonl21 => "MOYONL21",
274            Nnbanl2g => "NNBANL2G",
275            Ntsbdeb1 => "NTSBDEB1",
276            Rabonl2u => "RABONL2U",
277            Rbrbnl21 => "RBRBNL21",
278            Revoie23 => "REVOIE23",
279            Revolt21 => "REVOLT21",
280            Snsbnl2a => "SNSBNL2A",
281            Trionl2u => "TRIONL2U",
282            Unknown(v) => v,
283        }
284    }
285}
286
287impl std::str::FromStr for PaymentMethodIdealBic {
288    type Err = std::convert::Infallible;
289    fn from_str(s: &str) -> Result<Self, Self::Err> {
290        use PaymentMethodIdealBic::*;
291        match s {
292            "ABNANL2A" => Ok(Abnanl2a),
293            "ASNBNL21" => Ok(Asnbnl21),
294            "BITSNL2A" => Ok(Bitsnl2a),
295            "BUNQNL2A" => Ok(Bunqnl2a),
296            "BUUTNL2A" => Ok(Buutnl2a),
297            "FNOMNL22" => Ok(Fnomnl22),
298            "FVLBNL22" => Ok(Fvlbnl22),
299            "HANDNL2A" => Ok(Handnl2a),
300            "INGBNL2A" => Ok(Ingbnl2a),
301            "KNABNL2H" => Ok(Knabnl2h),
302            "MOYONL21" => Ok(Moyonl21),
303            "NNBANL2G" => Ok(Nnbanl2g),
304            "NTSBDEB1" => Ok(Ntsbdeb1),
305            "RABONL2U" => Ok(Rabonl2u),
306            "RBRBNL21" => Ok(Rbrbnl21),
307            "REVOIE23" => Ok(Revoie23),
308            "REVOLT21" => Ok(Revolt21),
309            "SNSBNL2A" => Ok(Snsbnl2a),
310            "TRIONL2U" => Ok(Trionl2u),
311            v => {
312                tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentMethodIdealBic");
313                Ok(Unknown(v.to_owned()))
314            }
315        }
316    }
317}
318impl std::fmt::Display for PaymentMethodIdealBic {
319    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
320        f.write_str(self.as_str())
321    }
322}
323
324impl std::fmt::Debug for PaymentMethodIdealBic {
325    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
326        f.write_str(self.as_str())
327    }
328}
329#[cfg(feature = "serialize")]
330impl serde::Serialize for PaymentMethodIdealBic {
331    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
332    where
333        S: serde::Serializer,
334    {
335        serializer.serialize_str(self.as_str())
336    }
337}
338impl miniserde::Deserialize for PaymentMethodIdealBic {
339    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
340        crate::Place::new(out)
341    }
342}
343
344impl miniserde::de::Visitor for crate::Place<PaymentMethodIdealBic> {
345    fn string(&mut self, s: &str) -> miniserde::Result<()> {
346        use std::str::FromStr;
347        self.out = Some(PaymentMethodIdealBic::from_str(s).expect("infallible"));
348        Ok(())
349    }
350}
351
352stripe_types::impl_from_val_with_from_str!(PaymentMethodIdealBic);
353#[cfg(feature = "deserialize")]
354impl<'de> serde::Deserialize<'de> for PaymentMethodIdealBic {
355    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
356        use std::str::FromStr;
357        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
358        Ok(Self::from_str(&s).expect("infallible"))
359    }
360}