sellapp-sdk 0.1.1

Official Rust SDK for the SellApp API: manage products, orders, subscriptions, and customers.
// This file is auto-generated by oagen. Do not edit.

use serde::{Deserialize, Serialize};
use std::fmt;
use std::str::FromStr;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    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,
    /// Wire value not recognized by this SDK version. The original
    /// string is preserved verbatim. SellApp may add new enum values
    /// server-side; matching on this variant lets callers handle
    /// forward-compatible values without panicking.
    Unknown(String),
}

impl SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    /// Canonical wire string for this value. For [`Self::Unknown`] returns the
    /// original wire value as received from the API.
    #[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(),
        }
    }

    /// Whether this value was declared by the schema used to generate the SDK.
    pub fn is_known(&self) -> bool {
        !matches!(self, Self::Unknown(_))
    }
}

impl fmt::Display for SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str(self.as_str())
    }
}

impl AsRef<str> for SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl FromStr for SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    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 SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    fn from(s: String) -> Self {
        // Reuse the original `String` allocation in the fallback branch.
        match Self::from_str(&s) {
            Ok(Self::Unknown(_)) => Self::Unknown(s),
            Ok(other) => other,
        }
    }
}

impl From<&str> for SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    fn from(s: &str) -> Self {
        Self::from_str(s).unwrap_or_else(|_| Self::Unknown(s.to_string()))
    }
}

impl Serialize for SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de> Deserialize<'de> for SdkCreateInvoiceRequestApplicationJsonPaymentMethod {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let s = String::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}