refactor: introduce a domain type for profile ID (#5687)

This commit is contained in:
Sanchith Hegde
2024-08-27 13:31:01 +05:30
committed by GitHub
parent fac8e7916f
commit b63d723b8b
118 changed files with 707 additions and 547 deletions

View File

@ -207,8 +207,9 @@ pub async fn update_business_profile_active_algorithm_ref(
let routing_cache_key = cache::CacheKind::Routing(
format!(
"routing_config_{}_{profile_id}",
merchant_id.get_string_repr()
"routing_config_{}_{}",
merchant_id.get_string_repr(),
profile_id.get_string_repr(),
)
.into(),
);
@ -300,13 +301,13 @@ impl MerchantConnectorAccounts {
pub fn filter_by_profile<'a, T>(
&'a self,
profile_id: &'a str,
profile_id: &'a common_utils::id_type::ProfileId,
func: impl Fn(&'a MerchantConnectorAccount) -> T,
) -> FxHashSet<T>
where
T: std::hash::Hash + Eq,
{
self.filter_and_map(|mca| mca.profile_id == profile_id, func)
self.filter_and_map(|mca| mca.profile_id == *profile_id, func)
}
}
@ -396,7 +397,7 @@ pub async fn validate_connectors_in_routing_config(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &str,
profile_id: &common_utils::id_type::ProfileId,
routing_algorithm: &routing_types::RoutingAlgorithm,
) -> RouterResult<()> {
let all_mcas = &*state
@ -413,13 +414,13 @@ pub async fn validate_connectors_in_routing_config(
})?;
let name_mca_id_set = all_mcas
.iter()
.filter(|mca| mca.profile_id == profile_id)
.filter(|mca| mca.profile_id == *profile_id)
.map(|mca| (&mca.connector_name, mca.get_id()))
.collect::<FxHashSet<_>>();
let name_set = all_mcas
.iter()
.filter(|mca| mca.profile_id == profile_id)
.filter(|mca| mca.profile_id == *profile_id)
.map(|mca| &mca.connector_name)
.collect::<FxHashSet<_>>();