# Tasks

## List all tasks

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/tasks`

This endpoint allows you to get the list of your tasks. \
The tasks are returned sorted by creation date.

#### Query Parameters

| Name      | Type    | Description                                                                      |
| --------- | ------- | -------------------------------------------------------------------------------- |
| page      | integer | The number of the page you wish to see. Default is 1.                            |
| per\_page | integer | The number of the desired result per page. Default is 20. Maximum values is 100. |

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Accept         | string | Should be `application/json`. |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": [
        {
            "id": 381,
            "projet_id": 70,
            "active": 1,
            "creation_date": "2020-06-01",
            "title": "Simoan Provencher",
            "start_date": "0000-00-00",
            "end_date": "0000-00-00",
            "status": 2,
            "time_estimated": "0.00",
            "time_spent": "1.00",
            "description": null,
            "comments": []
        },
        {
            "id": 380,
            "projet_id": 0,
            "active": 1,
            "creation_date": "2020-06-01",
            "title": "BOOKING - ",
            "start_date": "0000-00-00",
            "end_date": "0000-00-00",
            "status": 2,
            "time_estimated": "1.00",
            "time_spent": "0.00",
            "description": "",
            "comments": []
        }
    ],
    "meta": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 25,
        "total": 2
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Retrieve a task

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/tasks/:id`

This endpoint allows you to get the details of the task.

#### Path Parameters

| Name | Type    | Description                     |
| ---- | ------- | ------------------------------- |
| id   | integer | The ID of the task to retrieve. |

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Accept         | string | Should be `application/json`. |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": {
        "id": 70,
        "projet_id": 18,
        "active": 1,
        "creation_date": "0000-00-00",
        "title": "a1 - ",
        "start_date": "2019-10-02",
        "end_date": "2019-10-02",
        "status": 2,
        "time_estimated": "1.00",
        "time_spent": "9.00",
        "description": "",
        "comments": [
            {
                "id": 1,
                "tache_id": 70,
                "user_id": 205,
                "date": "2020-08-19",
                "comment": ""
            }
        ]
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a task

<mark style="color:green;">`POST`</mark> `https://app.gem-books.com/api/tasks`

This endpoint allows you to create a task. \
Returns the created task.

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Content-Type   | string | Should be `application/json`. |
| Accept         | string | Should be `application/json`. |

#### Request Body

| Name        | Type    | Description    |
| ----------- | ------- | -------------- |
| project\_id | integer | ID of project. |
| name        | string  | Task name.     |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": {
        "id": 70,
        "projet_id": 18,
        "active": 1,
        "creation_date": "0000-00-00",
        "title": "a1 - ",
        "start_date": "2019-10-02",
        "end_date": "2019-10-02",
        "status": 2,
        "time_estimated": "1.00",
        "time_spent": "9.00",
        "description": "",
        "comments": [
            {
                "id": 1,
                "tache_id": 70,
                "user_id": 205,
                "date": "2020-08-19",
                "comment": ""
            }
        ]
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

```
{
    "project_id" : 18,
    "name": "Test Project"
}
```

## Update a task

<mark style="color:orange;">`PUT`</mark> `https://app.gem-books.com/api/tasks/:id`

This endpoint allows you to update a specific task. \
Returns the updated task.

#### Path Parameters

| Name | Type    | Description       |
| ---- | ------- | ----------------- |
| id   | integer | Task id to update |

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Content-Type   | string | Should be `application/json`. |
| Accept         | string | Should be `application/json`. |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": {
        "id": 70,
        "projet_id": 18,
        "active": 1,
        "creation_date": "0000-00-00",
        "title": "a1 - ",
        "start_date": "2019-10-02",
        "end_date": "2019-10-02",
        "status": 2,
        "time_estimated": "1.00",
        "time_spent": "9.00",
        "description": "",
        "comments": [
            {
                "id": 1,
                "tache_id": 70,
                "user_id": 205,
                "date": "2020-08-19",
                "comment": ""
            }
        ]
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

```
{
    "name": "Test Project"
}
```
