#[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 PaymentIntentPaymentMethodOptionsAcssDebit {
pub mandate_options:
Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>,
pub target_date: Option<String>,
pub verification_method: Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebit {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("PaymentIntentPaymentMethodOptionsAcssDebit").finish_non_exhaustive()
}
}
#[doc(hidden)]
pub struct PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
mandate_options:
Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>>,
setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>>,
target_date: Option<Option<String>>,
verification_method:
Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>>,
}
#[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 PaymentIntentPaymentMethodOptionsAcssDebit {
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
Place::new(out)
}
}
struct Builder<'a> {
out: &'a mut Option<PaymentIntentPaymentMethodOptionsAcssDebit>,
builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder,
}
impl Visitor for Place<PaymentIntentPaymentMethodOptionsAcssDebit> {
fn map(&mut self) -> Result<Box<dyn Map + '_>> {
Ok(Box::new(Builder {
out: &mut self.out,
builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(),
}))
}
}
impl MapBuilder for PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
type Out = PaymentIntentPaymentMethodOptionsAcssDebit;
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
Ok(match k {
"mandate_options" => Deserialize::begin(&mut self.mandate_options),
"setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
"target_date" => Deserialize::begin(&mut self.target_date),
"verification_method" => Deserialize::begin(&mut self.verification_method),
_ => <dyn Visitor>::ignore(),
})
}
fn deser_default() -> Self {
Self {
mandate_options: Some(None),
setup_future_usage: Some(None),
target_date: Some(None),
verification_method: Some(None),
}
}
fn take_out(&mut self) -> Option<Self::Out> {
let (
Some(mandate_options),
Some(setup_future_usage),
Some(target_date),
Some(verification_method),
) = (
self.mandate_options.take(),
self.setup_future_usage.take(),
self.target_date.take(),
self.verification_method.take(),
)
else {
return None;
};
Some(Self::Out {
mandate_options,
setup_future_usage,
target_date,
verification_method,
})
}
}
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 PaymentIntentPaymentMethodOptionsAcssDebit {
type Builder = PaymentIntentPaymentMethodOptionsAcssDebitBuilder;
}
impl FromValueOpt for PaymentIntentPaymentMethodOptionsAcssDebit {
fn from_value(v: Value) -> Option<Self> {
let Value::Object(obj) = v else {
return None;
};
let mut b = PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
"setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
"target_date" => b.target_date = FromValueOpt::from_value(v),
"verification_method" => b.verification_method = FromValueOpt::from_value(v),
_ => {}
}
}
b.take_out()
}
}
};
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
None,
OffSession,
OnSession,
Unknown(String),
}
impl PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
pub fn as_str(&self) -> &str {
use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
match self {
None => "none",
OffSession => "off_session",
OnSession => "on_session",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
match s {
"none" => Ok(None),
"off_session" => Ok(OffSession),
"on_session" => Ok(OnSession),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor
for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>
{
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(
PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::from_str(s)
.expect("infallible"),
);
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(
PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage
);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
Automatic,
Instant,
Microdeposits,
Unknown(String),
}
impl PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
pub fn as_str(&self) -> &str {
use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
match self {
Automatic => "automatic",
Instant => "instant",
Microdeposits => "microdeposits",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
match s {
"automatic" => Ok(Automatic),
"instant" => Ok(Instant),
"microdeposits" => Ok(Microdeposits),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
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 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
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 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
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 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor
for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>
{
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(
PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s)
.expect("infallible"),
);
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(
PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod
);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
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"))
}
}