From c5f8f8e8b86b1841659d566a4f9cb3dbc6cef1c0 Mon Sep 17 00:00:00 2001 From: tanishqsingla Date: Sat, 4 Mar 2023 18:45:39 +0530 Subject: [PATCH 1/3] feat: Add api contract for task request --- taskRequest/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 taskRequest/README.md diff --git a/taskRequest/README.md b/taskRequest/README.md new file mode 100644 index 0000000..0898f71 --- /dev/null +++ b/taskRequest/README.md @@ -0,0 +1,42 @@ +# Task Request + +## Task Request Object + +``` + +``` + +## **Requests** + +| Route | Description | +| :-------------------------------------------: | :---------------: | +| [GET /taskRequests](#get-taskRequests) | Returns all tasks | + +## **GET /taskRequests** + +Returns all tasks to super user. + +- **Params** + None +- **Query** + None +- **Body** + None +- **Headers** + None +- **Cookie** + rds-session: `` +- Success Response + - Code: 200 + Content: + ``` + { + message: "Task requests returned successfully", + taskRequests: [ + {} + ], + } + ``` +- Error Response + - Code: 401 + Content: `{'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthorized User' }` From b72ac4a11cdaffd55b6ab174c32b65c5ad8680b2 Mon Sep 17 00:00:00 2001 From: tanishqsingla Date: Sat, 4 Mar 2023 19:59:11 +0530 Subject: [PATCH 2/3] feat: Add patch and put api contracts for task request --- taskRequest/README.md | 97 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 19 deletions(-) diff --git a/taskRequest/README.md b/taskRequest/README.md index 0898f71..e88c0a5 100644 --- a/taskRequest/README.md +++ b/taskRequest/README.md @@ -3,40 +3,99 @@ ## Task Request Object ``` - +// TBD ``` ## **Requests** -| Route | Description | -| :-------------------------------------------: | :---------------: | -| [GET /taskRequests](#get-taskRequests) | Returns all tasks | +| Route | Description | +| :-------------------------------------------: | :---------------------------: | +| [GET /taskRequests](#get-taskRequests) | Returns all task Reqeusts | +| [PUT /taskRequest](#put-taskRequest) | Creates a task Request | +| [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** +- **Params** None -- **Query** +- **Query** None -- **Body** +- **Body** None -- **Headers** +- **Headers** None -- **Cookie** +- **Cookie** rds-session: `` - Success Response - Code: 200 - Content: - ``` - { - message: "Task requests returned successfully", - taskRequests: [ - {} - ], - } - ``` + Content: + ``` + { + message: "Task requests returned successfully", + taskRequests: [ + {} + ], + } + ``` +- Error Response + - Code: 401 + Content: `{'statusCode': 401, 'error': 'Unauthorized User' }` + - Code: 403 + Content: `{'statusCode: 403, 'error': 'Unauthorized access: user is not super user'}` + - Code: 500 + Content: `{'statusCode: 500, 'error': 'Internal Server Error'}` + +## **PUT /taskRequest** + +Creates a task request. + +- **Params** + None +- **Query** + None +- **Headers** + `Content-Type: 'application/json'` +- **Body** + `{}` +- **Cookie** + rds-session: `` +- Success Response + - Code: 201 + Content: + ``` + { + message: "Task request created successfully", + taskRequest: {} + } + ``` +- Error Response + - Code: 401 + Content: `{statusCode: 500, 'error': "Unauthorized User"}` + - Code: 403 + Content: `{'statusCode: 403, 'error': 'Unauthorized access: user is not super user'}` + - Code: 500 + Content: `{statusCode: 500, 'error': "Internal server error"}` + +## **PATCH /taskRequest/:id** + +Changes status of task request + +- **Params** + Task Request id +- **Query** + None +- **Headers** + `Content-Type: 'application/json'` +- **Body** + `{, approvedTo: userId}` +- **Success** + - Code: 204 + Content: `` - Error Response - Code: 401 - Content: `{'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthorized User' }` + Content: `{statusCode: 500, 'error': "Unauthorized User"}` + - Code: 403 + Content: `{'statusCode: 403, 'error': 'Unauthorized access: user is not super user'}` From ae54420092d8a4bf4f269e24aff2553173eca308 Mon Sep 17 00:00:00 2001 From: tanishqsingla Date: Wed, 29 Mar 2023 15:24:27 +0530 Subject: [PATCH 3/3] refactor(task request): Update task request api contract --- taskRequest/README.md | 110 +++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 24 deletions(-) diff --git a/taskRequest/README.md b/taskRequest/README.md index e88c0a5..17010da 100644 --- a/taskRequest/README.md +++ b/taskRequest/README.md @@ -8,12 +8,12 @@ ## **Requests** -| Route | Description | -| :-------------------------------------------: | :---------------------------: | -| [GET /taskRequests](#get-taskRequests) | Returns all task Reqeusts | -| [PUT /taskRequest](#put-taskRequest) | Creates a task Request | -| [PATCH /taskRequest](#patch-taskRequests) | Approves task request to user | -| [DELETE /taskRequest/:id](#delete-taskRequst) | Delete task request | +| 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** @@ -32,7 +32,7 @@ Returns all tasks to super user. - Success Response - Code: 200 Content: - ``` + ```js { message: "Task requests returned successfully", taskRequests: [ @@ -43,12 +43,10 @@ Returns all tasks to super user. - Error Response - Code: 401 Content: `{'statusCode': 401, 'error': 'Unauthorized User' }` - - Code: 403 - Content: `{'statusCode: 403, 'error': 'Unauthorized access: user is not super user'}` - Code: 500 Content: `{'statusCode: 500, 'error': 'Internal Server Error'}` -## **PUT /taskRequest** +## **POST /addOrUpdate** Creates a task request. @@ -59,27 +57,66 @@ Creates a task request. - **Headers** `Content-Type: 'application/json'` - **Body** - `{}` + `{taskId, userId}` - **Cookie** rds-session: `` - Success Response - - Code: 201 + - Code: 201 Content: + ```js + { + message: "Task request successfully created", + taskRequest: {} + } ``` + - Code: 200 + Content: + ```js { - message: "Task request created successfully", - taskRequest: {} + message: "Task request updated successfully", + 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: 403 - Content: `{'statusCode: 403, 'error': 'Unauthorized access: user is not super 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/:id** +## PATCH /taskRequest/approve Changes status of task request @@ -90,12 +127,37 @@ Changes status of task request - **Headers** `Content-Type: 'application/json'` - **Body** - `{, approvedTo: userId}` + `{taskRequestId, userId}` - **Success** - - Code: 204 - Content: `` -- Error Response + - Code: 200 + Content: `{'message': 'Task successfully assigned to user ', 'taskRequest': }` +- **Error Response** + - Code: 400 + Content: `{'statusCode': 401, 'message': 'Invalid request body'}` - Code: 401 - Content: `{statusCode: 500, 'error': "Unauthorized User"}` - - Code: 403 - Content: `{'statusCode: 403, 'error': 'Unauthorized access: user is not super user'}` + 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" + } + ```