Skip to content

Commit 0eaadc4

Browse files
hrithikesh026hyperswitch-bot[bot]SanchithHegde
authored
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 <[email protected]>
1 parent 800da6a commit 0eaadc4

File tree

7 files changed

+115
-6
lines changed

7 files changed

+115
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
openapi: post /v2/organization
3+
---
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
openapi: get /v2/organization/{organization_id}
3+
---
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
openapi: put /v2/organization/{organization_id}
3+
---

api-reference-v2/mint.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
"essentials/go-live"
3535
]
3636
},
37+
{
38+
"group": "Organization",
39+
"pages": [
40+
"api-reference/organization/organization--create",
41+
"api-reference/organization/organization--retrieve",
42+
"api-reference/organization/organization--update"
43+
]
44+
},
3745
{
3846
"group": "Merchant Account",
3947
"pages": [

api-reference-v2/openapi_spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
],
2222
"paths": {
23-
"/organization": {
23+
"/v2/organization": {
2424
"post": {
2525
"tags": [
2626
"Organization"
@@ -67,7 +67,7 @@
6767
]
6868
}
6969
},
70-
"/organization/{organization_id}": {
70+
"/v2/organization/{organization_id}": {
7171
"get": {
7272
"tags": [
7373
"Organization"

crates/openapi/src/routes/organization.rs

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(any(feature = "v1", feature = "v2"))]
1+
#[cfg(feature = "v1")]
22
/// Organization - Create
33
///
44
/// Create a new organization
@@ -25,7 +25,7 @@
2525
)]
2626
pub async fn organization_create() {}
2727

28-
#[cfg(any(feature = "v1", feature = "v2"))]
28+
#[cfg(feature = "v1")]
2929
/// Organization - Retrieve
3030
///
3131
/// Retrieve an existing organization
@@ -43,7 +43,7 @@ pub async fn organization_create() {}
4343
)]
4444
pub async fn organization_retrieve() {}
4545

46-
#[cfg(any(feature = "v1", feature = "v2"))]
46+
#[cfg(feature = "v1")]
4747
/// Organization - Update
4848
///
4949
/// Create a new organization for .
@@ -70,3 +70,76 @@ pub async fn organization_retrieve() {}
7070
security(("admin_api_key" = []))
7171
)]
7272
pub async fn organization_update() {}
73+
74+
#[cfg(feature = "v2")]
75+
/// Organization - Create
76+
///
77+
/// Create a new organization
78+
#[utoipa::path(
79+
post,
80+
path = "/v2/organization",
81+
request_body(
82+
content = OrganizationRequest,
83+
examples(
84+
(
85+
"Create an organization with organization_name" = (
86+
value = json!({"organization_name": "organization_abc"})
87+
)
88+
),
89+
)
90+
),
91+
responses(
92+
(status = 200, description = "Organization Created", body =OrganizationResponse),
93+
(status = 400, description = "Invalid data")
94+
),
95+
tag = "Organization",
96+
operation_id = "Create an Organization",
97+
security(("admin_api_key" = []))
98+
)]
99+
pub async fn organization_create() {}
100+
101+
#[cfg(feature = "v2")]
102+
/// Organization - Retrieve
103+
///
104+
/// Retrieve an existing organization
105+
#[utoipa::path(
106+
get,
107+
path = "/v2/organization/{organization_id}",
108+
params (("organization_id" = String, Path, description = "The unique identifier for the Organization")),
109+
responses(
110+
(status = 200, description = "Organization Created", body =OrganizationResponse),
111+
(status = 400, description = "Invalid data")
112+
),
113+
tag = "Organization",
114+
operation_id = "Retrieve an Organization",
115+
security(("admin_api_key" = []))
116+
)]
117+
pub async fn organization_retrieve() {}
118+
119+
#[cfg(feature = "v2")]
120+
/// Organization - Update
121+
///
122+
/// Create a new organization for .
123+
#[utoipa::path(
124+
put,
125+
path = "/v2/organization/{organization_id}",
126+
request_body(
127+
content = OrganizationRequest,
128+
examples(
129+
(
130+
"Update organization_name of the organization" = (
131+
value = json!({"organization_name": "organization_abcd"})
132+
)
133+
),
134+
)
135+
),
136+
params (("organization_id" = String, Path, description = "The unique identifier for the Organization")),
137+
responses(
138+
(status = 200, description = "Organization Created", body =OrganizationResponse),
139+
(status = 400, description = "Invalid data")
140+
),
141+
tag = "Organization",
142+
operation_id = "Update an Organization",
143+
security(("admin_api_key" = []))
144+
)]
145+
pub async fn organization_update() {}

crates/router/src/routes/app.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,12 @@ impl Blocklist {
11371137

11381138
#[cfg(feature = "olap")]
11391139
pub struct Organization;
1140-
#[cfg(feature = "olap")]
1140+
1141+
#[cfg(all(
1142+
feature = "olap",
1143+
any(feature = "v1", feature = "v2"),
1144+
not(feature = "merchant_account_v2")
1145+
))]
11411146
impl Organization {
11421147
pub fn server(state: AppState) -> Scope {
11431148
web::scope("/organization")
@@ -1151,6 +1156,20 @@ impl Organization {
11511156
}
11521157
}
11531158

1159+
#[cfg(all(feature = "v2", feature = "olap", feature = "merchant_account_v2"))]
1160+
impl Organization {
1161+
pub fn server(state: AppState) -> Scope {
1162+
web::scope("/v2/organization")
1163+
.app_data(web::Data::new(state))
1164+
.service(web::resource("").route(web::post().to(organization_create)))
1165+
.service(
1166+
web::resource("/{id}")
1167+
.route(web::get().to(organization_retrieve))
1168+
.route(web::put().to(organization_update)),
1169+
)
1170+
}
1171+
}
1172+
11541173
pub struct MerchantAccount;
11551174

11561175
#[cfg(all(feature = "v2", feature = "olap", feature = "merchant_account_v2"))]

0 commit comments

Comments
 (0)