#[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 SubscriptionPaymentMethodOptionsCard {
pub mandate_options: Option<stripe_shared::InvoiceMandateOptionsCard>,
pub network: Option<SubscriptionPaymentMethodOptionsCardNetwork>,
pub request_three_d_secure: Option<SubscriptionPaymentMethodOptionsCardRequestThreeDSecure>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for SubscriptionPaymentMethodOptionsCard {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("SubscriptionPaymentMethodOptionsCard").finish_non_exhaustive()
}
}
#[doc(hidden)]
pub struct SubscriptionPaymentMethodOptionsCardBuilder {
mandate_options: Option<Option<stripe_shared::InvoiceMandateOptionsCard>>,
network: Option<Option<SubscriptionPaymentMethodOptionsCardNetwork>>,
request_three_d_secure: Option<Option<SubscriptionPaymentMethodOptionsCardRequestThreeDSecure>>,
}
#[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 SubscriptionPaymentMethodOptionsCard {
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
Place::new(out)
}
}
struct Builder<'a> {
out: &'a mut Option<SubscriptionPaymentMethodOptionsCard>,
builder: SubscriptionPaymentMethodOptionsCardBuilder,
}
impl Visitor for Place<SubscriptionPaymentMethodOptionsCard> {
fn map(&mut self) -> Result<Box<dyn Map + '_>> {
Ok(Box::new(Builder {
out: &mut self.out,
builder: SubscriptionPaymentMethodOptionsCardBuilder::deser_default(),
}))
}
}
impl MapBuilder for SubscriptionPaymentMethodOptionsCardBuilder {
type Out = SubscriptionPaymentMethodOptionsCard;
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
Ok(match k {
"mandate_options" => Deserialize::begin(&mut self.mandate_options),
"network" => Deserialize::begin(&mut self.network),
"request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure),
_ => <dyn Visitor>::ignore(),
})
}
fn deser_default() -> Self {
Self {
mandate_options: Some(None),
network: Some(None),
request_three_d_secure: Some(None),
}
}
fn take_out(&mut self) -> Option<Self::Out> {
let (Some(mandate_options), Some(network), Some(request_three_d_secure)) = (
self.mandate_options.take(),
self.network.take(),
self.request_three_d_secure.take(),
) else {
return None;
};
Some(Self::Out { mandate_options, network, request_three_d_secure })
}
}
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 SubscriptionPaymentMethodOptionsCard {
type Builder = SubscriptionPaymentMethodOptionsCardBuilder;
}
impl FromValueOpt for SubscriptionPaymentMethodOptionsCard {
fn from_value(v: Value) -> Option<Self> {
let Value::Object(obj) = v else {
return None;
};
let mut b = SubscriptionPaymentMethodOptionsCardBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
"network" => b.network = FromValueOpt::from_value(v),
"request_three_d_secure" => {
b.request_three_d_secure = FromValueOpt::from_value(v)
}
_ => {}
}
}
b.take_out()
}
}
};
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum SubscriptionPaymentMethodOptionsCardNetwork {
Amex,
CartesBancaires,
Diners,
Discover,
EftposAu,
Girocard,
Interac,
Jcb,
Link,
Mastercard,
Unionpay,
Unknown,
Visa,
_Unknown(String),
}
impl SubscriptionPaymentMethodOptionsCardNetwork {
pub fn as_str(&self) -> &str {
use SubscriptionPaymentMethodOptionsCardNetwork::*;
match self {
Amex => "amex",
CartesBancaires => "cartes_bancaires",
Diners => "diners",
Discover => "discover",
EftposAu => "eftpos_au",
Girocard => "girocard",
Interac => "interac",
Jcb => "jcb",
Link => "link",
Mastercard => "mastercard",
Unionpay => "unionpay",
Unknown => "unknown",
Visa => "visa",
_Unknown(v) => v,
}
}
}
impl std::str::FromStr for SubscriptionPaymentMethodOptionsCardNetwork {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use SubscriptionPaymentMethodOptionsCardNetwork::*;
match s {
"amex" => Ok(Amex),
"cartes_bancaires" => Ok(CartesBancaires),
"diners" => Ok(Diners),
"discover" => Ok(Discover),
"eftpos_au" => Ok(EftposAu),
"girocard" => Ok(Girocard),
"interac" => Ok(Interac),
"jcb" => Ok(Jcb),
"link" => Ok(Link),
"mastercard" => Ok(Mastercard),
"unionpay" => Ok(Unionpay),
"unknown" => Ok(Unknown),
"visa" => Ok(Visa),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"SubscriptionPaymentMethodOptionsCardNetwork"
);
Ok(_Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for SubscriptionPaymentMethodOptionsCardNetwork {
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 SubscriptionPaymentMethodOptionsCardNetwork {
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 SubscriptionPaymentMethodOptionsCardNetwork {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(SubscriptionPaymentMethodOptionsCardNetwork))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for SubscriptionPaymentMethodOptionsCardNetwork {
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 SubscriptionPaymentMethodOptionsCardNetwork {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<SubscriptionPaymentMethodOptionsCardNetwork> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out =
Some(SubscriptionPaymentMethodOptionsCardNetwork::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(SubscriptionPaymentMethodOptionsCardNetwork);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardNetwork {
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 SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
Any,
Automatic,
Challenge,
Unknown(String),
}
impl SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
pub fn as_str(&self) -> &str {
use SubscriptionPaymentMethodOptionsCardRequestThreeDSecure::*;
match self {
Any => "any",
Automatic => "automatic",
Challenge => "challenge",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use SubscriptionPaymentMethodOptionsCardRequestThreeDSecure::*;
match s {
"any" => Ok(Any),
"automatic" => Ok(Automatic),
"challenge" => Ok(Challenge),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"SubscriptionPaymentMethodOptionsCardRequestThreeDSecure"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
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 SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
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 SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(SubscriptionPaymentMethodOptionsCardRequestThreeDSecure))
.finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
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 SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor
for crate::Place<SubscriptionPaymentMethodOptionsCardRequestThreeDSecure>
{
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(
SubscriptionPaymentMethodOptionsCardRequestThreeDSecure::from_str(s)
.expect("infallible"),
);
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(SubscriptionPaymentMethodOptionsCardRequestThreeDSecure);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure {
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"))
}
}