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