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

@ -127,6 +127,17 @@ Never share your secret api keys. Keep them guarded and secure.
routes::payments::payments_confirm_intent,
routes::payments::payment_status,
//Routes for payment methods
routes::payment_method::list_customer_payment_method_for_payment,
routes::payment_method::list_customer_payment_method_api,
routes::payment_method::create_payment_method_api,
routes::payment_method::create_payment_method_intent_api,
routes::payment_method::confirm_payment_method_intent_api,
routes::payment_method::payment_method_update_api,
routes::payment_method::payment_method_retrieve_api,
routes::payment_method::payment_method_delete_api,
//Routes for refunds
routes::refunds::refunds_create,
),
@ -170,9 +181,12 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::customers::CustomerRequest,
api_models::customers::CustomerDeleteResponse,
api_models::payment_methods::PaymentMethodCreate,
api_models::payment_methods::PaymentMethodIntentCreate,
api_models::payment_methods::PaymentMethodIntentConfirm,
api_models::payment_methods::PaymentMethodResponse,
api_models::payment_methods::PaymentMethodResponseData,
api_models::payment_methods::CustomerPaymentMethod,
api_models::payment_methods::PaymentMethodListRequest,
api_models::payment_methods::PaymentMethodListResponse,
api_models::payment_methods::ResponsePaymentMethodsEnabled,
api_models::payment_methods::ResponsePaymentMethodTypes,
@ -189,6 +203,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payment_methods::PaymentMethodCreateData,
api_models::payment_methods::CardDetail,
api_models::payment_methods::CardDetailUpdate,
api_models::payment_methods::CardType,
api_models::payment_methods::RequestPaymentMethodTypes,
api_models::payment_methods::CardType,
api_models::payment_methods::PaymentMethodListData,

View File

