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

API contract for GET tasks/paginated #82

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
42 changes: 24 additions & 18 deletions tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@

## **Requests**

| Route | Description |
| :--------------------------------: | :---------------: |
| [GET /tasks](#get-tasks) | Returns all tasks |
| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user |
| [POST /tasks](#post-tasks) | Creates new task |
| [PATCH /tasks/:id](#patch-tasksid) | Updates tasks |
| [GET /tasks/:username](#get-tasksusername) | Returns all tasks of the user |
| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task |
| Route | Description |
| :-----------------------------------------: | :---------------------------: |
| [GET /tasks](#get-tasks) | Returns all tasks |
| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user |
| [POST /tasks](#post-tasks) | Creates new task |
| [PATCH /tasks/:id](#patch-tasksid) | Updates tasks |
| [GET /tasks/:username](#get-tasksusername) | Returns all tasks of the user |
| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task |

## **GET /tasks**

Returns all the tasks
Returns all the tasks or Returns all the tasks which are created after the `<task_object>` whose "id" would be passed in the query `after`. The no. of returned documents is controlled by `limit`again from the query which will also have a default.

- **Params**
None
- **Query**
None
_Required:_ limit=[number], after=[string(task id)] `(Only required for pagination)`
- **Body**
None
- **Headers**
Expand All @@ -67,19 +67,22 @@ Returns all the tasks

```
{
message: 'Tasks returned successfully!'
message: 'Queried Tasks returned successfully!',
tasks: [
{<task_object>},
{<task_object>}
]
],
meta: {
total : {<task_object>}[] length,
till : <task_object_id>
},
}
```

- **Error Response:**
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`


## **GET /tasks/self**

Returns all the completed tasks of user if query `completed=true` is passed, else returns all the active and blocked tasks of the user.
Expand All @@ -97,6 +100,7 @@ Returns all the completed tasks of user if query `completed=true` is passed, els
- **Success Response:**
- **Code:** 200
- **Content:**

```
[
{<task_object>},
Expand Down Expand Up @@ -130,6 +134,7 @@ Returns all tasks of the requested user.
- **Success Response:**
- **Code:** 200
- **Content:**

```
{
message: 'Tasks returned successfully!'
Expand All @@ -146,7 +151,6 @@ Returns all tasks of the requested user.
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`


## **POST /tasks**

- **Params**
Expand Down Expand Up @@ -199,10 +203,11 @@ Returns all tasks of the requested user.
- **Headers**
Content-Type: application/json

- **Body**
- **Body**

```
{
status: <new-status>
{
status: <new-status>
percentCompleted: <number>
}
```
Expand All @@ -211,6 +216,7 @@ Returns all tasks of the requested user.
rds-session: `<JWT>`

- **Success Response:**

- **Code**: 200
- **Content:** `{'message': 'Task updated successfully!'}`

Expand All @@ -222,4 +228,4 @@ Returns all tasks of the requested user.
- **Code:** 404
- **Content:** `{ 'statusCode': 404, 'error': 'Not Found', 'message': 'Task doesn't exist' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`