Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: added all contact us route #281

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

Ajinx1
Copy link
Contributor

@Ajinx1 Ajinx1 commented Aug 6, 2024

Description

This pull request introduces five new endpoints to manage contact us messages records. The functionality for each is detailed below:

  1. Get All Contacts: Implements the endpoint to retrieve a list of all messages with proper validation and authentication.
  2. Get Contact by ID: Implements the endpoint to retrieve a contact message record by its ID with proper validation and authentication.
  3. Get Contact by Email: Implements the endpoint to retrieve a contact message record by its email with proper validation and authentication.
  4. Delete Contact by ID: Implements the endpoint to delete a contact message record by its ID with proper validation and authentication.
  5. Create Contact: Implements the endpoint to create a new contact message record with proper validation and authentication.

Each endpoint ensures that requests are authenticated and validated properly, and they handle various error scenarios gracefully.

Key features of this implementation:

  • Get All Contacts:

    • Endpoint: GET /api/v1/contact?page=1&limit=10
    • Retrieves a list of all contact records with validation and authentication.
    • Handles unauthorized access and other errors.
  • Get Contact by ID:

    • Endpoint: GET /api/v1/contact/id/:id
    • Retrieves a contact record by its ID with validation and authentication.
    • Handles validation errors, unauthorized access, and other errors.
  • Get Contact by Email:

    • Endpoint: GET /api/v1/contact/email/:email
    • Retrieves a contact record by its email with validation and authentication.
    • Handles validation errors, unauthorized access, and other errors.
  • Delete Contact by ID:

    • Endpoint: DELETE /api/v1/contact/:id
    • Deletes a contact record by its ID with validation and authentication.
    • Handles validation errors, unauthorized access, and other errors.
  • Create Contact:

    • Endpoint: POST /api/v1/contact
    • Creates a new contact record with validation and authentication.
    • Handles validation errors, unauthorized access, and other errors.

API DOC HERE

Related Issues

This pull request addresses the following issues:

How Has This Been Tested?

The changes have been tested using the following methods:

  • Integration Tests:

    • Added tests to cover the retrieval of all contacts, contact by ID, and contact by email, as well as deleting and creating contact records.
    • Validated successful retrieval, creation, and deletion, handling of errors, and authentication scenarios.
  • Test Scenarios:

    • Successful retrieval of all contact records.
    • Successful retrieval of a contact record by ID and email.
    • Successful creation of a new contact record.
    • Successful deletion of a contact record by ID.
    • Handling of validation errors and unauthorized access for all endpoints.
    • Handling of missing fields and invalid data for the creation endpoint.

Screenshots (if appropriate - Postman, etc):

image image image image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Cyberguru1 Cyberguru1 self-requested a review August 6, 2024 14:53
Copy link
Contributor

@Cyberguru1 Cyberguru1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
nice job man

@Cyberguru1 Cyberguru1 merged commit aad3bfa into hngprojects:dev Aug 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants