Skip to content

task_api

sandeshkhadka edited this page Jun 21, 2024 · 2 revisions

Creating a Task

POST /api/create/task HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Authorization: Bearer <JWT_TOKEN>
{
    "name": "<TASK_NAME>",
    "assignToId": "<USER_ID>"

}

Success Response:

{
    "task": {
        "id": "<TASK_ID>",
        "name": "<TASK_NAME>",
        "belongsToId": "<USER_ID>",
        "schedule": "<TIMESTAMP>",
        "status": "Pending|Completed|Missing"
    }
}

Failure Response:

{
    "message": "Could not create Task"
}

Deleting a Task

DELETE /task/<TASK_ID> HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Authorization: Bearer <JWT_TOKEN>

Success response:

{
    "deletedTask": {
        "id": "<TASK_ID>",
        "name": "<TASK_NAME>",
        "schedule": "<TIMESTAMP>",
        "belongsToId": "<USER_ID>",
        "status": "Pending|Missed|Completed"
    }
}

Failure response:

{
    "message": "Could not delete task"
}

Fetching task

POST /api/task/ HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Authorization: Bearer <JWT_TOKEN>
{
   "page": 1

}

Success response:

{
    "tasks": [{
        "id": "<TASK_ID>",
        "name": "<TASK_NAME>",
        "belongsToId": "<USER_ID>",
        "schedule": "<TIMESTAMP>",
        "status": "Pending|Completed|Missing"
    }]
}

Failure response

{
    "message": "Task not found"
}
{
    "message": "already approved"
}
Clone this wiki locally