@ -25,7 +25,7 @@ pub async fn api_key_create() {}
/// displayed only once on creation, so ensure you store it securely.
#[utoipa::path(
post,
path = "/v2/api_keys",
path = "/v2/api-keys",
request_body= CreateApiKeyRequest,
responses(
(status = 200, description = "API Key created", body = CreateApiKeyResponse),
@ -64,7 +64,7 @@ pub async fn api_key_retrieve() {}
/// Retrieve information about the specified API Key.
#[utoipa::path(
get,
path = "/v2/api_keys/{id}",
path = "/v2/api-keys/{id}",
params (
("id" = String, Path, description = "The unique identifier for the API Key")
),
@ -106,7 +106,7 @@ pub async fn api_key_update() {}
/// Update information for the specified API Key.
#[utoipa::path(
put,
path = "/v2/api_keys/{id}",
path = "/v2/api-keys/{id}",
request_body = UpdateApiKeyRequest,
params (
("id" = String, Path, description = "The unique identifier for the API Key")
@ -150,7 +150,7 @@ pub async fn api_key_revoke() {}
/// authenticating with our APIs.
#[utoipa::path(
delete,
path = "/v2/api_keys/{id}",
path = "/v2/api-keys/{id}",
params (
("id" = String, Path, description = "The unique identifier for the API Key")
),
@ -191,7 +191,7 @@ pub async fn api_key_list() {}
/// List all the API Keys associated to a merchant account.
#[utoipa::path(
get,
path = "/v2/api_keys/list",
path = "/v2/api-keys/list",
params(
("limit" = Option<i64>, Query, description = "The maximum number of API Keys to include in the response"),
("skip" = Option<i64>, Query, description = "The number of API Keys to skip when retrieving the list of API keys."),

View File

@ -50,7 +50,7 @@ pub async fn merchant_account_create() {}
/// Before creating the merchant account, it is mandatory to create an organization.
#[utoipa::path(
post,
path = "/v2/merchant_accounts",
path = "/v2/merchant-accounts",
params(
(
"X-Organization-Id" = String, Header,
@ -128,7 +128,7 @@ pub async fn retrieve_merchant_account() {}
/// Retrieve a *merchant* account details.
#[utoipa::path(
get,
path = "/v2/merchant_accounts/{id}",
path = "/v2/merchant-accounts/{id}",
params (("id" = String, Path, description = "The unique identifier for the merchant account")),
responses(
(status = 200, description = "Merchant Account Retrieved", body = MerchantAccountResponse),
@ -190,7 +190,7 @@ pub async fn update_merchant_account() {}
/// Updates details of an existing merchant account. Helpful in updating merchant details such as email, contact details, or other configuration details like webhook, routing algorithm etc
#[utoipa::path(
put,
path = "/v2/merchant_accounts/{id}",
path = "/v2/merchant-accounts/{id}",
request_body (
content = MerchantAccountUpdate,
examples(
@ -300,7 +300,7 @@ pub async fn payment_connector_list_profile() {}
/// List profiles for an Merchant
#[utoipa::path(
get,
path = "/v2/merchant_accounts/{id}/profiles",
path = "/v2/merchant-accounts/{id}/profiles",
params (("id" = String, Path, description = "The unique identifier for the Merchant")),
responses(
(status = 200, description = "profile list retrieved successfully", body = Vec<ProfileResponse>),

View File

@ -67,7 +67,7 @@ pub async fn connector_create() {}
#[cfg(feature = "v2")]
#[utoipa::path(
post,
path = "/v2/connector_accounts",
path = "/v2/connector-accounts",
request_body(
content = MerchantConnectorCreate,
examples(
@ -152,7 +152,7 @@ pub async fn connector_retrieve() {}
#[cfg(feature = "v2")]
#[utoipa::path(
get,
path = "/v2/connector_accounts/{id}",
path = "/v2/connector-accounts/{id}",
params(
("id" = i32, Path, description = "The unique identifier for the Merchant Connector")
),
@ -241,7 +241,7 @@ pub async fn connector_update() {}
#[cfg(feature = "v2")]
#[utoipa::path(
put,
path = "/v2/connector_accounts/{id}",
path = "/v2/connector-accounts/{id}",
request_body(
content = MerchantConnectorUpdate,
examples(
@ -310,7 +310,7 @@ pub async fn connector_delete() {}
#[cfg(feature = "v2")]
#[utoipa::path(
delete,
path = "/v2/connector_accounts/{id}",
path = "/v2/connector-accounts/{id}",
params(
("id" = i32, Path, description = "The unique identifier for the Merchant Connector")
),

View File

@ -150,7 +150,7 @@ pub async fn organization_update() {}
/// List merchant accounts for an Organization
#[utoipa::path(
get,
path = "/v2/organization/{id}/merchant_accounts",
path = "/v2/organization/{id}/merchant-accounts",
params (("id" = String, Path, description = "The unique identifier for the Organization")),
responses(
(status = 200, description = "Merchant Account list retrieved successfully", body = Vec<MerchantAccountResponse>),

View File

@ -31,6 +31,7 @@
operation_id = "Create a Payment Method",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn create_payment_method_api() {}
/// List payment methods for a Merchant
@ -84,6 +85,7 @@ pub async fn list_payment_method_api() {}
operation_id = "List all Payment Methods for a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn list_customer_payment_method_api() {}
/// List customer saved payment methods for a Payment
@ -130,6 +132,7 @@ pub async fn list_customer_payment_method_api_client() {}
operation_id = "Retrieve a Payment method",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn payment_method_retrieve_api() {}
/// Payment Method - Update
@ -151,6 +154,7 @@ pub async fn payment_method_retrieve_api() {}
operation_id = "Update a Payment method",
security(("api_key" = []), ("publishable_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn payment_method_update_api() {}
/// Payment Method - Delete
@ -170,6 +174,7 @@ pub async fn payment_method_update_api() {}
operation_id = "Delete a Payment method",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn payment_method_delete_api() {}
/// Payment Method - Set Default Payment Method for Customer
@ -192,3 +197,171 @@ pub async fn payment_method_delete_api() {}
security(("ephemeral_key" = []))
)]
pub async fn default_payment_method_set_api() {}
/// Payment Method - Create Intent
///
/// Creates a payment method for customer with billing information and other metadata.
#[utoipa::path(
post,
path = "/v2/payment-methods/create-intent",
request_body(
content = PaymentMethodIntentCreate,
// TODO: Add examples
),
responses(
(status = 200, description = "Payment Method Intent Created", body = PaymentMethodResponse),
(status = 400, description = "Invalid Data"),
),
tag = "Payment Methods",
operation_id = "Create Payment Method Intent",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn create_payment_method_intent_api() {}
/// Payment Method - Confirm Intent
///
/// Update a payment method with customer's payment method related information.
#[utoipa::path(
post,
path = "/v2/payment-methods/{id}/confirm-intent",
request_body(
content = PaymentMethodIntentConfirm,
// TODO: Add examples
),
responses(
(status = 200, description = "Payment Method Intent Confirmed", body = PaymentMethodResponse),
(status = 400, description = "Invalid Data"),
),
tag = "Payment Methods",
operation_id = "Confirm Payment Method Intent",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn confirm_payment_method_intent_api() {}
/// Payment Method - Create
///
/// Creates and stores a payment method against a customer. In case of cards, this API should be used only by PCI compliant merchants.
#[utoipa::path(
post,
path = "/v2/payment-methods",
request_body(
content = PaymentMethodCreate,
// TODO: Add examples
),
responses(
(status = 200, description = "Payment Method Created", body = PaymentMethodResponse),
(status = 400, description = "Invalid Data"),
),
tag = "Payment Methods",
operation_id = "Create Payment Method",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn create_payment_method_api() {}
/// Payment Method - Retrieve
///
/// Retrieves a payment method of a customer.
#[utoipa::path(
get,
path = "/v2/payment-methods/{id}",
params (
("id" = String, Path, description = "The unique identifier for the Payment Method"),
),
responses(
(status = 200, description = "Payment Method Retrieved", body = PaymentMethodResponse),
(status = 404, description = "Payment Method Not Found"),
),
tag = "Payment Methods",
operation_id = "Retrieve Payment Method",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn payment_method_retrieve_api() {}
/// Payment Method - Update
///
/// Update an existing payment method of a customer.
#[utoipa::path(
patch,
path = "/v2/payment-methods/{id}/update-saved-payment-method",
request_body(
content = PaymentMethodUpdate,
// TODO: Add examples
),
responses(
(status = 200, description = "Payment Method Update", body = PaymentMethodResponse),
(status = 400, description = "Invalid Data"),
),
tag = "Payment Methods",
operation_id = "Update Payment Method",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn payment_method_update_api() {}
/// Payment Method - Delete
///
/// Deletes a payment method of a customer.
#[utoipa::path(
delete,
path = "/v2/payment-methods/{id}",
params (
("id" = String, Path, description = "The unique identifier for the Payment Method"),
),
responses(
(status = 200, description = "Payment Method Retrieved", body = PaymentMethodDeleteResponse),
(status = 404, description = "Payment Method Not Found"),
),
tag = "Payment Methods",
operation_id = "Delete Payment Method",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn payment_method_delete_api() {}
/// List customer saved payment methods for a payment
///
/// 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/{id}/saved-payment-methods",
request_body(
content = PaymentMethodListRequest,
// TODO: Add examples and add param for customer_id
),
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" = []))
)]
#[cfg(feature = "v2")]
pub async fn list_customer_payment_method_for_payment() {}
/// List saved payment methods for a Customer
///
/// 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/{id}/saved-payment-methods",
request_body(
content = PaymentMethodListRequest,
// TODO: Add examples and add param for customer_id
),
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" = []))
)]
#[cfg(feature = "v2")]
pub async fn list_customer_payment_method_api() {}

View File

@ -210,7 +210,7 @@ pub async fn profile_update() {}
/// Activates a routing algorithm under a profile
#[utoipa::path(
patch,
path = "/v2/profiles/{id}/activate_routing_algorithm",
path = "/v2/profiles/{id}/activate-routing-algorithm",
request_body ( content = RoutingAlgorithmId,
examples( (
"Activate a routing algorithm" = (
@ -240,7 +240,7 @@ pub async fn routing_link_config() {}
/// Deactivates a routing algorithm under a profile
#[utoipa::path(
patch,
path = "/v2/profiles/{id}/deactivate_routing_algorithm",
path = "/v2/profiles/{id}/deactivate-routing-algorithm",
params(
("id" = String, Path, description = "The unique identifier for the profile"),
),
@ -263,7 +263,7 @@ pub async fn routing_unlink_config() {}
/// Update the default fallback routing algorithm for the profile
#[utoipa::path(
patch,
path = "/v2/profiles/{id}/fallback_routing",
path = "/v2/profiles/{id}/fallback-routing",
request_body = Vec<RoutableConnectorChoice>,
params(
("id" = String, Path, description = "The unique identifier for the profile"),
@ -307,11 +307,11 @@ pub async fn profile_retrieve() {}
#[cfg(feature = "v2")]
/// Profile - Retrieve Active Routing Algorithm
///
///_
/// Retrieve active routing algorithm under the profile
#[utoipa::path(
get,
path = "/v2/profiles/{id}/routing_algorithm",
path = "/v2/profiles/{id}/routing-algorithm",
params(
("id" = String, Path, description = "The unique identifier for the profile"),
("limit" = Option<u16>, Query, description = "The number of records of the algorithms to be returned"),
@ -334,7 +334,7 @@ pub async fn routing_retrieve_linked_config() {}
/// Retrieve the default fallback routing algorithm for the profile
#[utoipa::path(
get,
path = "/v2/profiles/{id}/fallback_routing",
path = "/v2/profiles/{id}/fallback-routing",
params(
("id" = String, Path, description = "The unique identifier for the profile"),
),
@ -353,7 +353,7 @@ pub async fn routing_retrieve_default_config() {}
/// List Connector Accounts for the profile
#[utoipa::path(
get,
path = "/v2/profiles/{id}/connector_accounts",
path = "/v2/profiles/{id}/connector-accounts",
params(
("id" = String, Path, description = "The unique identifier for the business profile"),
(

View File

@ -26,7 +26,7 @@ pub async fn routing_create_config() {}
/// Create a routing algorithm
#[utoipa::path(
post,
path = "/v2/routing_algorithm",
path = "/v2/routing-algorithm",
request_body = RoutingConfigRequest,
responses(
(status = 200, description = "Routing Algorithm created", body = RoutingDictionaryRecord),
@ -94,7 +94,7 @@ pub async fn routing_retrieve_config() {}
#[utoipa::path(
get,
path = "/v2/routing_algorithm/{id}",
path = "/v2/routing-algorithm/{id}",
params(
("id" = String, Path, description = "The unique identifier for a routing algorithm"),
),