refactor(api_models): enhance accepted countries/currencies types (#807)

This commit is contained in:
ItsMeShashank
2023-03-28 17:01:02 +05:30
committed by GitHub
parent 97b95f0e4d
commit f9ef3135af
4 changed files with 69 additions and 78 deletions

View File

@ -360,28 +360,30 @@ pub struct PaymentMethodsEnabled {
pub payment_method_types: Option<Vec<payment_methods::RequestPaymentMethodTypes>>,
}
/// List of enabled and disabled currencies, empty in case all currencies are enabled
#[derive(Eq, PartialEq, Hash, Debug, Clone, serde::Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct AcceptedCurrencies {
/// type of accepted currencies (disable_only, enable_only)
#[serde(rename = "type")]
pub accept_type: String,
/// List of currencies of the provided type
#[schema(value_type = Option<Vec<Currency>>,example = json!(["USD", "EUR"]))]
pub list: Option<Vec<api_enums::Currency>>,
#[derive(PartialEq, Eq, Hash, Debug, Clone, serde::Serialize, Deserialize, ToSchema)]
#[serde(
deny_unknown_fields,
tag = "type",
content = "list",
rename_all = "snake_case"
)]
pub enum AcceptedCurrencies {
EnableOnly(Vec<api_enums::Currency>),
DisableOnly(Vec<api_enums::Currency>),
AllAccepted,
}
/// List of enabled and disabled countries, empty in case all countries are enabled
#[derive(Eq, PartialEq, Hash, Debug, Clone, serde::Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct AcceptedCountries {
/// Type of accepted countries (disable_only, enable_only)
#[serde(rename = "type")]
pub accept_type: String,
/// List of countries of the provided type
#[schema(example = json!(["FR", "DE","IN"]))]
pub list: Option<Vec<String>>,
#[derive(PartialEq, Eq, Hash, Debug, Clone, serde::Serialize, Deserialize, ToSchema)]
#[serde(
deny_unknown_fields,
tag = "type",
content = "list",
rename_all = "snake_case"
)]
pub enum AcceptedCountries {
EnableOnly(Vec<String>),
DisableOnly(Vec<String>),
AllAccepted,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]

View File

@ -137,6 +137,7 @@ pub enum ConnectorType {
serde::Serialize,
strum::Display,
strum::EnumString,
strum::EnumIter,
ToSchema,
frunk::LabelledGeneric,
)]

View File

@ -241,9 +241,8 @@ pub struct RequestPaymentMethodTypes {
/// List of currencies accepted or has the processing capabilities of the processor
#[schema(example = json!(
{
"enable_all":false,
"disable_only": ["INR", "CAD", "AED","JPY"],
"enable_only": ["EUR","USD"]
"type": "specific_accepted",
"list": ["USD", "INR"]
}
))]
pub accepted_currencies: Option<admin::AcceptedCurrencies>,
@ -251,9 +250,8 @@ pub struct RequestPaymentMethodTypes {
/// List of Countries accepted or has the processing capabilities of the processor
#[schema(example = json!(
{
"enable_all":false,
"disable_only": ["FR", "DE","IN"],
"enable_only": ["UK","AU"]
"type": "specific_accepted",
"list": ["UK", "AU"]
}
))]
pub accepted_countries: Option<admin::AcceptedCountries>,