mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
refactor(core): add profile_id for default_fallback api (#6546)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -909,26 +909,30 @@ pub async fn retrieve_default_fallback_algorithm_for_profile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v1")]
|
#[cfg(feature = "v1")]
|
||||||
|
|
||||||
pub async fn retrieve_default_routing_config(
|
pub async fn retrieve_default_routing_config(
|
||||||
state: SessionState,
|
state: SessionState,
|
||||||
|
profile_id: Option<common_utils::id_type::ProfileId>,
|
||||||
merchant_account: domain::MerchantAccount,
|
merchant_account: domain::MerchantAccount,
|
||||||
transaction_type: &enums::TransactionType,
|
transaction_type: &enums::TransactionType,
|
||||||
) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {
|
) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {
|
||||||
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(&metrics::CONTEXT, 1, &[]);
|
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(&metrics::CONTEXT, 1, &[]);
|
||||||
let db = state.store.as_ref();
|
let db = state.store.as_ref();
|
||||||
|
let id = profile_id
|
||||||
|
.map(|profile_id| profile_id.get_string_repr().to_owned())
|
||||||
|
.unwrap_or_else(|| merchant_account.get_id().get_string_repr().to_string());
|
||||||
|
|
||||||
helpers::get_merchant_default_config(
|
helpers::get_merchant_default_config(db, &id, transaction_type)
|
||||||
db,
|
.await
|
||||||
merchant_account.get_id().get_string_repr(),
|
.map(|conn_choice| {
|
||||||
transaction_type,
|
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE.add(
|
||||||
)
|
&metrics::CONTEXT,
|
||||||
.await
|
1,
|
||||||
.map(|conn_choice| {
|
&[],
|
||||||
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE.add(&metrics::CONTEXT, 1, &[]);
|
);
|
||||||
service_api::ApplicationResponse::Json(conn_choice)
|
service_api::ApplicationResponse::Json(conn_choice)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v2")]
|
#[cfg(feature = "v2")]
|
||||||
pub async fn retrieve_routing_config_under_profile(
|
pub async fn retrieve_routing_config_under_profile(
|
||||||
state: SessionState,
|
state: SessionState,
|
||||||
|
|||||||
@ -758,22 +758,14 @@ impl Routing {
|
|||||||
},
|
},
|
||||||
)))
|
)))
|
||||||
.service(
|
.service(
|
||||||
web::resource("/default")
|
web::resource("/default").route(web::post().to(|state, req, payload| {
|
||||||
.route(web::get().to(|state, req| {
|
routing::routing_update_default_config(
|
||||||
routing::routing_retrieve_default_config(
|
state,
|
||||||
state,
|
req,
|
||||||
req,
|
payload,
|
||||||
&TransactionType::Payment,
|
&TransactionType::Payment,
|
||||||
)
|
)
|
||||||
}))
|
})),
|
||||||
.route(web::post().to(|state, req, payload| {
|
|
||||||
routing::routing_update_default_config(
|
|
||||||
state,
|
|
||||||
req,
|
|
||||||
payload,
|
|
||||||
&TransactionType::Payment,
|
|
||||||
)
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/deactivate").route(web::post().to(|state, req, payload| {
|
web::resource("/deactivate").route(web::post().to(|state, req, payload| {
|
||||||
@ -807,11 +799,7 @@ impl Routing {
|
|||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/default/profile").route(web::get().to(|state, req| {
|
web::resource("/default/profile").route(web::get().to(|state, req| {
|
||||||
routing::routing_retrieve_default_config_for_profiles(
|
routing::routing_retrieve_default_config(state, req, &TransactionType::Payment)
|
||||||
state,
|
|
||||||
req,
|
|
||||||
&TransactionType::Payment,
|
|
||||||
)
|
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -565,17 +565,13 @@ pub async fn routing_retrieve_default_config(
|
|||||||
&req,
|
&req,
|
||||||
(),
|
(),
|
||||||
|state, auth: auth::AuthenticationData, _, _| {
|
|state, auth: auth::AuthenticationData, _, _| {
|
||||||
routing::retrieve_default_routing_config(state, auth.merchant_account, transaction_type)
|
routing::retrieve_default_routing_config(
|
||||||
|
state,
|
||||||
|
auth.profile_id,
|
||||||
|
auth.merchant_account,
|
||||||
|
transaction_type,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
#[cfg(not(feature = "release"))]
|
|
||||||
auth::auth_type(
|
|
||||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
|
||||||
&auth::JWTAuth {
|
|
||||||
permission: Permission::ProfileRoutingRead,
|
|
||||||
},
|
|
||||||
req.headers(),
|
|
||||||
),
|
|
||||||
#[cfg(feature = "release")]
|
|
||||||
&auth::JWTAuth {
|
&auth::JWTAuth {
|
||||||
permission: Permission::ProfileRoutingRead,
|
permission: Permission::ProfileRoutingRead,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user