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]: Admin - User Details: Implement API Endpoint for user detail for admin #140

Open
3 tasks
dmendie opened this issue Jul 27, 2024 · 0 comments
Open
3 tasks
Assignees

Comments

@dmendie
Copy link
Contributor

dmendie commented Jul 27, 2024

Description

Create an API endpoint to retrieve the details of a registered user's information for the admin user. This endpoint will be part of the administration user management. Admin users can see in-depth information about a user using this endpoint

Acceptance Criteria

  • The endpoint should be accessible at GET /api/v1/admin/users/{id}.
  • The endpoint should accept HTTP GET requests.
  • The endpoint should retrieve up-to-date information about a registered user from the database using the provided user's ID.
  • The endpoint should return a 200 OK status code with the user's details in the response body
  • This endpoint should be secured and only accessible to an admin user

GET /api/v1/admin/users/3454
Response:
On a successful retrieval of the user details, the API should return a 200 OK status code. The response body should contain the user details:

{
  "status": "success",
  "status_code": 200
  "data": {
    "id": 3454,
    "first_name": "string",
    "last_name": "string",
    "email": "string",
    "avatar_url": "string
    "phone_number': 'string",
    "status': 'active",
    "created_at": "2023-01-01T12:00:00Z",
    "updated_at": "2023-06-01T12:00:00Z"
  }
}

Validation:

If the user's ID is missing or invalid, the API should return a 400 Bad Request status code with appropriate validation error messages:

{
  "status": "unsuccessful",
 "status_code": 400,
  "message": "Valid user ID must be provided"
}

If the user does not exist, the API should return a 404 Not Found status code with an appropriate message:

{
  "status": "unsuccessful",
 "status_code": 404,
  "message": "user not found"
}

Purpose

To provide admin users with in-depth information about a registered user

Requirements

  • Develop server-side logic to retrieve user's details by ID.
  • Securely handle the retrieval process and comply with security standards.
  • Ensure the user's ID is validated and handled correctly.

Expected Outcome

API endpoint allows admin users to retrieve user details by ID with appropriate validation and security measures.

Tasks:

  • Define the GET /api/v1/admin/users/{id} route in the server-side application.
  • Validate that the user's ID is provided and is in a valid format.
  • Implement logic to retrieve the user details from the database using the provided ID.
  • Return the user details in the response body if the ID is valid and the user exists.
  • Handle cases where the user's ID is invalid or the user does not exist, providing appropriate error messages.

Testing

  • Write unit tests to validate input validation and user retrieval logic.
  • Write integration tests to ensure end-to-end functionality.
  • Perform security testing to ensure data protection and compliance.
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

No branches or pull requests

1 participant