chore: create v2 route for organization (#5679)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
Hrithikesh
2024-08-26 12:20:11 +05:30
committed by GitHub
parent 800da6a16a
commit 0eaadc42b7
7 changed files with 115 additions and 6 deletions

View File

@ -0,0 +1,3 @@
---
openapi: post /v2/organization
---

View File

@ -0,0 +1,3 @@
---
openapi: get /v2/organization/{organization_id}
---

View File

@ -0,0 +1,3 @@
---
openapi: put /v2/organization/{organization_id}
---

View File

@ -34,6 +34,14 @@
"essentials/go-live"
]
},
{
"group": "Organization",
"pages": [
"api-reference/organization/organization--create",
"api-reference/organization/organization--retrieve",
"api-reference/organization/organization--update"
]
},
{
"group": "Merchant Account",
"pages": [

View File

@ -20,7 +20,7 @@
}
],
"paths": {
"/organization": {
"/v2/organization": {
"post": {
"tags": [
"Organization"
@ -67,7 +67,7 @@
]
}
},
"/organization/{organization_id}": {
"/v2/organization/{organization_id}": {
"get": {
"tags": [
"Organization"

View File

@ -1,4 +1,4 @@
#[cfg(any(feature = "v1", feature = "v2"))]
#[cfg(feature = "v1")]
/// Organization - Create
///
/// Create a new organization
@ -25,7 +25,7 @@
)]
pub async fn organization_create() {}
#[cfg(any(feature = "v1", feature = "v2"))]
#[cfg(feature = "v1")]
/// Organization - Retrieve
///
/// Retrieve an existing organization
@ -43,7 +43,7 @@ pub async fn organization_create() {}
)]
pub async fn organization_retrieve() {}
#[cfg(any(feature = "v1", feature = "v2"))]
#[cfg(feature = "v1")]
/// Organization - Update
///
/// Create a new organization for .
@ -70,3 +70,76 @@ pub async fn organization_retrieve() {}
security(("admin_api_key" = []))
)]
pub async fn organization_update() {}
#[cfg(feature = "v2")]
/// Organization - Create
///
/// Create a new organization
#[utoipa::path(
post,
path = "/v2/organization",
request_body(
content = OrganizationRequest,
examples(
(
"Create an organization with organization_name" = (
value = json!({"organization_name": "organization_abc"})
)
),
)
),
responses(
(status = 200, description = "Organization Created", body =OrganizationResponse),
(status = 400, description = "Invalid data")
),
tag = "Organization",
operation_id = "Create an Organization",
security(("admin_api_key" = []))
)]
pub async fn organization_create() {}
#[cfg(feature = "v2")]
/// Organization - Retrieve
///
/// Retrieve an existing organization
#[utoipa::path(
get,
path = "/v2/organization/{organization_id}",
params (("organization_id" = String, Path, description = "The unique identifier for the Organization")),
responses(
(status = 200, description = "Organization Created", body =OrganizationResponse),
(status = 400, description = "Invalid data")
),
tag = "Organization",
operation_id = "Retrieve an Organization",
security(("admin_api_key" = []))
)]
pub async fn organization_retrieve() {}
#[cfg(feature = "v2")]
/// Organization - Update
///
/// Create a new organization for .
#[utoipa::path(
put,
path = "/v2/organization/{organization_id}",
request_body(
content = OrganizationRequest,
examples(
(
"Update organization_name of the organization" = (
value = json!({"organization_name": "organization_abcd"})
)
),
)
),
params (("organization_id" = String, Path, description = "The unique identifier for the Organization")),
responses(
(status = 200, description = "Organization Created", body =OrganizationResponse),
(status = 400, description = "Invalid data")
),
tag = "Organization",
operation_id = "Update an Organization",
security(("admin_api_key" = []))
)]
pub async fn organization_update() {}

View File

@ -1137,7 +1137,12 @@ impl Blocklist {
#[cfg(feature = "olap")]
pub struct Organization;
#[cfg(feature = "olap")]
#[cfg(all(
feature = "olap",
any(feature = "v1", feature = "v2"),
not(feature = "merchant_account_v2")
))]
impl Organization {
pub fn server(state: AppState) -> Scope {
web::scope("/organization")
@ -1151,6 +1156,20 @@ impl Organization {
}
}
#[cfg(all(feature = "v2", feature = "olap", feature = "merchant_account_v2"))]
impl Organization {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/organization")
.app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(organization_create)))
.service(
web::resource("/{id}")
.route(web::get().to(organization_retrieve))
.route(web::put().to(organization_update)),
)
}
}
pub struct MerchantAccount;
#[cfg(all(feature = "v2", feature = "olap", feature = "merchant_account_v2"))]