feat(openapi): Add open api routes for routing v2 (#5686)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Amisha Prabhat
2024-08-27 13:23:46 +05:30
committed by GitHub
parent c3c9b2740b
commit 6bb97671e7
16 changed files with 665 additions and 23 deletions

View File

@ -89,6 +89,17 @@ Never share your secret api keys. Keep them guarded and secure.
routes::business_profile::business_profile_create,
routes::business_profile::business_profile_retrieve,
routes::business_profile::business_profile_update,
// Routes for routing under business profile
routes::business_profile::routing_link_config,
routes::business_profile::routing_unlink_config,
routes::business_profile::routing_update_default_config,
routes::business_profile::routing_retrieve_default_config,
routes::business_profile::routing_retrieve_linked_config,
// Routes for routing
routes::routing::routing_create_config,
routes::routing::routing_retrieve_config,
),
components(schemas(
common_utils::types::MinorUnit,
@ -452,6 +463,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::routing::ast::ValueType,
api_models::routing::ast::MetadataValue,
api_models::routing::ast::NumberComparison,
api_models::routing::RoutingAlgorithmId,
api_models::payment_methods::RequestPaymentMethodTypes,
api_models::payments::PaymentLinkStatus,
api_models::blocklist::BlocklistRequest,

View File

@ -205,3 +205,121 @@ pub async fn business_profile_retrieve() {}
security(("admin_api_key" = []))
)]
pub async fn business_profile_retrieve() {}
#[cfg(feature = "v2")]
/// Business Profile - Retrieve Active Routing Algorithm
///
/// Retrieve active routing algorithm under the business profile
#[utoipa::path(
get,
path = "/v2/profiles/{profile_id}/routing_algorithm",
params(
("profile_id" = String, Path, description = "The unique identifier for the business profile"),
("limit" = Option<u16>, Query, description = "The number of records of the algorithms to be returned"),
("offset" = Option<u8>, Query, description = "The record offset of the algorithm from which to start gathering the results")),
responses(
(status = 200, description = "Successfully retrieved active config", body = LinkedRoutingConfigRetrieveResponse),
(status = 500, description = "Internal server error"),
(status = 404, description = "Resource missing"),
(status = 403, description = "Forbidden")
),
tag = "Business Profile",
operation_id = "Retrieve the active routing algorithm under the business profile",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_retrieve_linked_config() {}
#[cfg(feature = "v2")]
/// Business Profile - Activate routing algorithm
///
/// Activates a routing algorithm under a business profile
#[utoipa::path(
patch,
path = "/v2/profiles/{profile_id}/activate_routing_algorithm",
request_body ( content = RoutingAlgorithmId,
examples( (
"Activate a routing algorithm" = (
value = json!({
"routing_algorithm_id": "routing_algorithm_123"
})
)
))),
params(
("profile_id" = String, Path, description = "The unique identifier for the business profile"),
),
responses(
(status = 200, description = "Routing Algorithm is activated", body = RoutingDictionaryRecord),
(status = 500, description = "Internal server error"),
(status = 404, description = "Resource missing"),
(status = 400, description = "Bad request")
),
tag = "Business Profile",
operation_id = "Activates a routing algorithm under a business profile",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_link_config() {}
#[cfg(feature = "v2")]
/// Business Profile - Deactivate routing algorithm
///
/// Deactivates a routing algorithm under a business profile
#[utoipa::path(
patch,
path = "/v2/profiles/{profile_id}/deactivate_routing_algorithm",
params(
("profile_id" = String, Path, description = "The unique identifier for the business profile"),
),
responses(
(status = 200, description = "Successfully deactivated routing config", body = RoutingDictionaryRecord),
(status = 500, description = "Internal server error"),
(status = 400, description = "Malformed request"),
(status = 403, description = "Malformed request"),
(status = 422, description = "Unprocessable request")
),
tag = "Business Profile",
operation_id = " Deactivates a routing algorithm under a business profile",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_unlink_config() {}
#[cfg(feature = "v2")]
/// Business Profile - Update Default Fallback Routing Algorithm
///
/// Update the default fallback routing algorithm for the business profile
#[utoipa::path(
post,
path = "/v2/profiles/{profile_id}/fallback_routing",
request_body = Vec<RoutableConnectorChoice>,
params(
("profile_id" = String, Path, description = "The unique identifier for the business profile"),
),
responses(
(status = 200, description = "Successfully updated the default fallback routing algorithm", body = Vec<RoutableConnectorChoice>),
(status = 500, description = "Internal server error"),
(status = 400, description = "Malformed request"),
(status = 422, description = "Unprocessable request")
),
tag = "Business Profile",
operation_id = "Update the default fallback routing algorithm for the business profile",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_update_default_config() {}
#[cfg(feature = "v2")]
/// Business Profile - Retrieve Default Fallback Routing Algorithm
///
/// Retrieve the default fallback routing algorithm for the business profile
#[utoipa::path(
get,
path = "/v2/profiles/{profile_id}/fallback_routing",
params(
("profile_id" = String, Path, description = "The unique identifier for the business profile"),
),
responses(
(status = 200, description = "Successfully retrieved default fallback routing algorithm", body = Vec<RoutableConnectorChoice>),
(status = 500, description = "Internal server error")
),
tag = "Business Profile",
operation_id = "Retrieve the default fallback routing algorithm for the business profile",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_retrieve_default_config() {}

