Skip to content

Commit

Permalink
refactor(merchant_account_v2): remove routing algorithms from merchan…
Browse files Browse the repository at this point in the history
…t account and add version column (#5527)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
Co-authored-by: Hrithikesh <61539176+hrithikesh026@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 10, 2024
1 parent 68574b2 commit f1196be
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 132 deletions.
23 changes: 8 additions & 15 deletions crates/diesel_models/src/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct MerchantAccount {
pub recon_status: storage_enums::ReconStatus,
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub version: common_enums::ApiVersion,
}

#[cfg(all(
Expand Down Expand Up @@ -90,6 +91,7 @@ pub struct MerchantAccountSetter {
pub recon_status: storage_enums::ReconStatus,
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub version: common_enums::ApiVersion,
}

#[cfg(all(
Expand Down Expand Up @@ -126,6 +128,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
recon_status: item.recon_status,
payment_link_config: item.payment_link_config,
pm_collect_link_config: item.pm_collect_link_config,
version: item.version,
}
}
}
Expand All @@ -151,14 +154,12 @@ pub struct MerchantAccount {
pub publishable_key: Option<String>,
pub storage_scheme: storage_enums::MerchantStorageScheme,
pub metadata: Option<pii::SecretSerdeValue>,
pub routing_algorithm: Option<serde_json::Value>,
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: common_utils::id_type::OrganizationId,
pub recon_status: storage_enums::ReconStatus,
pub id: common_utils::id_type::MerchantId,
pub version: common_enums::ApiVersion,
}

#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]
Expand All @@ -173,11 +174,9 @@ impl From<MerchantAccountSetter> for MerchantAccount {
metadata: item.metadata,
created_at: item.created_at,
modified_at: item.modified_at,
frm_routing_algorithm: item.frm_routing_algorithm,
routing_algorithm: item.routing_algorithm,
payout_routing_algorithm: item.payout_routing_algorithm,
organization_id: item.organization_id,
recon_status: item.recon_status,
version: item.version,
}
}
}
Expand All @@ -190,13 +189,11 @@ pub struct MerchantAccountSetter {
pub publishable_key: Option<String>,
pub storage_scheme: storage_enums::MerchantStorageScheme,
pub metadata: Option<pii::SecretSerdeValue>,
pub routing_algorithm: Option<serde_json::Value>,
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: common_utils::id_type::OrganizationId,
pub recon_status: storage_enums::ReconStatus,
pub version: common_enums::ApiVersion,
}

impl MerchantAccount {
Expand Down Expand Up @@ -248,6 +245,7 @@ pub struct MerchantAccountNew {
pub recon_status: storage_enums::ReconStatus,
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub version: common_enums::ApiVersion,
}

#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]
Expand All @@ -258,14 +256,12 @@ pub struct MerchantAccountNew {
pub merchant_details: Option<Encryption>,
pub publishable_key: Option<String>,
pub metadata: Option<pii::SecretSerdeValue>,
pub routing_algorithm: Option<serde_json::Value>,
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: common_utils::id_type::OrganizationId,
pub recon_status: storage_enums::ReconStatus,
pub id: common_utils::id_type::MerchantId,
pub version: common_enums::ApiVersion,
}

#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]
Expand All @@ -277,10 +273,7 @@ pub struct MerchantAccountUpdateInternal {
pub publishable_key: Option<String>,
pub storage_scheme: Option<storage_enums::MerchantStorageScheme>,
pub metadata: Option<pii::SecretSerdeValue>,
pub routing_algorithm: Option<serde_json::Value>,
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<common_utils::id_type::OrganizationId>,
pub recon_status: Option<storage_enums::ReconStatus>,
}
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ diesel::table! {
recon_status -> ReconStatus,
payment_link_config -> Nullable<Jsonb>,
pm_collect_link_config -> Nullable<Jsonb>,
version -> ApiVersion,
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,16 +647,14 @@ diesel::table! {
publishable_key -> Nullable<Varchar>,
storage_scheme -> MerchantStorageScheme,
metadata -> Nullable<Jsonb>,
routing_algorithm -> Nullable<Json>,
created_at -> Timestamp,
modified_at -> Timestamp,
frm_routing_algorithm -> Nullable<Jsonb>,
payout_routing_algorithm -> Nullable<Jsonb>,
#[max_length = 32]
organization_id -> Varchar,
recon_status -> ReconStatus,
#[max_length = 64]
id -> Varchar,
version -> ApiVersion,
}
}

Expand Down
14 changes: 14 additions & 0 deletions crates/hyperswitch_domain_models/src/consts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Constants that are used in the domain models.
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2"),
not(feature = "merchant_account_v2")
))]
pub const API_VERSION: common_enums::ApiVersion = common_enums::ApiVersion::V1;

#[cfg(all(
feature = "v2",
any(feature = "customer_v2", feature = "merchant_account_v2")
))]
pub const API_VERSION: common_enums::ApiVersion = common_enums::ApiVersion::V2;
11 changes: 5 additions & 6 deletions crates/hyperswitch_domain_models/src/customer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use api_models::customers::CustomerRequestWithEncryption;
// #[cfg(all(feature = "v2", feature = "customer_v2"))]
// use common_enums::SoftDeleteStatus;
use common_enums::ApiVersion;
use common_utils::{
crypto, date_time,
encryption::Encryption,
Expand Down Expand Up @@ -36,7 +35,7 @@ pub struct Customer {
pub address_id: Option<String>,
pub default_payment_method_id: Option<String>,
pub updated_by: Option<String>,
pub version: ApiVersion,
pub version: common_enums::ApiVersion,
}

#[cfg(all(feature = "v2", feature = "customer_v2"))]
Expand All @@ -54,12 +53,12 @@ pub struct Customer {
pub modified_at: PrimitiveDateTime,
pub default_payment_method_id: Option<String>,
pub updated_by: Option<String>,
pub version: ApiVersion,
pub merchant_reference_id: Option<id_type::CustomerId>,
pub default_billing_address: Option<Encryption>,
pub default_shipping_address: Option<Encryption>,
// pub status: Option<SoftDeleteStatus>,
pub id: String,
pub version: common_enums::ApiVersion,
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
Expand Down Expand Up @@ -196,8 +195,8 @@ impl super::behaviour::Conversion for Customer {
updated_by: self.updated_by,
default_billing_address: self.default_billing_address.map(Encryption::from),
default_shipping_address: self.default_shipping_address.map(Encryption::from),
// status: self.status,
version: self.version,
// status: self.status,
})
}

Expand Down Expand Up @@ -250,8 +249,8 @@ impl super::behaviour::Conversion for Customer {
updated_by: item.updated_by,
default_billing_address: item.default_billing_address,
default_shipping_address: item.default_shipping_address,
// status: item.status,
version: item.version,
// status: item.status,
})
}

Expand All @@ -275,7 +274,7 @@ impl super::behaviour::Conversion for Customer {
default_billing_address: self.default_billing_address,
default_shipping_address: self.default_shipping_address,
// status: self.status,
version: self.version,
version: crate::consts::API_VERSION,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/hyperswitch_domain_models/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod api;
pub mod behaviour;
pub mod business_profile;
pub mod consts;
pub mod customer;
pub mod errors;
pub mod mandates;
Expand Down
Loading

0 comments on commit f1196be

Please # to comment.