hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
155 stars 136 forks source link

[FEAT] Update Customer Details API #89

Open SCCSMARTCODE opened 3 months ago

SCCSMARTCODE commented 3 months ago

Description

Create an API endpoint to update customer details. This endpoint will allow administrators to update customer information from the Customer Details Page efficiently and securely.


Acceptance Criteria

  1. Endpoint Definition:

    • API endpoint to update customer details.
  2. Functionality:

    • Admin can update customer details successfully.
    • Ensure only authorized users (admins) can update customer details.
  3. Implementation Steps:

    • Define API Endpoint:
      • Define the API endpoint to update customer details.
    • Implement Logic:
      • Implement the logic to update customer information in the database.
    • Handle Responses:
      • Handle success and error responses, including invalid customer ID and unauthorized access.
    • Write Tests:
      • Write tests for the endpoint to ensure proper functionality.

Purpose

The purpose of this endpoint is to provide administrators with a secure and efficient way to update customer details. This will enhance the system's ability to maintain accurate and up-to-date customer information.


Requirements


Expected Outcome


Example API Endpoint:

Request Example:

{
  "firstName": "John",
  "lastName": "Doe",
  "email": "john.doe@example.com",
  "phone": "+1234567890",
  "address": "123 Main St, Anytown, USA"
}

Successful Response Example:

{
  "status": "success",
  "status_code": 200,
  "message": "Customer details updated successfully.",
  "customer": {
    "id": "customerId",
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "phone": "+1234567890",
    "address": "123 Main St, Anytown, USA"
  }
}

Error Response Examples:

  1. Invalid Customer ID:

    {
     "status": "error",
     "message": "Invalid customer ID.",
     "status_code": 400
    }
  2. Unauthorized Access:

    {
     "status": "error",
     "message": "Unauthorized access.",
     "status_code": 401
    }

Unit Testing

SCCSMARTCODE commented 3 months ago

Slack ID: SCCSMARTCODE