View File

@ -1,3 +1,4 @@
#[cfg(feature = "v1")]
/// Routing - Create
///
/// Create a routing config
@ -19,14 +20,37 @@
)]
pub async fn routing_create_config() {}
#[cfg(feature = "v2")]
/// Routing - Create
///
/// Create a routing algorithm
#[utoipa::path(
post,
path = "/v2/routing_algorithm",
request_body = RoutingConfigRequest,
responses(
(status = 200, description = "Routing Algorithm created", body = RoutingDictionaryRecord),
(status = 400, description = "Request body is malformed"),
(status = 500, description = "Internal server error"),
(status = 404, description = "Resource missing"),
(status = 422, description = "Unprocessable request"),
(status = 403, description = "Forbidden"),
),
tag = "Routing",
operation_id = "Create a routing algprithm",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_create_config() {}
#[cfg(feature = "v1")]
/// Routing - Activate config
///
/// Activate a routing config
#[utoipa::path(
post,
path = "/routing/{algorithm_id}/activate",
path = "/routing/{routing_algorithm_id}/activate",
params(
("algorithm_id" = String, Path, description = "The unique identifier for a config"),
("routing_algorithm_id" = String, Path, description = "The unique identifier for a config"),
),
responses(
(status = 200, description = "Routing config activated", body = RoutingDictionaryRecord),
@ -40,15 +64,16 @@ pub async fn routing_create_config() {}
)]
pub async fn routing_link_config() {}
#[cfg(feature = "v1")]
/// Routing - Retrieve
///
/// Retrieve a routing algorithm
#[utoipa::path(
get,
path = "/routing/{algorithm_id}",
path = "/routing/{routing_algorithm_id}",
params(
("algorithm_id" = String, Path, description = "The unique identifier for a config"),
("routing_algorithm_id" = String, Path, description = "The unique identifier for a config"),
),
responses(
(status = 200, description = "Successfully fetched routing config", body = MerchantRoutingAlgorithm),
@ -62,6 +87,30 @@ pub async fn routing_link_config() {}
)]
pub async fn routing_retrieve_config() {}
#[cfg(feature = "v2")]
/// Routing - Retrieve
///
/// Retrieve a routing algorithm with its algorithm id
#[utoipa::path(
get,
path = "/v2/routing_algorithm/{routing_algorithm_id}",
params(
("routing_algorithm_id" = String, Path, description = "The unique identifier for a routing algorithm"),
),
responses(
(status = 200, description = "Successfully fetched routing algorithm", body = MerchantRoutingAlgorithm),
(status = 500, description = "Internal server error"),
(status = 404, description = "Resource missing"),
(status = 403, description = "Forbidden")
),
tag = "Routing",
operation_id = "Retrieve a routing algorithm with its algorithm id",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn routing_retrieve_config() {}
#[cfg(feature = "v1")]
/// Routing - List
///
/// List all routing configs
@ -84,6 +133,7 @@ pub async fn routing_retrieve_config() {}
)]
pub async fn list_routing_configs() {}
#[cfg(feature = "v1")]
/// Routing - Deactivate
///
/// Deactivates a routing config
@ -104,6 +154,7 @@ pub async fn list_routing_configs() {}
)]
pub async fn routing_unlink_config() {}
#[cfg(feature = "v1")]
/// Routing - Update Default Config
///
/// Update default fallback config
@ -123,6 +174,7 @@ pub async fn routing_unlink_config() {}
)]
pub async fn routing_update_default_config() {}
#[cfg(feature = "v1")]
/// Routing - Retrieve Default Config
///
/// Retrieve default fallback config
@ -139,6 +191,7 @@ pub async fn routing_update_default_config() {}
)]
pub async fn routing_retrieve_default_config() {}
#[cfg(feature = "v1")]
/// Routing - Retrieve Config
///
/// Retrieve active config
@ -160,6 +213,7 @@ pub async fn routing_retrieve_default_config() {}
)]
pub async fn routing_retrieve_linked_config() {}
#[cfg(feature = "v1")]
/// Routing - Retrieve Default For Profile
///
/// Retrieve default config for profiles
@ -177,6 +231,7 @@ pub async fn routing_retrieve_linked_config() {}
)]
pub async fn routing_retrieve_default_config_for_profiles() {}
#[cfg(feature = "v1")]
/// Routing - Update Default For Profile
///
/// Update default config for profiles