hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 141 forks source link

[FEAT] Contact Us API Endpoint #26

Open Xaldovah opened 1 month ago

Xaldovah commented 1 month ago

Description

Create an API endpoint to handle user inquiries from the "Contact Us" form. This endpoint will validate the input data and send the inquiry to a specified email address.

Acceptance Criteria

  1. API Endpoint Implementation:

    • The endpoint should be accessible at /api/v1/contact.
    • The endpoint should accept HTTP POST requests.
      1. Data Validation and Sanitization:
    • The API should validate the request payload to ensure all required fields (name, email, message) are present and valid.
  2. Email Sending:

    • The API should send the user's inquiry to a specified email address.
  3. Response:

    • On success, the API should return a 200 OK status code with a success message.
    • On failure, the API should return a 400 Bad Request status code with appropriate error messages.

Request Example: POST /api/v1/contact

{
  "name": "string",
  "email": "string",
  "message": "string"
}

Successful Response:

{
  "message": "string",
  "status": int
}

Error Response:

{
  "message": "string",
  "errors": [
    "string",
  ],
  "status": int
}

Purpose

Provides a backend service to handle user inquiries from the "Contact Us" form, ensuring data is validated and inquiries are sent to the appropriate email address.

Requirements

Expected Outcome

API endpoint allows users to submit inquiries via the "Contact Us" form, and ensures the inquiries are sent to the appropriate email address. status code

Testing

Xaldovah commented 1 month ago

This ticket issue has already been approved in the main repo.