docs: add openapi docs for customers v2 (#5926)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2024-09-18 12:24:55 +05:30
committed by GitHub
parent 0a0c93e102
commit 2bc8756e06
3 changed files with 339 additions and 0 deletions

View File

@ -109,6 +109,13 @@ Never share your secret api keys. Keep them guarded and secure.
routes::api_keys::api_key_retrieve,
routes::api_keys::api_key_update,
routes::api_keys::api_key_revoke,
//Routes for customers
routes::customers::customers_create,
routes::customers::customers_retrieve,
routes::customers::customers_update,
routes::customers::customers_delete,
routes::customers::customers_list,
),
components(schemas(
common_utils::types::MinorUnit,

View File

@ -23,6 +23,7 @@
operation_id = "Create a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_create() {}
/// Customers - Retrieve
@ -40,6 +41,7 @@ pub async fn customers_create() {}
operation_id = "Retrieve a Customer",
security(("api_key" = []), ("ephemeral_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_retrieve() {}
/// Customers - Update
@ -66,6 +68,7 @@ pub async fn customers_retrieve() {}
operation_id = "Update a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_update() {}
/// Customers - Delete
@ -83,6 +86,7 @@ pub async fn customers_update() {}
operation_id = "Delete a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_delete() {}
/// Customers - List
@ -99,4 +103,111 @@ pub async fn customers_delete() {}
operation_id = "List all Customers for a Merchant",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_list() {}
/// Creates a customer object and stores the customer details to be reused for future payments.
/// Incase the customer already exists in the system, this API will respond with the customer details.
#[utoipa::path(
post,
path = "/v2/customers",
request_body (
content = CustomerRequest,
examples (( "Create a customer with name and email" =(
value =json!( {
"email": "guest@example.com",
"name": "John Doe"
})
)))
),
responses(
(status = 200, description = "Customer Created", body = CustomerResponse),
(status = 400, description = "Invalid data")
),
tag = "Customers",
operation_id = "Create a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_create() {}
/// Customers - Retrieve
///
/// Retrieves a customer's details.
#[utoipa::path(
get,
path = "/v2/customers/{id}",
params (("id" = String, Path, description = "The unique identifier for the Customer")),
responses(
(status = 200, description = "Customer Retrieved", body = CustomerResponse),
(status = 404, description = "Customer was not found")
),
tag = "Customers",
operation_id = "Retrieve a Customer",
security(("api_key" = []), ("ephemeral_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_retrieve() {}
/// Customers - Update
///
/// Updates the customer's details in a customer object.
#[utoipa::path(
post,
path = "/v2/customers/{id}",
request_body (
content = CustomerRequest,
examples (( "Update name and email of a customer" =(
value =json!( {
"email": "guest@example.com",
"name": "John Doe"
})
)))
),
params (("id" = String, Path, description = "The unique identifier for the Customer")),
responses(
(status = 200, description = "Customer was Updated", body = CustomerResponse),
(status = 404, description = "Customer was not found")
),
tag = "Customers",
operation_id = "Update a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_update() {}
/// Customers - Delete
///
/// Delete a customer record.
#[utoipa::path(
delete,
path = "/v2/customers/{id}",
params (("id" = String, Path, description = "The unique identifier for the Customer")),
responses(
(status = 200, description = "Customer was Deleted", body = CustomerDeleteResponse),
(status = 404, description = "Customer was not found")
),
tag = "Customers",
operation_id = "Delete a Customer",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_delete() {}
/// Customers - List
///
/// Lists all the customers for a particular merchant id.
#[utoipa::path(
post,
path = "/v2/customers/list",
responses(
(status = 200, description = "Customers retrieved", body = Vec<CustomerResponse>),
(status = 400, description = "Invalid Data"),
),
tag = "Customers",
operation_id = "List all Customers for a Merchant",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_list() {}