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