mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	refactor: use business profile domain models instead of diesel models (#5566)
This commit is contained in:
		| @ -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 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sanchith Hegde
					Sanchith Hegde