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

@ -42,7 +42,7 @@ pub fn is_enabled(
pub async fn check_if_connector_exists(
state: &SessionState,
connector_id: &str,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
merchant_id: &common_utils::id_type::MerchantId,
) -> RouterResult<()> {
let key_manager_state = &state.into();
@ -70,7 +70,7 @@ pub async fn check_if_connector_exists(
)
.await
.to_not_found_response(ApiErrorResponse::MerchantConnectorAccountNotFound {
id: connector_id.to_string(),
id: connector_id.get_string_repr().to_string(),
})?;
#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]
@ -85,7 +85,7 @@ pub async fn check_if_connector_exists(
pub async fn set_tracking_id_in_configs(
state: &SessionState,
connector_id: &str,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
connector: enums::Connector,
) -> RouterResult<()> {
let timestamp = common_utils::date_time::now_unix_timestamp().to_string();
@ -130,7 +130,7 @@ pub async fn set_tracking_id_in_configs(
pub async fn get_tracking_id_from_configs(
state: &SessionState,
connector_id: &str,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
connector: enums::Connector,
) -> RouterResult<String> {
let timestamp = state
@ -144,14 +144,17 @@ pub async fn get_tracking_id_from_configs(
.attach_printable("Error getting data from configs table")?
.config;
Ok(format!("{}_{}", connector_id, timestamp))
Ok(format!("{}_{}", connector_id.get_string_repr(), timestamp))
}
fn build_key(connector_id: &str, connector: enums::Connector) -> String {
fn build_key(
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
connector: enums::Connector,
) -> String {
format!(
"{}_{}_{}",
consts::CONNECTOR_ONBOARDING_CONFIG_PREFIX,
connector,
connector_id,
connector_id.get_string_repr(),
)
}