Danmwihoti / Bitcoin-focused-DeFi-app-on-ZetaChain

Other
1 stars 0 forks source link

MUB-016 Manage Team API #1

Open Danmwihoti opened 3 months ago

Danmwihoti commented 3 months ago

Description

Create API endpoints for managing teams (rename, delete, archive, activate, deactivate).

Acceptance Criteria

Allow admins to manage teams through various actions. Provide API endpoints for managing teams.

Tasks

Define API endpoints and request schemas for:

  1. Renaming teams
  2. Deleting teams
  3. Archiving teams
  4. Activating teams
  5. Deactivating teams

Implement logic to perform these management actions. Handle success and error responses for each action. Write tests for each endpoint.

1. Rename Team

Endpoints

/api/v1/teams/{teamId}/rename

Renames the team with the specified ID.

Request Body

{ "newName": "string" }

Responses

Successful

Status code: 200

{ 
"message": "Team renamed successfully.",
 "teamId": 123, "newName": 
"New Team Name"
 }

Error Response

Status code: 400

{
"error": "Bad Request", 
"message": "Invalid name provided."
}

Status code: 404

{
"error": "Not Found",
 "message": "Team not found."
}

2. Deleting teams

Endpoints

[DELETE] /api/v1/teams/{teamId} Delete the team with the specified ID.

Responses

Successful

Status code: 204 Deleted successfully

Error Response

Status code: 403

{
"error": "Forbidden", 
"message": "You do not have permission to delete this team."
}

Status code: 404

{
"error": "Not Found",
 "message": "Team not found."
}

3. Archive Team

Endpoints

[PATCH] /api/v1/teams/{teamId}/archive It Archives the team with the specified ID.

Responses

Successful

Status code: 200

{ 
"message": "Team archived successfully.",
 "teamId": 123

 }

Error Response

Status code: 403

{
"error": "Forbidden", 
"message": "You do not have permission to archive this team."
}

Status code: 404

{
"error": "Not Found",
 "message": "Team not found."
}

4. Activate team

Endpoints

[PATCH] /api/v1/teams/{teamId}/activate Activates the team with the specified ID.

Responses

Successful

Status code: 200

{ 
"message": "Team activated successfully.",
 "teamId": 123
 }

Error Response

Status code: 403

{
"error": "Forbidden", 
"message": "You do not have permission to archive this team."
}

Status code: 404

{
"error": "Not Found",
 "message": "Team not found."
}

5. Deactivate Team

Endpoints

[PATCH] /api/v1/teams/{teamId}/deactivate

Deactivate the team with the specified ID.

Responses

Successful

Status code: 200

{ 
"message": "Team deactivated successfully.",
 "teamId": 123
 }

Error Response

Status code: 403

{
"error": "Forbidden", 
"message": "You do not have permission to archive this team."
}

Status code: 404

{
"error": "Not Found",
 "message": "Team not found."
}

Secure Endpoints

Authentication & Authorization:

Danmwihoti commented 3 months ago

@mwihoti