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