#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct PaymentMethodDetailsUsBankAccount {
pub account_holder_type: Option<PaymentMethodDetailsUsBankAccountAccountHolderType>,
pub account_type: Option<PaymentMethodDetailsUsBankAccountAccountType>,
pub bank_name: Option<String>,
pub expected_debit_date: Option<String>,
pub fingerprint: Option<String>,
pub last4: Option<String>,
pub mandate: Option<stripe_types::Expandable<stripe_shared::Mandate>>,
pub payment_reference: Option<String>,
pub routing_number: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentMethodDetailsUsBankAccount {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("PaymentMethodDetailsUsBankAccount").finish_non_exhaustive()
}
}
#[doc(hidden)]
pub struct PaymentMethodDetailsUsBankAccountBuilder {
account_holder_type: Option<Option<PaymentMethodDetailsUsBankAccountAccountHolderType>>,
account_type: Option<Option<PaymentMethodDetailsUsBankAccountAccountType>>,
bank_name: Option<Option<String>>,
expected_debit_date: Option<Option<String>>,
fingerprint: Option<Option<String>>,
last4: Option<Option<String>>,
mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>,
payment_reference: Option<Option<String>>,
routing_number: Option<Option<String>>,
}
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
use miniserde::{Deserialize, Result, make_place};
use stripe_types::miniserde_helpers::FromValueOpt;
use stripe_types::{MapBuilder, ObjectDeser};
make_place!(Place);
impl Deserialize for PaymentMethodDetailsUsBankAccount {
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
Place::new(out)
}
}
struct Builder<'a> {
out: &'a mut Option<PaymentMethodDetailsUsBankAccount>,
builder: PaymentMethodDetailsUsBankAccountBuilder,
}
impl Visitor for Place<PaymentMethodDetailsUsBankAccount> {
fn map(&mut self) -> Result<Box<dyn Map + '_>> {
Ok(Box::new(Builder {
out: &mut self.out,
builder: PaymentMethodDetailsUsBankAccountBuilder::deser_default(),
}))
}
}
impl MapBuilder for PaymentMethodDetailsUsBankAccountBuilder {
type Out = PaymentMethodDetailsUsBankAccount;
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
Ok(match k {
"account_holder_type" => Deserialize::begin(&mut self.account_holder_type),
"account_type" => Deserialize::begin(&mut self.account_type),
"bank_name" => Deserialize::begin(&mut self.bank_name),
"expected_debit_date" => Deserialize::begin(&mut self.expected_debit_date),
"fingerprint" => Deserialize::begin(&mut self.fingerprint),
"last4" => Deserialize::begin(&mut self.last4),
"mandate" => Deserialize::begin(&mut self.mandate),
"payment_reference" => Deserialize::begin(&mut self.payment_reference),
"routing_number" => Deserialize::begin(&mut self.routing_number),
_ => <dyn Visitor>::ignore(),
})
}
fn deser_default() -> Self {
Self {
account_holder_type: Some(None),
account_type: Some(None),
bank_name: Some(None),
expected_debit_date: Some(None),
fingerprint: Some(None),
last4: Some(None),
mandate: Some(None),
payment_reference: Some(None),
routing_number: Some(None),
}
}
fn take_out(&mut self) -> Option<Self::Out> {
let (
Some(account_holder_type),
Some(account_type),
Some(bank_name),
Some(expected_debit_date),
Some(fingerprint),
Some(last4),
Some(mandate),
Some(payment_reference),
Some(routing_number),
) = (
self.account_holder_type.take(),
self.account_type.take(),
self.bank_name.take(),
self.expected_debit_date.take(),
self.fingerprint.take(),
self.last4.take(),
self.mandate.take(),
self.payment_reference.take(),
self.routing_number.take(),
)
else {
return None;
};
Some(Self::Out {
account_holder_type,
account_type,
bank_name,
expected_debit_date,
fingerprint,
last4,
mandate,
payment_reference,
routing_number,
})
}
}
impl Map for Builder<'_> {
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
self.builder.key(k)
}
fn finish(&mut self) -> Result<()> {
*self.out = self.builder.take_out();
Ok(())
}
}
impl ObjectDeser for PaymentMethodDetailsUsBankAccount {
type Builder = PaymentMethodDetailsUsBankAccountBuilder;
}
impl FromValueOpt for PaymentMethodDetailsUsBankAccount {
fn from_value(v: Value) -> Option<Self> {
let Value::Object(obj) = v else {
return None;
};
let mut b = PaymentMethodDetailsUsBankAccountBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"account_holder_type" => b.account_holder_type = FromValueOpt::from_value(v),
"account_type" => b.account_type = FromValueOpt::from_value(v),
"bank_name" => b.bank_name = FromValueOpt::from_value(v),
"expected_debit_date" => b.expected_debit_date = FromValueOpt::from_value(v),
"fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
"last4" => b.last4 = FromValueOpt::from_value(v),
"mandate" => b.mandate = FromValueOpt::from_value(v),
"payment_reference" => b.payment_reference = FromValueOpt::from_value(v),
"routing_number" => b.routing_number = FromValueOpt::from_value(v),
_ => {}
}
}
b.take_out()
}
}
};
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentMethodDetailsUsBankAccountAccountHolderType {
Company,
Individual,
Unknown(String),
}
impl PaymentMethodDetailsUsBankAccountAccountHolderType {
pub fn as_str(&self) -> &str {
use PaymentMethodDetailsUsBankAccountAccountHolderType::*;
match self {
Company => "company",
Individual => "individual",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentMethodDetailsUsBankAccountAccountHolderType {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentMethodDetailsUsBankAccountAccountHolderType::*;
match s {
"company" => Ok(Company),
"individual" => Ok(Individual),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentMethodDetailsUsBankAccountAccountHolderType"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentMethodDetailsUsBankAccountAccountHolderType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentMethodDetailsUsBankAccountAccountHolderType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentMethodDetailsUsBankAccountAccountHolderType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentMethodDetailsUsBankAccountAccountHolderType))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentMethodDetailsUsBankAccountAccountHolderType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentMethodDetailsUsBankAccountAccountHolderType {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsUsBankAccountAccountHolderType> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(
PaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s).expect("infallible"),
);
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsUsBankAccountAccountHolderType);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsUsBankAccountAccountHolderType {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentMethodDetailsUsBankAccountAccountType {
Checking,
Savings,
Unknown(String),
}
impl PaymentMethodDetailsUsBankAccountAccountType {
pub fn as_str(&self) -> &str {
use PaymentMethodDetailsUsBankAccountAccountType::*;
match self {
Checking => "checking",
Savings => "savings",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentMethodDetailsUsBankAccountAccountType {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentMethodDetailsUsBankAccountAccountType::*;
match s {
"checking" => Ok(Checking),
"savings" => Ok(Savings),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentMethodDetailsUsBankAccountAccountType"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentMethodDetailsUsBankAccountAccountType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentMethodDetailsUsBankAccountAccountType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentMethodDetailsUsBankAccountAccountType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentMethodDetailsUsBankAccountAccountType))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentMethodDetailsUsBankAccountAccountType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentMethodDetailsUsBankAccountAccountType {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsUsBankAccountAccountType> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out =
Some(PaymentMethodDetailsUsBankAccountAccountType::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsUsBankAccountAccountType);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsUsBankAccountAccountType {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}