refactor(routing): Api v2 for routing create and activate endpoints (#5423)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Amisha Prabhat
2024-08-01 15:00:28 +05:30
committed by GitHub
parent 1d4c87a9e3
commit 6140cfe04e
11 changed files with 568 additions and 139 deletions

View File

@ -3,7 +3,7 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};
use crate::routing::{
LinkedRoutingConfigRetrieveResponse, MerchantRoutingAlgorithm, ProfileDefaultRoutingConfig,
RoutingAlgorithmId, RoutingConfigRequest, RoutingDictionaryRecord, RoutingKind,
RoutingPayloadWrapper, RoutingRetrieveLinkQuery, RoutingRetrieveQuery,
RoutingLinkWrapper, RoutingPayloadWrapper, RoutingRetrieveLinkQuery, RoutingRetrieveQuery,
};
impl ApiEventMetric for RoutingKind {
@ -64,3 +64,9 @@ impl ApiEventMetric for RoutingRetrieveLinkQuery {
Some(ApiEventsType::Routing)
}
}
impl ApiEventMetric for RoutingLinkWrapper {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Routing)
}
}

View File

@ -1,6 +1,6 @@
use std::fmt::Debug;
use common_utils::errors::ParsingError;
use common_utils::{errors::ParsingError, ext_traits::ValueExt, pii};
pub use euclid::{
dssa::types::EuclidAnalysable,
frontend::{
@ -427,6 +427,14 @@ impl RoutingAlgorithmRef {
self.surcharge_config_algo_id = Some(ids);
self.timestamp = common_utils::date_time::now_unix_timestamp();
}
pub fn parse_routing_algorithm(
value: Option<pii::SecretSerdeValue>,
) -> Result<Option<Self>, error_stack::Report<ParsingError>> {
value
.map(|val| val.parse_value::<Self>("RoutingAlgorithmRef"))
.transpose()
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
@ -459,6 +467,12 @@ pub enum RoutingKind {
}
#[repr(transparent)]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(transparent)]
pub struct RoutingAlgorithmId(pub String);
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct RoutingLinkWrapper {
pub profile_id: String,
pub algorithm_id: RoutingAlgorithmId,
}