Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

13.3 KB
Raw Blame
/// Customers - Create
///
/// 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 = "/customers",
    request_body  (
        content = CustomerRequest,
        examples  (( "Update name and email of a customer" =(
        value =json!( {
            "email": "[email protected]",
            "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 = "v1")]
pub async fn customers_create() {}

/// Customers - Retrieve
///
/// Retrieves a customer's details.
#[utoipa::path(
    get,
    path = "/customers/{customer_id}",
    params (("customer_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" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_retrieve() {}

/// Customers - Update
///
/// Updates the customer's details in a customer object.
#[utoipa::path(
    post,
    path = "/customers/{customer_id}",
    request_body (
        content = CustomerUpdateRequest,
        examples  (( "Update name and email of a customer" =(
        value =json!( {
            "email": "[email protected]",
            "name": "John Doe"
        })
        )))
    ),
    params (("customer_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 = "v1")]
pub async fn customers_update() {}

/// Customers - Delete
///
/// Delete a customer record.
#[utoipa::path(
    delete,
    path = "/customers/{customer_id}",
    params (("customer_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 = "v1")]
pub async fn customers_delete() {}

/// Customers - List
///
/// Lists all the customers for a particular merchant id.
#[utoipa::path(
    get,
    path = "/customers/list",
    params (("offset" = Option<u32>, Query, description = "Offset for pagination"),
    ("limit" = Option<u16>, Query, description = "Limit for pagination")),
    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 = "v1")]
pub async fn customers_list() {}

/// Customers - Create
///
/// 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",
    params (
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    request_body  (
        content = CustomerRequest,
        examples  (( "Create a customer with name and email" =(
        value =json!( {
            "email": "[email protected]",
            "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 - Create
///
/// 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 = "/v1/customers",
    params (
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    request_body  (
        content = CustomerRequest,
        examples  (( "Create a customer with name and email" =(
        value =json!( {
            "email": "[email protected]",
            "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_v1() {}
/// 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"),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_retrieve() {}

/// Customers - Retrieve using Merchant Reference ID
///
/// Retrieves a customer's details using the merchant supplied reference ID.
#[utoipa::path(
    get,
    path = "/v2/customers/reference/{merchant_reference_id}",
    params (
        (
            "merchant_reference_id" = String,
            Path,
            description = "The merchant supplied reference identifier for the Customer"
        ),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    responses(
        (status = 200, description = "Customer Retrieved", body = CustomerResponse),
        (status = 404, description = "Customer was not found")
    ),
    tag = "Customers",
    operation_id = "Retrieve a Customer using Merchant Reference ID",
    security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_retrieve_by_merchant_reference_id() {}

/// Customers - Retrieve using Merchant Reference ID
///
/// Retrieves a customer's details using the merchant supplied reference ID.
#[utoipa::path(
    get,
    path = "/v1/customers/reference/{merchant_reference_id}",
    params (
        (
            "merchant_reference_id" = String,
            Path,
            description = "The merchant supplied reference 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 using Merchant Reference ID",
    security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn customers_retrieve_by_merchant_reference_id() {}

/// Customers - Retrieve
///
/// Retrieves a customer's details.
#[utoipa::path(
    get,
    path = "/v1/customers/{id}",
    params (
        ("id" = String, Path, description = "The unique identifier for the Customer"),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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" = []))
)]
#[cfg(feature = "v2")]
pub async fn customers_retrieve_v1() {}

/// Customers - Update
///
/// Updates the customer's details in a customer object.
#[utoipa::path(
    put,
    path = "/v2/customers/{id}",
    request_body (
        content = CustomerUpdateRequest,
        examples  (( "Update name and email of a customer" =(
        value =json!( {
            "email": "[email protected]",
            "name": "John Doe"
        })
        )))
    ),
    params (
        ("id" = String, Path, description = "The unique identifier for the Customer"),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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 - Update
///
/// Updates the customer's details in a customer object.
#[utoipa::path(
    put,
    path = "/v1/customers/{id}",
    request_body (
        content = CustomerUpdateRequest,
        examples  (( "Update name and email of a customer" =(
        value =json!( {
            "email": "[email protected]",
            "name": "John Doe"
        })
        )))
    ),
    params (
        ("id" = String, Path, description = "The unique identifier for the Customer"),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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_v1() {}

/// Customers - Delete
///
/// Delete a customer record.
#[utoipa::path(
    delete,
    path = "/v2/customers/{id}",
    params (
        ("id" = String, Path, description = "The unique identifier for the Customer"),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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 - Delete
///
/// Delete a customer record.
#[utoipa::path(
    delete,
    path = "/v1/customers/{id}",
    params (
        ("id" = String, Path, description = "The unique identifier for the Customer"),
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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_v1() {}
/// Customers - List
///
/// Lists all the customers for a particular merchant id.
#[utoipa::path(
    get,
    path = "/v2/customers/list",
    params (
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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() {}

/// Customers - List
///
/// Lists all the customers for a particular merchant id.
#[utoipa::path(
    get,
    path = "/v1/customers/list",
    params (
        (
            "X-Profile-Id" = String, Header,
            description = "Profile ID associated to the customer",
            example = "pro_abcdefghijklmnop"
        )
    ),
    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_v1() {}