refactor: use business profile domain models instead of diesel models (#5566)

This commit is contained in:
Sanchith Hegde
2024-08-08 15:39:02 +05:30
committed by GitHub
parent baaa73cff9
commit e56ad0d688
69 changed files with 913 additions and 990 deletions

View File

@ -3,11 +3,8 @@
//! Functions that are used to perform the retrieval of merchant's
//! routing dict, configs, defaults
use api_models::routing as routing_types;
use common_utils::ext_traits::Encode;
use diesel_models::{
business_profile::{BusinessProfile, BusinessProfileUpdate},
configs,
};
use common_utils::{ext_traits::Encode, types::keymanager::KeyManagerState};
use diesel_models::configs;
use error_stack::ResultExt;
use rustc_hash::FxHashSet;
use storage_impl::redis::cache;
@ -190,7 +187,9 @@ pub async fn update_merchant_active_algorithm_ref(
pub async fn update_business_profile_active_algorithm_ref(
db: &dyn StorageInterface,
current_business_profile: BusinessProfile,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_business_profile: domain::BusinessProfile,
algorithm_id: routing_types::RoutingAlgorithmRef,
transaction_type: &storage::enums::TransactionType,
) -> RouterResult<()> {
@ -217,15 +216,20 @@ pub async fn update_business_profile_active_algorithm_ref(
storage::enums::TransactionType::Payout => (None, Some(ref_val)),
};
let business_profile_update = BusinessProfileUpdate::RoutingAlgorithmUpdate {
let business_profile_update = domain::BusinessProfileUpdate::RoutingAlgorithmUpdate {
routing_algorithm,
payout_routing_algorithm,
};
db.update_business_profile_by_profile_id(current_business_profile, business_profile_update)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update routing algorithm ref in business profile")?;
db.update_business_profile_by_profile_id(
key_manager_state,
merchant_key_store,
current_business_profile,
business_profile_update,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update routing algorithm ref in business profile")?;
cache::publish_into_redact_channel(db.get_cache_store().as_ref(), [routing_cache_key])
.await