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]: Endpoint to Deactivate User Account #409

Open
ZainabAlayande opened this issue Aug 8, 2024 · 0 comments
Open

[FEAT]: Endpoint to Deactivate User Account #409

ZainabAlayande opened this issue Aug 8, 2024 · 0 comments

Comments

@ZainabAlayande
Copy link
Collaborator

Description

Develop an API endpoint that deactivates a user account. The endpoint should handle the deactivation process by marking the user's account as inactive or canceled, based on the provided reason.

Acceptance Criteria

  • The endpoint should be accessible via api/v1/users/deactivate and accept HTTP PATCH requests.
  • The request payload should include a confirmation field (boolean) and a reason field (string).
  • If confirmation is true, the account should be deactivated, and the reason should be recorded.
  • The API should validate the request and return appropriate responses based on the operation's success or failure.

Endpoint

URL

1. DEACTIVATE USER ACCOUNT

api/v1/users/deactivate

METHOD

PATCH

Request Body

{
  "confirmation": true,
  "reason": "No longer needed"
}

RESPONSE

Success Response (json)

{
  "status": "success",
  "message": "The account has been successfully deactivated.",
  "data": {}
}

Error Response (json)

{
  "status": "400",
  "message": "Bad Request. The confirmation field is required.",
  "data": {}
}
{
  "status": "error",
  "message": "Unauthorized. You do not have the necessary permissions.",
  "data": {}
}

TASK

  • Implement the PATCH endpoint to handle user account deactivation.
  • Validate the input to ensure that confirmation is true and a reason is provided.
  • Integrate with the database to update the user status based on the deactivation request.
  • Ensure proper error handling and response codes for different scenarios (success, bad request, unauthorized).
  • Write unit tests to cover all possible cases, including successful deactivation, invalid request, and unauthorized access.
  • Write end-to-end tests to verify the entire deactivation process.

Expected Outcome

  • A functional API endpoint that can deactivate a user account based on the provided request payload.
  • The system should handle various scenarios, including success, bad request, and unauthorized access, with appropriate responses.
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