1#[derive(Clone, Debug)]
9#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
10pub struct BankAccount {
11 pub account: Option<stripe_types::Expandable<stripe_shared::Account>>,
14 pub account_holder_name: Option<String>,
16 pub account_holder_type: Option<String>,
18 pub account_type: Option<String>,
22 pub available_payout_methods: Option<Vec<BankAccountAvailablePayoutMethods>>,
25 pub bank_name: Option<String>,
27 pub country: String,
29 pub currency: stripe_types::Currency,
31 pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
33 pub default_for_currency: Option<bool>,
35 pub fingerprint: Option<String>,
38 pub future_requirements: Option<stripe_shared::ExternalAccountRequirements>,
40 pub id: stripe_shared::BankAccountId,
42 pub last4: String,
44 pub metadata: Option<std::collections::HashMap<String, String>>,
47 pub requirements: Option<stripe_shared::ExternalAccountRequirements>,
49 pub routing_number: Option<String>,
51 pub status: String,
67}
68#[doc(hidden)]
69pub struct BankAccountBuilder {
70 account: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
71 account_holder_name: Option<Option<String>>,
72 account_holder_type: Option<Option<String>>,
73 account_type: Option<Option<String>>,
74 available_payout_methods: Option<Option<Vec<BankAccountAvailablePayoutMethods>>>,
75 bank_name: Option<Option<String>>,
76 country: Option<String>,
77 currency: Option<stripe_types::Currency>,
78 customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
79 default_for_currency: Option<Option<bool>>,
80 fingerprint: Option<Option<String>>,
81 future_requirements: Option<Option<stripe_shared::ExternalAccountRequirements>>,
82 id: Option<stripe_shared::BankAccountId>,
83 last4: Option<String>,
84 metadata: Option<Option<std::collections::HashMap<String, String>>>,
85 requirements: Option<Option<stripe_shared::ExternalAccountRequirements>>,
86 routing_number: Option<Option<String>>,
87 status: Option<String>,
88}
89
90#[allow(
91 unused_variables,
92 irrefutable_let_patterns,
93 clippy::let_unit_value,
94 clippy::match_single_binding,
95 clippy::single_match
96)]
97const _: () = {
98 use miniserde::de::{Map, Visitor};
99 use miniserde::json::Value;
100 use miniserde::{Deserialize, Result, make_place};
101 use stripe_types::miniserde_helpers::FromValueOpt;
102 use stripe_types::{MapBuilder, ObjectDeser};
103
104 make_place!(Place);
105
106 impl Deserialize for BankAccount {
107 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
108 Place::new(out)
109 }
110 }
111
112 struct Builder<'a> {
113 out: &'a mut Option<BankAccount>,
114 builder: BankAccountBuilder,
115 }
116
117 impl Visitor for Place<BankAccount> {
118 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
119 Ok(Box::new(Builder {
120 out: &mut self.out,
121 builder: BankAccountBuilder::deser_default(),
122 }))
123 }
124 }
125
126 impl MapBuilder for BankAccountBuilder {
127 type Out = BankAccount;
128 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
129 Ok(match k {
130 "account" => Deserialize::begin(&mut self.account),
131 "account_holder_name" => Deserialize::begin(&mut self.account_holder_name),
132 "account_holder_type" => Deserialize::begin(&mut self.account_holder_type),
133 "account_type" => Deserialize::begin(&mut self.account_type),
134 "available_payout_methods" => {
135 Deserialize::begin(&mut self.available_payout_methods)
136 }
137 "bank_name" => Deserialize::begin(&mut self.bank_name),
138 "country" => Deserialize::begin(&mut self.country),
139 "currency" => Deserialize::begin(&mut self.currency),
140 "customer" => Deserialize::begin(&mut self.customer),
141 "default_for_currency" => Deserialize::begin(&mut self.default_for_currency),
142 "fingerprint" => Deserialize::begin(&mut self.fingerprint),
143 "future_requirements" => Deserialize::begin(&mut self.future_requirements),
144 "id" => Deserialize::begin(&mut self.id),
145 "last4" => Deserialize::begin(&mut self.last4),
146 "metadata" => Deserialize::begin(&mut self.metadata),
147 "requirements" => Deserialize::begin(&mut self.requirements),
148 "routing_number" => Deserialize::begin(&mut self.routing_number),
149 "status" => Deserialize::begin(&mut self.status),
150 _ => <dyn Visitor>::ignore(),
151 })
152 }
153
154 fn deser_default() -> Self {
155 Self {
156 account: Deserialize::default(),
157 account_holder_name: Deserialize::default(),
158 account_holder_type: Deserialize::default(),
159 account_type: Deserialize::default(),
160 available_payout_methods: Deserialize::default(),
161 bank_name: Deserialize::default(),
162 country: Deserialize::default(),
163 currency: Deserialize::default(),
164 customer: Deserialize::default(),
165 default_for_currency: Deserialize::default(),
166 fingerprint: Deserialize::default(),
167 future_requirements: Deserialize::default(),
168 id: Deserialize::default(),
169 last4: Deserialize::default(),
170 metadata: Deserialize::default(),
171 requirements: Deserialize::default(),
172 routing_number: Deserialize::default(),
173 status: Deserialize::default(),
174 }
175 }
176
177 fn take_out(&mut self) -> Option<Self::Out> {
178 let (
179 Some(account),
180 Some(account_holder_name),
181 Some(account_holder_type),
182 Some(account_type),
183 Some(available_payout_methods),
184 Some(bank_name),
185 Some(country),
186 Some(currency),
187 Some(customer),
188 Some(default_for_currency),
189 Some(fingerprint),
190 Some(future_requirements),
191 Some(id),
192 Some(last4),
193 Some(metadata),
194 Some(requirements),
195 Some(routing_number),
196 Some(status),
197 ) = (
198 self.account.take(),
199 self.account_holder_name.take(),
200 self.account_holder_type.take(),
201 self.account_type.take(),
202 self.available_payout_methods.take(),
203 self.bank_name.take(),
204 self.country.take(),
205 self.currency.take(),
206 self.customer.take(),
207 self.default_for_currency,
208 self.fingerprint.take(),
209 self.future_requirements.take(),
210 self.id.take(),
211 self.last4.take(),
212 self.metadata.take(),
213 self.requirements.take(),
214 self.routing_number.take(),
215 self.status.take(),
216 )
217 else {
218 return None;
219 };
220 Some(Self::Out {
221 account,
222 account_holder_name,
223 account_holder_type,
224 account_type,
225 available_payout_methods,
226 bank_name,
227 country,
228 currency,
229 customer,
230 default_for_currency,
231 fingerprint,
232 future_requirements,
233 id,
234 last4,
235 metadata,
236 requirements,
237 routing_number,
238 status,
239 })
240 }
241 }
242
243 impl Map for Builder<'_> {
244 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
245 self.builder.key(k)
246 }
247
248 fn finish(&mut self) -> Result<()> {
249 *self.out = self.builder.take_out();
250 Ok(())
251 }
252 }
253
254 impl ObjectDeser for BankAccount {
255 type Builder = BankAccountBuilder;
256 }
257
258 impl FromValueOpt for BankAccount {
259 fn from_value(v: Value) -> Option<Self> {
260 let Value::Object(obj) = v else {
261 return None;
262 };
263 let mut b = BankAccountBuilder::deser_default();
264 for (k, v) in obj {
265 match k.as_str() {
266 "account" => b.account = FromValueOpt::from_value(v),
267 "account_holder_name" => b.account_holder_name = FromValueOpt::from_value(v),
268 "account_holder_type" => b.account_holder_type = FromValueOpt::from_value(v),
269 "account_type" => b.account_type = FromValueOpt::from_value(v),
270 "available_payout_methods" => {
271 b.available_payout_methods = FromValueOpt::from_value(v)
272 }
273 "bank_name" => b.bank_name = FromValueOpt::from_value(v),
274 "country" => b.country = FromValueOpt::from_value(v),
275 "currency" => b.currency = FromValueOpt::from_value(v),
276 "customer" => b.customer = FromValueOpt::from_value(v),
277 "default_for_currency" => b.default_for_currency = FromValueOpt::from_value(v),
278 "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
279 "future_requirements" => b.future_requirements = FromValueOpt::from_value(v),
280 "id" => b.id = FromValueOpt::from_value(v),
281 "last4" => b.last4 = FromValueOpt::from_value(v),
282 "metadata" => b.metadata = FromValueOpt::from_value(v),
283 "requirements" => b.requirements = FromValueOpt::from_value(v),
284 "routing_number" => b.routing_number = FromValueOpt::from_value(v),
285 "status" => b.status = FromValueOpt::from_value(v),
286 _ => {}
287 }
288 }
289 b.take_out()
290 }
291 }
292};
293#[cfg(feature = "serialize")]
294impl serde::Serialize for BankAccount {
295 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
296 use serde::ser::SerializeStruct;
297 let mut s = s.serialize_struct("BankAccount", 19)?;
298 s.serialize_field("account", &self.account)?;
299 s.serialize_field("account_holder_name", &self.account_holder_name)?;
300 s.serialize_field("account_holder_type", &self.account_holder_type)?;
301 s.serialize_field("account_type", &self.account_type)?;
302 s.serialize_field("available_payout_methods", &self.available_payout_methods)?;
303 s.serialize_field("bank_name", &self.bank_name)?;
304 s.serialize_field("country", &self.country)?;
305 s.serialize_field("currency", &self.currency)?;
306 s.serialize_field("customer", &self.customer)?;
307 s.serialize_field("default_for_currency", &self.default_for_currency)?;
308 s.serialize_field("fingerprint", &self.fingerprint)?;
309 s.serialize_field("future_requirements", &self.future_requirements)?;
310 s.serialize_field("id", &self.id)?;
311 s.serialize_field("last4", &self.last4)?;
312 s.serialize_field("metadata", &self.metadata)?;
313 s.serialize_field("requirements", &self.requirements)?;
314 s.serialize_field("routing_number", &self.routing_number)?;
315 s.serialize_field("status", &self.status)?;
316
317 s.serialize_field("object", "bank_account")?;
318 s.end()
319 }
320}
321#[derive(Clone, Eq, PartialEq)]
324#[non_exhaustive]
325pub enum BankAccountAvailablePayoutMethods {
326 Instant,
327 Standard,
328 Unknown(String),
330}
331impl BankAccountAvailablePayoutMethods {
332 pub fn as_str(&self) -> &str {
333 use BankAccountAvailablePayoutMethods::*;
334 match self {
335 Instant => "instant",
336 Standard => "standard",
337 Unknown(v) => v,
338 }
339 }
340}
341
342impl std::str::FromStr for BankAccountAvailablePayoutMethods {
343 type Err = std::convert::Infallible;
344 fn from_str(s: &str) -> Result<Self, Self::Err> {
345 use BankAccountAvailablePayoutMethods::*;
346 match s {
347 "instant" => Ok(Instant),
348 "standard" => Ok(Standard),
349 v => {
350 tracing::warn!(
351 "Unknown value '{}' for enum '{}'",
352 v,
353 "BankAccountAvailablePayoutMethods"
354 );
355 Ok(Unknown(v.to_owned()))
356 }
357 }
358 }
359}
360impl std::fmt::Display for BankAccountAvailablePayoutMethods {
361 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
362 f.write_str(self.as_str())
363 }
364}
365
366impl std::fmt::Debug for BankAccountAvailablePayoutMethods {
367 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
368 f.write_str(self.as_str())
369 }
370}
371#[cfg(feature = "serialize")]
372impl serde::Serialize for BankAccountAvailablePayoutMethods {
373 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
374 where
375 S: serde::Serializer,
376 {
377 serializer.serialize_str(self.as_str())
378 }
379}
380impl miniserde::Deserialize for BankAccountAvailablePayoutMethods {
381 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
382 crate::Place::new(out)
383 }
384}
385
386impl miniserde::de::Visitor for crate::Place<BankAccountAvailablePayoutMethods> {
387 fn string(&mut self, s: &str) -> miniserde::Result<()> {
388 use std::str::FromStr;
389 self.out = Some(BankAccountAvailablePayoutMethods::from_str(s).expect("infallible"));
390 Ok(())
391 }
392}
393
394stripe_types::impl_from_val_with_from_str!(BankAccountAvailablePayoutMethods);
395#[cfg(feature = "deserialize")]
396impl<'de> serde::Deserialize<'de> for BankAccountAvailablePayoutMethods {
397 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
398 use std::str::FromStr;
399 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
400 Ok(Self::from_str(&s).expect("infallible"))
401 }
402}
403impl stripe_types::Object for BankAccount {
404 type Id = stripe_shared::BankAccountId;
405 fn id(&self) -> &Self::Id {
406 &self.id
407 }
408
409 fn into_id(self) -> Self::Id {
410 self.id
411 }
412}
413stripe_types::def_id!(BankAccountId);