#[derive(Clone, Eq, PartialEq)]
#[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 PaymentIntentNextActionDisplayBankTransferInstructions {
pub amount_remaining: Option<i64>,
pub currency: Option<stripe_types::Currency>,
pub financial_addresses:
Option<Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>>,
pub hosted_instructions_url: Option<String>,
pub reference: Option<String>,
#[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
pub type_: PaymentIntentNextActionDisplayBankTransferInstructionsType,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentNextActionDisplayBankTransferInstructions {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("PaymentIntentNextActionDisplayBankTransferInstructions")
.finish_non_exhaustive()
}
}
#[doc(hidden)]
pub struct PaymentIntentNextActionDisplayBankTransferInstructionsBuilder {
amount_remaining: Option<Option<i64>>,
currency: Option<Option<stripe_types::Currency>>,
financial_addresses:
Option<Option<Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>>>,
hosted_instructions_url: Option<Option<String>>,
reference: Option<Option<String>>,
type_: Option<PaymentIntentNextActionDisplayBankTransferInstructionsType>,
}
#[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 PaymentIntentNextActionDisplayBankTransferInstructions {
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
Place::new(out)
}
}
struct Builder<'a> {
out: &'a mut Option<PaymentIntentNextActionDisplayBankTransferInstructions>,
builder: PaymentIntentNextActionDisplayBankTransferInstructionsBuilder,
}
impl Visitor for Place<PaymentIntentNextActionDisplayBankTransferInstructions> {
fn map(&mut self) -> Result<Box<dyn Map + '_>> {
Ok(Box::new(Builder {
out: &mut self.out,
builder:
PaymentIntentNextActionDisplayBankTransferInstructionsBuilder::deser_default(),
}))
}
}
impl MapBuilder for PaymentIntentNextActionDisplayBankTransferInstructionsBuilder {
type Out = PaymentIntentNextActionDisplayBankTransferInstructions;
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
Ok(match k {
"amount_remaining" => Deserialize::begin(&mut self.amount_remaining),
"currency" => Deserialize::begin(&mut self.currency),
"financial_addresses" => Deserialize::begin(&mut self.financial_addresses),
"hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url),
"reference" => Deserialize::begin(&mut self.reference),
"type" => Deserialize::begin(&mut self.type_),
_ => <dyn Visitor>::ignore(),
})
}
fn deser_default() -> Self {
Self {
amount_remaining: Some(None),
currency: Some(None),
financial_addresses: Some(None),
hosted_instructions_url: Some(None),
reference: Some(None),
type_: None,
}
}
fn take_out(&mut self) -> Option<Self::Out> {
let (
Some(amount_remaining),
Some(currency),
Some(financial_addresses),
Some(hosted_instructions_url),
Some(reference),
Some(type_),
) = (
self.amount_remaining,
self.currency.take(),
self.financial_addresses.take(),
self.hosted_instructions_url.take(),
self.reference.take(),
self.type_.take(),
)
else {
return None;
};
Some(Self::Out {
amount_remaining,
currency,
financial_addresses,
hosted_instructions_url,
reference,
type_,
})
}
}
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 PaymentIntentNextActionDisplayBankTransferInstructions {
type Builder = PaymentIntentNextActionDisplayBankTransferInstructionsBuilder;
}
impl FromValueOpt for PaymentIntentNextActionDisplayBankTransferInstructions {
fn from_value(v: Value) -> Option<Self> {
let Value::Object(obj) = v else {
return None;
};
let mut b =
PaymentIntentNextActionDisplayBankTransferInstructionsBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"amount_remaining" => b.amount_remaining = FromValueOpt::from_value(v),
"currency" => b.currency = FromValueOpt::from_value(v),
"financial_addresses" => b.financial_addresses = FromValueOpt::from_value(v),
"hosted_instructions_url" => {
b.hosted_instructions_url = FromValueOpt::from_value(v)
}
"reference" => b.reference = FromValueOpt::from_value(v),
"type" => b.type_ = FromValueOpt::from_value(v),
_ => {}
}
}
b.take_out()
}
}
};
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentNextActionDisplayBankTransferInstructionsType {
EuBankTransfer,
GbBankTransfer,
JpBankTransfer,
MxBankTransfer,
UsBankTransfer,
Unknown(String),
}
impl PaymentIntentNextActionDisplayBankTransferInstructionsType {
pub fn as_str(&self) -> &str {
use PaymentIntentNextActionDisplayBankTransferInstructionsType::*;
match self {
EuBankTransfer => "eu_bank_transfer",
GbBankTransfer => "gb_bank_transfer",
JpBankTransfer => "jp_bank_transfer",
MxBankTransfer => "mx_bank_transfer",
UsBankTransfer => "us_bank_transfer",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentNextActionDisplayBankTransferInstructionsType {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentNextActionDisplayBankTransferInstructionsType::*;
match s {
"eu_bank_transfer" => Ok(EuBankTransfer),
"gb_bank_transfer" => Ok(GbBankTransfer),
"jp_bank_transfer" => Ok(JpBankTransfer),
"mx_bank_transfer" => Ok(MxBankTransfer),
"us_bank_transfer" => Ok(UsBankTransfer),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentNextActionDisplayBankTransferInstructionsType"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentNextActionDisplayBankTransferInstructionsType {
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 PaymentIntentNextActionDisplayBankTransferInstructionsType {
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 PaymentIntentNextActionDisplayBankTransferInstructionsType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentNextActionDisplayBankTransferInstructionsType))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentIntentNextActionDisplayBankTransferInstructionsType {
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 PaymentIntentNextActionDisplayBankTransferInstructionsType {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor
for crate::Place<PaymentIntentNextActionDisplayBankTransferInstructionsType>
{
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(
PaymentIntentNextActionDisplayBankTransferInstructionsType::from_str(s)
.expect("infallible"),
);
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(
PaymentIntentNextActionDisplayBankTransferInstructionsType
);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentNextActionDisplayBankTransferInstructionsType {
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"))
}
}