refactor: use CountryAlpha2 instead of CountryCode for country codes (#904)

This commit is contained in:
Pa1NarK
2023-05-03 13:46:41 +05:30
committed by GitHub
parent c9e8a9b4b7
commit 2cff019a1b
39 changed files with 1952 additions and 2427 deletions

View File

@ -254,7 +254,7 @@ pub enum RoutingAlgorithm {
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PrimaryBusinessDetails {
pub country: api_enums::CountryCode,
pub country: api_enums::CountryAlpha2,
pub business: String,
}
@ -385,11 +385,11 @@ pub struct MerchantConnectorCreate {
pub frm_configs: Option<FrmConfigs>,
/// Business Country of the connector
#[schema(example = "US")]
#[schema(value_type = CountryAlpha2, example = "US")]
#[cfg(feature = "multiple_mca")]
pub business_country: api_enums::CountryCode,
pub business_country: api_enums::CountryAlpha2,
#[cfg(not(feature = "multiple_mca"))]
pub business_country: Option<api_enums::CountryCode>,
pub business_country: Option<api_enums::CountryAlpha2>,
///Business Type of the merchant
#[schema(example = "travel")]
@ -466,8 +466,8 @@ pub struct MerchantConnectorResponse {
pub metadata: Option<pii::SecretSerdeValue>,
/// Business Country of the connector
#[schema(example = "US")]
pub business_country: api_enums::CountryCode,
#[schema(value_type = CountryAlpha2, example = "US")]
pub business_country: api_enums::CountryAlpha2,
///Business Type of the merchant
#[schema(example = "travel")]
@ -603,8 +603,8 @@ pub enum AcceptedCurrencies {
rename_all = "snake_case"
)]
pub enum AcceptedCountries {
EnableOnly(Vec<api_enums::CountryCode>),
DisableOnly(Vec<api_enums::CountryCode>),
EnableOnly(Vec<api_enums::CountryAlpha2>),
DisableOnly(Vec<api_enums::CountryAlpha2>),
AllAccepted,
}

View File

@ -102,11 +102,11 @@ pub struct PaymentMethodResponse {
pub payment_method_id: String,
/// The type of payment method use for the payment.
#[schema(value_type = PaymentMethodType,example = "card")]
#[schema(value_type = PaymentMethodType, example = "card")]
pub payment_method: api_enums::PaymentMethod,
/// This is a sub-category of payment method.
#[schema(value_type = Option<PaymentMethodType>,example = "credit")]
#[schema(value_type = Option<PaymentMethodType>, example = "credit")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,
/// Card details from card locker
@ -122,15 +122,15 @@ pub struct PaymentMethodResponse {
pub installment_payment_enabled: bool,
/// Type of payment experience enabled with the connector
#[schema(value_type = Option<Vec<PaymentExperience>>,example = json!(["redirect_to_url"]))]
#[schema(value_type = Option<Vec<PaymentExperience>>, example = json!(["redirect_to_url"]))]
pub payment_experience: Option<Vec<api_enums::PaymentExperience>>,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
#[schema(value_type = Option<Object>, example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<pii::SecretSerdeValue>,
/// A timestamp (ISO 8601 code) that determines when the customer was created
#[schema(value_type = Option<PrimitiveDateTime>,example = "2023-01-18T11:04:09.922Z")]
#[schema(value_type = Option<PrimitiveDateTime>, example = "2023-01-18T11:04:09.922Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<time::PrimitiveDateTime>,
}
@ -283,8 +283,8 @@ pub struct PaymentMethodListRequest {
pub client_secret: Option<String>,
/// The two-letter ISO currency code
#[schema(value_type = Option<Vec<Country>>, example = json!(["US", "UK", "IN"]))]
pub accepted_countries: Option<Vec<api_enums::CountryCode>>,
#[schema(value_type = Option<Vec<CountryAlpha2>>, example = json!(["US", "UK", "IN"]))]
pub accepted_countries: Option<Vec<api_enums::CountryAlpha2>>,
/// The three-letter ISO currency code
#[schema(value_type = Option<Vec<Currency>>,example = json!(["USD", "EUR"]))]

View File

@ -202,8 +202,8 @@ pub struct PaymentsRequest {
pub payment_method_type: Option<api_enums::PaymentMethodType>,
/// Business country of the merchant for this payment
#[schema(example = "US")]
pub business_country: Option<api_enums::CountryCode>,
#[schema(value_type = CountryAlpha2, example = "US")]
pub business_country: Option<api_enums::CountryAlpha2>,
/// Business label of the merchant for this payment
#[schema(example = "food")]
@ -439,8 +439,8 @@ pub enum PayLaterData {
#[schema(value_type = String)]
billing_email: Secret<String, pii::Email>,
// The billing country code
#[schema(value_type = Country)]
billing_country: api_enums::CountryCode,
#[schema(value_type = CountryAlpha2, example = "US")]
billing_country: api_enums::CountryAlpha2,
},
/// For Klarna Sdk as PayLater Option
KlarnaSdk {
@ -627,8 +627,8 @@ pub enum BankRedirectData {
billing_details: BankRedirectBilling,
/// The country for bank payment
#[schema(value_type = Country, example = "US")]
country: api_enums::CountryCode,
#[schema(value_type = CountryAlpha2, example = "US")]
country: api_enums::CountryAlpha2,
/// The preferred language
#[schema(example = "en")]
@ -645,7 +645,7 @@ pub struct CryptoData {}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct SofortBilling {
/// The country associated with the billing
#[schema(example = "US")]
#[schema(value_type = CountryAlpha2, example = "US")]
pub billing_country: String,
}
@ -857,8 +857,8 @@ pub struct AddressDetails {
pub city: Option<String>,
/// The two-letter ISO country code for the address
#[schema(value_type = Option<Country>, max_length = 2, min_length = 2, example = "US")]
pub country: Option<api_enums::CountryCode>,
#[schema(value_type = Option<CountryAlpha2>, example = "US")]
pub country: Option<api_enums::CountryAlpha2>,
/// The first line of the address
#[schema(value_type = Option<String>, max_length = 200, example = "123, King Street")]
@ -1119,7 +1119,7 @@ pub struct PaymentsResponse {
pub connector_label: Option<String>,
/// The business country of merchant for this payment
pub business_country: api_enums::CountryCode,
pub business_country: api_enums::CountryAlpha2,
/// The business label of merchant for this payment
pub business_label: String,
@ -1449,8 +1449,8 @@ pub struct GpayAllowedPaymentMethods {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct GpayTransactionInfo {
/// The country code
#[schema(value_type = Country)]
pub country_code: api_enums::CountryCode,
#[schema(value_type = CountryAlpha2, example = "US")]
pub country_code: api_enums::CountryAlpha2,
/// The currency code
pub currency_code: String,
/// The total price status (ex: 'FINAL')
@ -1597,8 +1597,8 @@ pub struct ApplePaySessionResponse {
#[derive(Debug, Clone, serde::Serialize, ToSchema, serde::Deserialize)]
pub struct ApplePayPaymentRequest {
/// The code for country
#[schema(value_type = Country)]
pub country_code: api_enums::CountryCode,
#[schema(value_type = CountryAlpha2, example = "US")]
pub country_code: api_enums::CountryAlpha2,
/// The code for currency
pub currency_code: String,
/// Represents the total for the payment.