refactor(router): add domain type for merchant_connector_account id (#5685)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
This commit is contained in:
Sai Harsha Vardhan
2024-08-28 13:22:19 +05:30
committed by GitHub
parent f33e1bb65c
commit 771f48cfe0
69 changed files with 388 additions and 271 deletions

View File

@ -670,16 +670,18 @@ pub struct MerchantId {
any(feature = "v1", feature = "v2"),
not(feature = "merchant_connector_account_v2")
))]
#[derive(Default, Debug, Deserialize, ToSchema, Serialize)]
#[derive(Debug, Deserialize, ToSchema, Serialize)]
pub struct MerchantConnectorId {
#[schema(value_type = String)]
pub merchant_id: id_type::MerchantId,
pub merchant_connector_id: String,
#[schema(value_type = String)]
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
}
#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]
#[derive(Default, Debug, Deserialize, ToSchema, Serialize)]
#[derive(Debug, Deserialize, ToSchema, Serialize)]
pub struct MerchantConnectorId {
pub id: String,
#[schema(value_type = String)]
pub id: id_type::MerchantConnectorAccountId,
}
#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]
@ -757,10 +759,6 @@ pub struct MerchantConnectorCreate {
#[schema(example = json!(consts::FRM_CONFIGS_EG))]
pub frm_configs: Option<Vec<FrmConfigs>>,
/// Unique ID of the connector
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub merchant_connector_id: Option<String>,
/// pm_auth_config will relate MCA records to their respective chosen auth services, based on payment_method and pmt
#[schema(value_type = Option<Object>)]
pub pm_auth_config: Option<pii::SecretSerdeValue>,
@ -904,8 +902,8 @@ pub struct MerchantConnectorCreate {
pub business_sub_label: Option<String>,
/// Unique ID of the connector
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub merchant_connector_id: Option<String>,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = Option<String>)]
pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
#[schema(value_type = Option<Object>)]
pub pm_auth_config: Option<pii::SecretSerdeValue>,
@ -1031,11 +1029,15 @@ pub struct MerchantConnectorWebhookDetails {
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, ToSchema)]
pub struct MerchantConnectorInfo {
pub connector_label: String,
pub merchant_connector_id: String,
#[schema(value_type = String)]
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
}
impl MerchantConnectorInfo {
pub fn new(connector_label: String, merchant_connector_id: String) -> Self {
pub fn new(
connector_label: String,
merchant_connector_id: id_type::MerchantConnectorAccountId,
) -> Self {
Self {
connector_label,
merchant_connector_id,
@ -1060,8 +1062,8 @@ pub struct MerchantConnectorResponse {
pub connector_label: Option<String>,
/// Unique ID of the merchant connector account
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub id: String,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)]
pub id: id_type::MerchantConnectorAccountId,
/// Identifier for the business profile, if not provided default will be chosen from merchant account
#[schema(max_length = 64, value_type = String)]
@ -1167,8 +1169,8 @@ pub struct MerchantConnectorResponse {
pub connector_label: Option<String>,
/// Unique ID of the merchant connector account
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub merchant_connector_id: String,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)]
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
/// Identifier for the business profile, if not provided default will be chosen from merchant account
#[schema(max_length = 64, value_type = String)]
@ -1291,8 +1293,8 @@ pub struct MerchantConnectorListResponse {
pub connector_label: Option<String>,
/// Unique ID of the merchant connector account
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub merchant_connector_id: String,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)]
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
/// Identifier for the business profile, if not provided default will be chosen from merchant account
#[schema(max_length = 64, value_type = String)]
@ -1400,8 +1402,8 @@ pub struct MerchantConnectorListResponse {
pub connector_label: Option<String>,
/// Unique ID of the merchant connector account
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub id: String,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)]
pub id: id_type::MerchantConnectorAccountId,
/// Identifier for the business profile, if not provided default will be chosen from merchant account
#[schema(max_length = 64, value_type = String)]
@ -1760,8 +1762,8 @@ pub struct MerchantConnectorDeleteResponse {
#[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]
pub merchant_id: id_type::MerchantId,
/// Unique ID of the connector
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub merchant_connector_id: String,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)]
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
/// If the connector is deleted or not
#[schema(example = false)]
pub deleted: bool,
@ -1774,8 +1776,8 @@ pub struct MerchantConnectorDeleteResponse {
#[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]
pub merchant_id: id_type::MerchantId,
/// Unique ID of the connector
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub id: String,
#[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)]
pub id: id_type::MerchantConnectorAccountId,
/// If the connector is deleted or not
#[schema(example = false)]
pub deleted: bool,