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