#[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 CheckoutAcssDebitMandateOptions {
pub custom_mandate_url: Option<String>,
pub default_for: Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>,
pub interval_description: Option<String>,
pub payment_schedule: Option<CheckoutAcssDebitMandateOptionsPaymentSchedule>,
pub transaction_type: Option<CheckoutAcssDebitMandateOptionsTransactionType>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CheckoutAcssDebitMandateOptions {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("CheckoutAcssDebitMandateOptions").finish_non_exhaustive()
}
}
#[doc(hidden)]
pub struct CheckoutAcssDebitMandateOptionsBuilder {
custom_mandate_url: Option<Option<String>>,
default_for: Option<Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>>,
interval_description: Option<Option<String>>,
payment_schedule: Option<Option<CheckoutAcssDebitMandateOptionsPaymentSchedule>>,
transaction_type: Option<Option<CheckoutAcssDebitMandateOptionsTransactionType>>,
}
#[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 CheckoutAcssDebitMandateOptions {
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
Place::new(out)
}
}
struct Builder<'a> {
out: &'a mut Option<CheckoutAcssDebitMandateOptions>,
builder: CheckoutAcssDebitMandateOptionsBuilder,
}
impl Visitor for Place<CheckoutAcssDebitMandateOptions> {
fn map(&mut self) -> Result<Box<dyn Map + '_>> {
Ok(Box::new(Builder {
out: &mut self.out,
builder: CheckoutAcssDebitMandateOptionsBuilder::deser_default(),
}))
}
}
impl MapBuilder for CheckoutAcssDebitMandateOptionsBuilder {
type Out = CheckoutAcssDebitMandateOptions;
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
Ok(match k {
"custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url),
"default_for" => Deserialize::begin(&mut self.default_for),
"interval_description" => Deserialize::begin(&mut self.interval_description),
"payment_schedule" => Deserialize::begin(&mut self.payment_schedule),
"transaction_type" => Deserialize::begin(&mut self.transaction_type),
_ => <dyn Visitor>::ignore(),
})
}
fn deser_default() -> Self {
Self {
custom_mandate_url: Some(None),
default_for: Some(None),
interval_description: Some(None),
payment_schedule: Some(None),
transaction_type: Some(None),
}
}
fn take_out(&mut self) -> Option<Self::Out> {
let (
Some(custom_mandate_url),
Some(default_for),
Some(interval_description),
Some(payment_schedule),
Some(transaction_type),
) = (
self.custom_mandate_url.take(),
self.default_for.take(),
self.interval_description.take(),
self.payment_schedule.take(),
self.transaction_type.take(),
)
else {
return None;
};
Some(Self::Out {
custom_mandate_url,
default_for,
interval_description,
payment_schedule,
transaction_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 CheckoutAcssDebitMandateOptions {
type Builder = CheckoutAcssDebitMandateOptionsBuilder;
}
impl FromValueOpt for CheckoutAcssDebitMandateOptions {
fn from_value(v: Value) -> Option<Self> {
let Value::Object(obj) = v else {
return None;
};
let mut b = CheckoutAcssDebitMandateOptionsBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"custom_mandate_url" => b.custom_mandate_url = FromValueOpt::from_value(v),
"default_for" => b.default_for = FromValueOpt::from_value(v),
"interval_description" => b.interval_description = FromValueOpt::from_value(v),
"payment_schedule" => b.payment_schedule = FromValueOpt::from_value(v),
"transaction_type" => b.transaction_type = FromValueOpt::from_value(v),
_ => {}
}
}
b.take_out()
}
}
};
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CheckoutAcssDebitMandateOptionsDefaultFor {
Invoice,
Subscription,
Unknown(String),
}
impl CheckoutAcssDebitMandateOptionsDefaultFor {
pub fn as_str(&self) -> &str {
use CheckoutAcssDebitMandateOptionsDefaultFor::*;
match self {
Invoice => "invoice",
Subscription => "subscription",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CheckoutAcssDebitMandateOptionsDefaultFor {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CheckoutAcssDebitMandateOptionsDefaultFor::*;
match s {
"invoice" => Ok(Invoice),
"subscription" => Ok(Subscription),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"CheckoutAcssDebitMandateOptionsDefaultFor"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CheckoutAcssDebitMandateOptionsDefaultFor {
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 CheckoutAcssDebitMandateOptionsDefaultFor {
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 CheckoutAcssDebitMandateOptionsDefaultFor {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CheckoutAcssDebitMandateOptionsDefaultFor))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for CheckoutAcssDebitMandateOptionsDefaultFor {
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 CheckoutAcssDebitMandateOptionsDefaultFor {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsDefaultFor> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out =
Some(CheckoutAcssDebitMandateOptionsDefaultFor::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsDefaultFor);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsDefaultFor {
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 CheckoutAcssDebitMandateOptionsPaymentSchedule {
Combined,
Interval,
Sporadic,
Unknown(String),
}
impl CheckoutAcssDebitMandateOptionsPaymentSchedule {
pub fn as_str(&self) -> &str {
use CheckoutAcssDebitMandateOptionsPaymentSchedule::*;
match self {
Combined => "combined",
Interval => "interval",
Sporadic => "sporadic",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CheckoutAcssDebitMandateOptionsPaymentSchedule {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CheckoutAcssDebitMandateOptionsPaymentSchedule::*;
match s {
"combined" => Ok(Combined),
"interval" => Ok(Interval),
"sporadic" => Ok(Sporadic),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"CheckoutAcssDebitMandateOptionsPaymentSchedule"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CheckoutAcssDebitMandateOptionsPaymentSchedule {
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 CheckoutAcssDebitMandateOptionsPaymentSchedule {
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 CheckoutAcssDebitMandateOptionsPaymentSchedule {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CheckoutAcssDebitMandateOptionsPaymentSchedule))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for CheckoutAcssDebitMandateOptionsPaymentSchedule {
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 CheckoutAcssDebitMandateOptionsPaymentSchedule {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsPaymentSchedule> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out =
Some(CheckoutAcssDebitMandateOptionsPaymentSchedule::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsPaymentSchedule);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsPaymentSchedule {
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 CheckoutAcssDebitMandateOptionsTransactionType {
Business,
Personal,
Unknown(String),
}
impl CheckoutAcssDebitMandateOptionsTransactionType {
pub fn as_str(&self) -> &str {
use CheckoutAcssDebitMandateOptionsTransactionType::*;
match self {
Business => "business",
Personal => "personal",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for CheckoutAcssDebitMandateOptionsTransactionType {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use CheckoutAcssDebitMandateOptionsTransactionType::*;
match s {
"business" => Ok(Business),
"personal" => Ok(Personal),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"CheckoutAcssDebitMandateOptionsTransactionType"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for CheckoutAcssDebitMandateOptionsTransactionType {
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 CheckoutAcssDebitMandateOptionsTransactionType {
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 CheckoutAcssDebitMandateOptionsTransactionType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(CheckoutAcssDebitMandateOptionsTransactionType))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for CheckoutAcssDebitMandateOptionsTransactionType {
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 CheckoutAcssDebitMandateOptionsTransactionType {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsTransactionType> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out =
Some(CheckoutAcssDebitMandateOptionsTransactionType::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsTransactionType);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsTransactionType {
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"))
}
}