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: Add api contract for task request #110

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions taskRequest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Task Request

## Task Request Object

```
// TBD
```

## **Requests**

| Route | Description |
| :-------------------------------------------: | :----------------------------------------------: |
| [GET /taskRequests](#get-taskRequests) | Returns all task Reqeusts |
| [POST /addOrUpdate](#addOrUpdate-taskRequest) | Creates a task Request or updates the requestors |
| [PATCH /taskRequest](#patch-taskRequests) | Approves task request to user |
| [DELETE /taskRequest/:id](#delete-taskRequst) | Delete task request |

## **GET /taskRequests**

Returns all tasks to super user.

- **Params**
None
- **Query**
None
- **Body**
None
- **Headers**
None
- **Cookie**
rds-session: `<JWT>`
- Success Response
- Code: 200
Content:
```js
{
message: "Task requests returned successfully",
taskRequests: [
{<task request object>}
],
}
```
- Error Response
- Code: 401
Content: `{'statusCode': 401, 'error': 'Unauthorized User' }`
- Code: 500
Content: `{'statusCode: 500, 'error': 'Internal Server Error'}`

## **POST /addOrUpdate**

Creates a task request.

- **Params**
None
- **Query**
None
- **Headers**
`Content-Type: 'application/json'`
- **Body**
`{taskId, userId}`
- **Cookie**
rds-session: `<JWT>`
- Success Response
- Code: 201
Content:
```js
{
message: "Task request successfully created",
taskRequest: {<task request object>}
}
```
- Code: 200
Content:
```js
{
message: "Task request updated successfully",
requestors: [<requestors>]
}
```
- Error Response
- Code: 400
- If taskId is not provided
Content: `{statusCode: 400, error: 'Bad Request', 'message': 'taskId is not provided'}`
- If userId is not provided
Content: `{statusCode: 400, error: 'Bad Request', 'message': 'userId is not provided'}`
- Code: 401
Content: `{statusCode: 500, 'error': "Unauthorized User"}`
- Code: 409
- If user is already a requestor
Content:
```js
{
'statusCode': 409,
'error': 'Conflict',
'message': 'User is already requesting for the task'
}
```
- If user does not exist
Content:
```js
{
'statusCode': 409,
'error': 'Conflict',
'message': 'User is already requesting for the task'
}
```
- If task doesn't exist
Content:
```js
{
'statusCode': 409,
'error': 'Conflict',
'message': "Task does not exist"
}
```
- Code: 500
Content: `{statusCode: 500, 'error': "Internal server error"}`

## PATCH /taskRequest/approve

Changes status of task request

- **Params**
Task Request id
- **Query**
None
- **Headers**
`Content-Type: 'application/json'`
- **Body**
`{taskRequestId, userId}`
- **Success**
- Code: 200
Content: `{'message': 'Task successfully assigned to user <username>', 'taskRequest': <task request object>}`
- **Error Response**
- Code: 400
Content: `{'statusCode': 401, 'message': 'Invalid request body'}`
- Code: 401
Content: `{'statusCode': 401, 'error': "Unauthorized User"}`
- Code: 409
- If user doesn't exist
```js
{
'statusCode': 409,
'error': 'Conflict',
'message': "User does not exist"
}
```
- If user is OOO
```js
{
'statusCode': 409,
'error': 'Conflict',
'message': "User is currently OOO"
}
```
- If user is active on another task
```js
{
'statusCode': 409,
'error': 'Conflict',
'message': "User is currently active on another task"
}
```