From 95df8bc449850ed146501ac3f0e24e3a9ee60bef Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Mon, 6 Jan 2025 16:04:02 +0530 Subject: [PATCH] fix(router): Consistently use PUT instead of PATCH in v2 --- .../payment-methods/payment-method--update.mdx | 2 +- .../profile/profile--activate-routing-algorithm.mdx | 2 +- .../profile/profile--deactivate-routing-algorithm.mdx | 2 +- ...profile--update-default-fallback-routing-algorithm.mdx | 2 +- api-reference-v2/openapi_spec.json | 8 ++++---- crates/openapi/src/routes/payment_method.rs | 2 +- crates/openapi/src/routes/profile.rs | 6 +++--- crates/router/src/routes/app.rs | 8 ++++---- cypress-tests-v2/cypress/support/commands.js | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx index 0adee195a6f..7f5f41668f5 100644 --- a/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx +++ b/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/payment-methods/{id}/update-saved-payment-method +openapi: put /v2/payment-methods/{id}/update-saved-payment-method --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx index ea9ee7596a0..df92420f09b 100644 --- a/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/profiles/{id}/activate-routing-algorithm +openapi: put /v2/profiles/{id}/activate-routing-algorithm --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx index 4d6b2d620c6..746bdf1e772 100644 --- a/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/profiles/{id}/deactivate-routing-algorithm +openapi: put /v2/profiles/{id}/deactivate-routing-algorithm --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx index b5df6a57ef8..61c7cbe1d55 100644 --- a/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/profiles/{id}/fallback-routing +openapi: put /v2/profiles/{id}/fallback-routing --- \ No newline at end of file diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index f1caede89cc..4f115be47ad 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -916,7 +916,7 @@ } }, "/v2/profiles/{id}/activate-routing-algorithm": { - "patch": { + "put": { "tags": [ "Profile" ], @@ -983,7 +983,7 @@ } }, "/v2/profiles/{id}/deactivate-routing-algorithm": { - "patch": { + "put": { "tags": [ "Profile" ], @@ -1036,7 +1036,7 @@ } }, "/v2/profiles/{id}/fallback-routing": { - "patch": { + "put": { "tags": [ "Profile" ], @@ -2397,7 +2397,7 @@ } }, "/v2/payment-methods/{id}/update-saved-payment-method": { - "patch": { + "put": { "tags": [ "Payment Methods" ], diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index b38a2342678..2939d54e4e1 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -285,7 +285,7 @@ pub async fn payment_method_retrieve_api() {} /// /// Update an existing payment method of a customer. #[utoipa::path( - patch, + put, path = "/v2/payment-methods/{id}/update-saved-payment-method", request_body( content = PaymentMethodUpdate, diff --git a/crates/openapi/src/routes/profile.rs b/crates/openapi/src/routes/profile.rs index cc484aa3f95..1a50c8ee557 100644 --- a/crates/openapi/src/routes/profile.rs +++ b/crates/openapi/src/routes/profile.rs @@ -209,7 +209,7 @@ pub async fn profile_update() {} /// /// Activates a routing algorithm under a profile #[utoipa::path( - patch, + put, path = "/v2/profiles/{id}/activate-routing-algorithm", request_body ( content = RoutingAlgorithmId, examples( ( @@ -239,7 +239,7 @@ pub async fn routing_link_config() {} /// /// Deactivates a routing algorithm under a profile #[utoipa::path( - patch, + put, path = "/v2/profiles/{id}/deactivate-routing-algorithm", params( ("id" = String, Path, description = "The unique identifier for the profile"), @@ -262,7 +262,7 @@ pub async fn routing_unlink_config() {} /// /// Update the default fallback routing algorithm for the profile #[utoipa::path( - patch, + put, path = "/v2/profiles/{id}/fallback-routing", request_body = Vec, params( diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index f9dbec77452..8a2f153dd52 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -1161,7 +1161,7 @@ impl PaymentMethods { ) .service( web::resource("/{id}/update-saved-payment-method") - .route(web::patch().to(payment_method_update_api)), + .route(web::put().to(payment_method_update_api)), ) .service( web::resource("/{id}") @@ -1754,10 +1754,10 @@ impl Profile { .service( web::resource("/fallback-routing") .route(web::get().to(routing::routing_retrieve_default_config)) - .route(web::patch().to(routing::routing_update_default_config)), + .route(web::put().to(routing::routing_update_default_config)), ) .service( - web::resource("/activate-routing-algorithm").route(web::patch().to( + web::resource("/activate-routing-algorithm").route(web::put().to( |state, req, path, payload| { routing::routing_link_config( state, @@ -1770,7 +1770,7 @@ impl Profile { )), ) .service( - web::resource("/deactivate-routing-algorithm").route(web::patch().to( + web::resource("/deactivate-routing-algorithm").route(web::put().to( |state, req, path| { routing::routing_unlink_config( state, diff --git a/cypress-tests-v2/cypress/support/commands.js b/cypress-tests-v2/cypress/support/commands.js index b6955c542a7..bbd65be4b59 100644 --- a/cypress-tests-v2/cypress/support/commands.js +++ b/cypress-tests-v2/cypress/support/commands.js @@ -853,7 +853,7 @@ Cypress.Commands.add( routingActivationBody.routing_algorithm_id = routing_algorithm_id; cy.request({ - method: "PATCH", + method: "PUT", url: url, headers: { Authorization: `Bearer ${api_key}`, @@ -925,7 +925,7 @@ Cypress.Commands.add("routingDeactivateCall", (globalState) => { const url = `${base_url}/v2/profiles/${profile_id}/deactivate-routing-algorithm`; cy.request({ - method: "PATCH", + method: "PUT", url: url, headers: { Authorization: `Bearer ${api_key}`,