Better ser/deser for payouts vals (#474)

This commit is contained in:
Geometrically
2022-11-08 14:14:07 -07:00
committed by GitHub
parent 0429c44d18
commit 1d391e68e5
3 changed files with 17 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ pub struct UserPayoutData {
}
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[serde(rename_all = "snake_case")]
pub enum RecipientType {
Email,
Phone,
@@ -90,10 +90,10 @@ impl RecipientType {
}
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq)]
#[serde(rename_all = "PascalCase")]
#[serde(rename_all = "snake_case")]
pub enum RecipientWallet {
Venmo,
PayPal,
Paypal,
}
impl std::fmt::Display for RecipientWallet {
@@ -106,16 +106,23 @@ impl RecipientWallet {
pub fn from_string(string: &str) -> RecipientWallet {
match string {
"venmo" => RecipientWallet::Venmo,
_ => RecipientWallet::PayPal,
_ => RecipientWallet::Paypal,
}
}
pub fn as_str(&self) -> &'static str {
match self {
RecipientWallet::PayPal => "paypal",
RecipientWallet::Paypal => "paypal",
RecipientWallet::Venmo => "venmo",
}
}
pub fn as_str_api(&self) -> &'static str {
match self {
RecipientWallet::Paypal => "PayPal",
RecipientWallet::Venmo => "Venmo",
}
}
}
use crate::database::models::user_item::User as DBUser;