refactor(enums): move enums from storage_models and api_models crates to common_enums crate (#1265)

This commit is contained in:
Amisha Prabhat
2023-07-13 17:42:14 +05:30
committed by GitHub
parent b8393d4b50
commit c0e1d4d3b0
40 changed files with 991 additions and 1852 deletions

View File

@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};
use crate::enums::{Country, CountryAlpha2, CountryAlpha3};
use crate::enums::{Country, CountryAlpha2, CountryAlpha3, PaymentMethod, PaymentMethodType};
impl Display for NumericCountryCodeParseError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
@ -1532,6 +1532,52 @@ impl Country {
}
}
impl From<PaymentMethodType> for PaymentMethod {
fn from(value: PaymentMethodType) -> Self {
match value {
PaymentMethodType::Ach => Self::BankDebit,
PaymentMethodType::Affirm => Self::PayLater,
PaymentMethodType::AfterpayClearpay => Self::PayLater,
PaymentMethodType::AliPay => Self::Wallet,
PaymentMethodType::AliPayHk => Self::Wallet,
PaymentMethodType::ApplePay => Self::Wallet,
PaymentMethodType::Bacs => Self::BankDebit,
PaymentMethodType::BancontactCard => Self::BankRedirect,
PaymentMethodType::Becs => Self::BankDebit,
PaymentMethodType::Blik => Self::BankRedirect,
PaymentMethodType::ClassicReward => Self::Reward,
PaymentMethodType::Credit => Self::Card,
PaymentMethodType::CryptoCurrency => Self::Crypto,
PaymentMethodType::Debit => Self::Card,
PaymentMethodType::Eps => Self::BankRedirect,
PaymentMethodType::Evoucher => Self::Reward,
PaymentMethodType::Giropay => Self::BankRedirect,
PaymentMethodType::GooglePay => Self::Wallet,
PaymentMethodType::Ideal => Self::BankRedirect,
PaymentMethodType::Klarna => Self::PayLater,
PaymentMethodType::MbWay => Self::Wallet,
PaymentMethodType::MobilePay => Self::Wallet,
PaymentMethodType::Multibanco => Self::BankTransfer,
PaymentMethodType::Interac => Self::BankRedirect,
PaymentMethodType::OnlineBankingCzechRepublic => Self::BankRedirect,
PaymentMethodType::OnlineBankingFinland => Self::BankRedirect,
PaymentMethodType::OnlineBankingPoland => Self::BankRedirect,
PaymentMethodType::OnlineBankingSlovakia => Self::BankRedirect,
PaymentMethodType::PayBright => Self::PayLater,
PaymentMethodType::Paypal => Self::Wallet,
PaymentMethodType::Przelewy24 => Self::BankRedirect,
PaymentMethodType::SamsungPay => Self::Wallet,
PaymentMethodType::Sepa => Self::BankDebit,
PaymentMethodType::Sofort => Self::BankRedirect,
PaymentMethodType::Swish => Self::BankRedirect,
PaymentMethodType::Trustly => Self::BankRedirect,
PaymentMethodType::UpiCollect => Self::Upi,
PaymentMethodType::Walley => Self::PayLater,
PaymentMethodType::WeChatPay => Self::Wallet,
}
}
}
#[derive(Debug)]
pub struct NumericCountryCodeParseError;
#[allow(dead_code)]