use serde::{Deserialize, Serialize};
use std::fmt;
use std::str::FromStr;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SdkCreateChargeRequestApplicationJsonPaymentMethod {
Authnet,
Btcpay,
Cashapp,
Coinbase,
Paddle,
Paydash,
Paypal,
Paystack,
Square,
Stripe,
Venmo,
Nmi,
MercadoPago,
Mollie,
Razorpay,
CustomPaymentMethod,
Lifi,
Btc,
Ltc,
Eth,
Xmr,
Sol,
Ada,
Bnb,
Trx,
Matic,
EthUsdt,
EthUsdc,
EthUni,
EthShib,
EthDai,
BnbUsdt,
BnbUsdc,
TrxUsdt,
TrxUsdc,
SolUsdt,
SolUsdc,
Unknown(String),
}
impl SdkCreateChargeRequestApplicationJsonPaymentMethod {
#[allow(deprecated)]
pub fn as_str(&self) -> &str {
match self {
Self::Authnet => "AUTHNET",
Self::Btcpay => "BTCPAY",
Self::Cashapp => "CASHAPP",
Self::Coinbase => "COINBASE",
Self::Paddle => "PADDLE",
Self::Paydash => "PAYDASH",
Self::Paypal => "PAYPAL",
Self::Paystack => "PAYSTACK",
Self::Square => "SQUARE",
Self::Stripe => "STRIPE",
Self::Venmo => "VENMO",
Self::Nmi => "NMI",
Self::MercadoPago => "MERCADO_PAGO",
Self::Mollie => "MOLLIE",
Self::Razorpay => "RAZORPAY",
Self::CustomPaymentMethod => "CUSTOM_PAYMENT_METHOD",
Self::Lifi => "LIFI",
Self::Btc => "BTC",
Self::Ltc => "LTC",
Self::Eth => "ETH",
Self::Xmr => "XMR",
Self::Sol => "SOL",
Self::Ada => "ADA",
Self::Bnb => "BNB",
Self::Trx => "TRX",
Self::Matic => "MATIC",
Self::EthUsdt => "ETH_USDT",
Self::EthUsdc => "ETH_USDC",
Self::EthUni => "ETH_UNI",
Self::EthShib => "ETH_SHIB",
Self::EthDai => "ETH_DAI",
Self::BnbUsdt => "BNB_USDT",
Self::BnbUsdc => "BNB_USDC",
Self::TrxUsdt => "TRX_USDT",
Self::TrxUsdc => "TRX_USDC",
Self::SolUsdt => "SOL_USDT",
Self::SolUsdc => "SOL_USDC",
Self::Unknown(s) => s.as_str(),
}
}
pub fn is_known(&self) -> bool {
!matches!(self, Self::Unknown(_))
}
}
impl fmt::Display for SdkCreateChargeRequestApplicationJsonPaymentMethod {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl AsRef<str> for SdkCreateChargeRequestApplicationJsonPaymentMethod {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl FromStr for SdkCreateChargeRequestApplicationJsonPaymentMethod {
type Err = std::convert::Infallible;
#[allow(deprecated)]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"AUTHNET" => Self::Authnet,
"BTCPAY" => Self::Btcpay,
"CASHAPP" => Self::Cashapp,
"COINBASE" => Self::Coinbase,
"PADDLE" => Self::Paddle,
"PAYDASH" => Self::Paydash,
"PAYPAL" => Self::Paypal,
"PAYSTACK" => Self::Paystack,
"SQUARE" => Self::Square,
"STRIPE" => Self::Stripe,
"VENMO" => Self::Venmo,
"NMI" => Self::Nmi,
"MERCADO_PAGO" => Self::MercadoPago,
"MOLLIE" => Self::Mollie,
"RAZORPAY" => Self::Razorpay,
"CUSTOM_PAYMENT_METHOD" => Self::CustomPaymentMethod,
"LIFI" => Self::Lifi,
"BTC" => Self::Btc,
"LTC" => Self::Ltc,
"ETH" => Self::Eth,
"XMR" => Self::Xmr,
"SOL" => Self::Sol,
"ADA" => Self::Ada,
"BNB" => Self::Bnb,
"TRX" => Self::Trx,
"MATIC" => Self::Matic,
"ETH_USDT" => Self::EthUsdt,
"ETH_USDC" => Self::EthUsdc,
"ETH_UNI" => Self::EthUni,
"ETH_SHIB" => Self::EthShib,
"ETH_DAI" => Self::EthDai,
"BNB_USDT" => Self::BnbUsdt,
"BNB_USDC" => Self::BnbUsdc,
"TRX_USDT" => Self::TrxUsdt,
"TRX_USDC" => Self::TrxUsdc,
"SOL_USDT" => Self::SolUsdt,
"SOL_USDC" => Self::SolUsdc,
other => Self::Unknown(other.to_string()),
})
}
}
impl From<String> for SdkCreateChargeRequestApplicationJsonPaymentMethod {
fn from(s: String) -> Self {
match Self::from_str(&s) {
Ok(Self::Unknown(_)) => Self::Unknown(s),
Ok(other) => other,
}
}
}
impl From<&str> for SdkCreateChargeRequestApplicationJsonPaymentMethod {
fn from(s: &str) -> Self {
Self::from_str(s).unwrap_or_else(|_| Self::Unknown(s.to_string()))
}
}
impl Serialize for SdkCreateChargeRequestApplicationJsonPaymentMethod {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for SdkCreateChargeRequestApplicationJsonPaymentMethod {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let s = String::deserialize(deserializer)?;
Ok(Self::from(s))
}
}