fix(openapi): Standardise API naming scheme for V2 (#6510)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Anurag Thakur
2024-11-29 15:58:59 +05:30
committed by GitHub
parent 9212f77684
commit 96393ff3d6
50 changed files with 872 additions and 167 deletions

View File

@ -556,11 +556,15 @@ impl Payments {
)
.service(web::resource("").route(web::get().to(payments::payment_status)))
.service(
web::resource("/start_redirection")
web::resource("/start-redirection")
.route(web::get().to(payments::payments_start_redirection)),
)
.service(
web::resource("/finish_redirection/{publishable_key}/{profile_id}")
web::resource("/saved-payment-methods")
.route(web::get().to(list_customer_payment_method_for_payment)),
)
.service(
web::resource("/finish-redirection/{publishable_key}/{profile_id}")
.route(web::get().to(payments::payments_finish_redirection)),
),
);
@ -715,7 +719,7 @@ pub struct Routing;
#[cfg(all(feature = "olap", feature = "v2"))]
impl Routing {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/routing_algorithm")
web::scope("/v2/routing-algorithm")
.app_data(web::Data::new(state.clone()))
.service(
web::resource("").route(web::post().to(|state, req, payload| {
@ -968,7 +972,7 @@ impl Customers {
#[cfg(all(feature = "oltp", feature = "v2", feature = "payment_methods_v2"))]
{
route = route.service(
web::resource("/{customer_id}/saved_payment_methods")
web::resource("/{customer_id}/saved-payment-methods")
.route(web::get().to(list_customer_payment_method_api)),
);
}
@ -1113,7 +1117,7 @@ impl Payouts {
#[cfg(all(feature = "oltp", feature = "v2", feature = "payment_methods_v2",))]
impl PaymentMethods {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/v2/payment_methods").app_data(web::Data::new(state));
let mut route = web::scope("/v2/payment-methods").app_data(web::Data::new(state));
route = route
.service(web::resource("").route(web::post().to(create_payment_method_api)))
.service(
@ -1125,7 +1129,7 @@ impl PaymentMethods {
.route(web::post().to(confirm_payment_method_intent_api)),
)
.service(
web::resource("/{id}/update_saved_payment_method")
web::resource("/{id}/update-saved-payment-method")
.route(web::patch().to(payment_method_update_api)),
)
.service(web::resource("/{id}").route(web::get().to(payment_method_retrieve_api)))
@ -1267,7 +1271,7 @@ impl Organization {
.route(web::put().to(admin::organization_update)),
)
.service(
web::resource("/merchant_accounts")
web::resource("/merchant-accounts")
.route(web::get().to(admin::merchant_account_list)),
),
)
@ -1279,7 +1283,7 @@ pub struct MerchantAccount;
#[cfg(all(feature = "v2", feature = "olap"))]
impl MerchantAccount {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/merchant_accounts")
web::scope("/v2/merchant-accounts")
.app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(admin::merchant_account_create)))
.service(
@ -1329,7 +1333,7 @@ pub struct MerchantConnectorAccount;
#[cfg(all(any(feature = "olap", feature = "oltp"), feature = "v2"))]
impl MerchantConnectorAccount {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/v2/connector_accounts").app_data(web::Data::new(state));
let mut route = web::scope("/v2/connector-accounts").app_data(web::Data::new(state));
#[cfg(feature = "olap")]
{
@ -1526,7 +1530,7 @@ pub struct ApiKeys;
#[cfg(all(feature = "olap", feature = "v2"))]
impl ApiKeys {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/api_keys")
web::scope("/v2/api-keys")
.app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(api_keys::api_key_create)))
.service(web::resource("/list").route(web::get().to(api_keys::api_key_list)))
@ -1691,16 +1695,16 @@ impl Profile {
.route(web::put().to(profiles::profile_update)),
)
.service(
web::resource("/connector_accounts")
web::resource("/connector-accounts")
.route(web::get().to(admin::connector_list)),
)
.service(
web::resource("/fallback_routing")
web::resource("/fallback-routing")
.route(web::get().to(routing::routing_retrieve_default_config))
.route(web::patch().to(routing::routing_update_default_config)),
)
.service(
web::resource("/activate_routing_algorithm").route(web::patch().to(
web::resource("/activate-routing-algorithm").route(web::patch().to(
|state, req, path, payload| {
routing::routing_link_config(
state,
@ -1713,7 +1717,7 @@ impl Profile {
)),
)
.service(
web::resource("/deactivate_routing_algorithm").route(web::patch().to(
web::resource("/deactivate-routing-algorithm").route(web::patch().to(
|state, req, path| {
routing::routing_unlink_config(
state,
@ -1724,7 +1728,7 @@ impl Profile {
},
)),
)
.service(web::resource("/routing_algorithm").route(web::get().to(
.service(web::resource("/routing-algorithm").route(web::get().to(
|state, req, query_params, path| {
routing::routing_retrieve_linked_config(
state,
@ -1999,7 +2003,7 @@ impl User {
)
.service(web::resource("/verify_email").route(web::post().to(user::verify_email)))
.service(
web::resource("/v2/verify_email").route(web::post().to(user::verify_email)),
web::resource("/v2/verify-email").route(web::post().to(user::verify_email)),
)
.service(
web::resource("/verify_email_request")
@ -2053,7 +2057,7 @@ impl User {
.route(web::post().to(user_role::accept_invitations_v2)),
)
.service(
web::resource("/pre_auth").route(
web::resource("/pre-auth").route(
web::post().to(user_role::accept_invitations_pre_auth),
),
),

View File

@ -508,30 +508,6 @@ pub async fn list_customer_payment_method_api(
}
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
/// List payment methods for a Customer v2
///
/// To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment
#[utoipa::path(
get,
path = "v2/payments/{payment_id}/saved_payment_methods",
params (
("client-secret" = String, Path, description = "A secret known only to your application and the authorization server"),
("accepted_country" = Vec<String>, Query, description = "The two-letter ISO currency code"),
("accepted_currency" = Vec<Currency>, Path, description = "The three-letter ISO currency code"),
("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."),
("maximum_amount" = i64, Query, description = "The maximum amount amount accepted for processing by the particular payment method."),
("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"),
("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"),
),
responses(
(status = 200, description = "Payment Methods retrieved for customer tied to its respective client-secret passed in the param", body = CustomerPaymentMethodsListResponse),
(status = 400, description = "Invalid Data"),
(status = 404, description = "Payment Methods does not exist in records")
),
tag = "Payment Methods",
operation_id = "List all Payment Methods for a Customer",
security(("publishable_key" = []))
)]
#[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))]
pub async fn list_customer_payment_method_for_payment(
state: web::Data<AppState>,
@ -575,29 +551,6 @@ pub async fn list_customer_payment_method_for_payment(
feature = "payment_methods_v2",
feature = "customer_v2"
))]
/// List payment methods for a Customer v2
///
/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context
#[utoipa::path(
get,
path = "v2/customers/{customer_id}/saved_payment_methods",
params (
("accepted_country" = Vec<String>, Query, description = "The two-letter ISO currency code"),
("accepted_currency" = Vec<Currency>, Path, description = "The three-letter ISO currency code"),
("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."),
("maximum_amount" = i64, Query, description = "The maximum amount amount accepted for processing by the particular payment method."),
("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"),
("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"),
),
responses(
(status = 200, description = "Payment Methods retrieved", body = CustomerPaymentMethodsListResponse),
(status = 400, description = "Invalid Data"),
(status = 404, description = "Payment Methods does not exist in records")
),
tag = "Payment Methods",
operation_id = "List all Payment Methods for a Customer",
security(("api_key" = []))
)]
#[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))]
pub async fn list_customer_payment_method_api(
state: web::Data<AppState>,

View File

@ -34,6 +34,10 @@ use crate::{
impl ForeignFrom<diesel_models::organization::Organization> for OrganizationResponse {
fn foreign_from(org: diesel_models::organization::Organization) -> Self {
Self {
#[cfg(feature = "v2")]
id: org.get_organization_id(),
#[cfg(feature = "v1")]
organization_id: org.get_organization_id(),
organization_name: org.get_organization_name(),
organization_details: org.organization_details,