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