1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsP24 {
5 pub bank: Option<PaymentMethodDetailsP24Bank>,
8 pub reference: Option<String>,
10 pub verified_name: Option<String>,
14}
15#[doc(hidden)]
16pub struct PaymentMethodDetailsP24Builder {
17 bank: Option<Option<PaymentMethodDetailsP24Bank>>,
18 reference: Option<Option<String>>,
19 verified_name: Option<Option<String>>,
20}
21
22#[allow(
23 unused_variables,
24 irrefutable_let_patterns,
25 clippy::let_unit_value,
26 clippy::match_single_binding,
27 clippy::single_match
28)]
29const _: () = {
30 use miniserde::de::{Map, Visitor};
31 use miniserde::json::Value;
32 use miniserde::{Deserialize, Result, make_place};
33 use stripe_types::miniserde_helpers::FromValueOpt;
34 use stripe_types::{MapBuilder, ObjectDeser};
35
36 make_place!(Place);
37
38 impl Deserialize for PaymentMethodDetailsP24 {
39 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
40 Place::new(out)
41 }
42 }
43
44 struct Builder<'a> {
45 out: &'a mut Option<PaymentMethodDetailsP24>,
46 builder: PaymentMethodDetailsP24Builder,
47 }
48
49 impl Visitor for Place<PaymentMethodDetailsP24> {
50 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
51 Ok(Box::new(Builder {
52 out: &mut self.out,
53 builder: PaymentMethodDetailsP24Builder::deser_default(),
54 }))
55 }
56 }
57
58 impl MapBuilder for PaymentMethodDetailsP24Builder {
59 type Out = PaymentMethodDetailsP24;
60 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
61 Ok(match k {
62 "bank" => Deserialize::begin(&mut self.bank),
63 "reference" => Deserialize::begin(&mut self.reference),
64 "verified_name" => Deserialize::begin(&mut self.verified_name),
65 _ => <dyn Visitor>::ignore(),
66 })
67 }
68
69 fn deser_default() -> Self {
70 Self {
71 bank: Deserialize::default(),
72 reference: Deserialize::default(),
73 verified_name: Deserialize::default(),
74 }
75 }
76
77 fn take_out(&mut self) -> Option<Self::Out> {
78 let (Some(bank), Some(reference), Some(verified_name)) =
79 (self.bank.take(), self.reference.take(), self.verified_name.take())
80 else {
81 return None;
82 };
83 Some(Self::Out { bank, reference, verified_name })
84 }
85 }
86
87 impl Map for Builder<'_> {
88 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89 self.builder.key(k)
90 }
91
92 fn finish(&mut self) -> Result<()> {
93 *self.out = self.builder.take_out();
94 Ok(())
95 }
96 }
97
98 impl ObjectDeser for PaymentMethodDetailsP24 {
99 type Builder = PaymentMethodDetailsP24Builder;
100 }
101
102 impl FromValueOpt for PaymentMethodDetailsP24 {
103 fn from_value(v: Value) -> Option<Self> {
104 let Value::Object(obj) = v else {
105 return None;
106 };
107 let mut b = PaymentMethodDetailsP24Builder::deser_default();
108 for (k, v) in obj {
109 match k.as_str() {
110 "bank" => b.bank = FromValueOpt::from_value(v),
111 "reference" => b.reference = FromValueOpt::from_value(v),
112 "verified_name" => b.verified_name = FromValueOpt::from_value(v),
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};
120#[derive(Clone, Eq, PartialEq)]
123#[non_exhaustive]
124pub enum PaymentMethodDetailsP24Bank {
125 AliorBank,
126 BankMillennium,
127 BankNowyBfgSa,
128 BankPekaoSa,
129 BankiSpbdzielcze,
130 Blik,
131 BnpParibas,
132 Boz,
133 CitiHandlowy,
134 CreditAgricole,
135 Envelobank,
136 EtransferPocztowy24,
137 GetinBank,
138 Ideabank,
139 Ing,
140 Inteligo,
141 MbankMtransfer,
142 NestPrzelew,
143 NoblePay,
144 PbacZIpko,
145 PlusBank,
146 SantanderPrzelew24,
147 TmobileUsbugiBankowe,
148 ToyotaBank,
149 Velobank,
150 VolkswagenBank,
151 Unknown(String),
153}
154impl PaymentMethodDetailsP24Bank {
155 pub fn as_str(&self) -> &str {
156 use PaymentMethodDetailsP24Bank::*;
157 match self {
158 AliorBank => "alior_bank",
159 BankMillennium => "bank_millennium",
160 BankNowyBfgSa => "bank_nowy_bfg_sa",
161 BankPekaoSa => "bank_pekao_sa",
162 BankiSpbdzielcze => "banki_spbdzielcze",
163 Blik => "blik",
164 BnpParibas => "bnp_paribas",
165 Boz => "boz",
166 CitiHandlowy => "citi_handlowy",
167 CreditAgricole => "credit_agricole",
168 Envelobank => "envelobank",
169 EtransferPocztowy24 => "etransfer_pocztowy24",
170 GetinBank => "getin_bank",
171 Ideabank => "ideabank",
172 Ing => "ing",
173 Inteligo => "inteligo",
174 MbankMtransfer => "mbank_mtransfer",
175 NestPrzelew => "nest_przelew",
176 NoblePay => "noble_pay",
177 PbacZIpko => "pbac_z_ipko",
178 PlusBank => "plus_bank",
179 SantanderPrzelew24 => "santander_przelew24",
180 TmobileUsbugiBankowe => "tmobile_usbugi_bankowe",
181 ToyotaBank => "toyota_bank",
182 Velobank => "velobank",
183 VolkswagenBank => "volkswagen_bank",
184 Unknown(v) => v,
185 }
186 }
187}
188
189impl std::str::FromStr for PaymentMethodDetailsP24Bank {
190 type Err = std::convert::Infallible;
191 fn from_str(s: &str) -> Result<Self, Self::Err> {
192 use PaymentMethodDetailsP24Bank::*;
193 match s {
194 "alior_bank" => Ok(AliorBank),
195 "bank_millennium" => Ok(BankMillennium),
196 "bank_nowy_bfg_sa" => Ok(BankNowyBfgSa),
197 "bank_pekao_sa" => Ok(BankPekaoSa),
198 "banki_spbdzielcze" => Ok(BankiSpbdzielcze),
199 "blik" => Ok(Blik),
200 "bnp_paribas" => Ok(BnpParibas),
201 "boz" => Ok(Boz),
202 "citi_handlowy" => Ok(CitiHandlowy),
203 "credit_agricole" => Ok(CreditAgricole),
204 "envelobank" => Ok(Envelobank),
205 "etransfer_pocztowy24" => Ok(EtransferPocztowy24),
206 "getin_bank" => Ok(GetinBank),
207 "ideabank" => Ok(Ideabank),
208 "ing" => Ok(Ing),
209 "inteligo" => Ok(Inteligo),
210 "mbank_mtransfer" => Ok(MbankMtransfer),
211 "nest_przelew" => Ok(NestPrzelew),
212 "noble_pay" => Ok(NoblePay),
213 "pbac_z_ipko" => Ok(PbacZIpko),
214 "plus_bank" => Ok(PlusBank),
215 "santander_przelew24" => Ok(SantanderPrzelew24),
216 "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe),
217 "toyota_bank" => Ok(ToyotaBank),
218 "velobank" => Ok(Velobank),
219 "volkswagen_bank" => Ok(VolkswagenBank),
220 v => {
221 tracing::warn!(
222 "Unknown value '{}' for enum '{}'",
223 v,
224 "PaymentMethodDetailsP24Bank"
225 );
226 Ok(Unknown(v.to_owned()))
227 }
228 }
229 }
230}
231impl std::fmt::Display for PaymentMethodDetailsP24Bank {
232 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
233 f.write_str(self.as_str())
234 }
235}
236
237impl std::fmt::Debug for PaymentMethodDetailsP24Bank {
238 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
239 f.write_str(self.as_str())
240 }
241}
242#[cfg(feature = "serialize")]
243impl serde::Serialize for PaymentMethodDetailsP24Bank {
244 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
245 where
246 S: serde::Serializer,
247 {
248 serializer.serialize_str(self.as_str())
249 }
250}
251impl miniserde::Deserialize for PaymentMethodDetailsP24Bank {
252 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
253 crate::Place::new(out)
254 }
255}
256
257impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsP24Bank> {
258 fn string(&mut self, s: &str) -> miniserde::Result<()> {
259 use std::str::FromStr;
260 self.out = Some(PaymentMethodDetailsP24Bank::from_str(s).expect("infallible"));
261 Ok(())
262 }
263}
264
265stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsP24Bank);
266#[cfg(feature = "deserialize")]
267impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsP24Bank {
268 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
269 use std::str::FromStr;
270 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
271 Ok(Self::from_str(&s).expect("infallible"))
272 }
273}