# Cell

## Method & Permission

| API         | GET                                              | POST                            | PUT | PATCH                           | DELETE |
| ----------- | ------------------------------------------------ | ------------------------------- | --- | ------------------------------- | ------ |
| Cell List   | Admin, Project Admin, Project Edit, Project View | Project Admin\*, Project Edit\* | -   | -                               | -      |
| Cell Detail | -                                                | -                               | -   | Project Admin\*, Project Edit\* | -      |

\*Cell can not be posted/modified if `row.is_locked=True`, unless the widget can be added at the read-only

\*Cell can not be posted/modified if `row.is_archived=True`

## Cell List

<mark style="color:blue;">`GET`</mark> `/tables/cell/list/{level}/{sid}/{serializer}/`

#### Path Parameters

| Name       | Type   | Description                     |
| ---------- | ------ | ------------------------------- |
| level      | string | organization                    |
| sid        | string | organization sid                |
| serializer | string | choose of \[name, list, detail] |

#### Query Parameters

| Name       | Type   | Description |
| ---------- | ------ | ----------- |
| row\_\_sid | string |             |

#### Headers

| Name  | Type   | Description              |
| ----- | ------ | ------------------------ |
| token | string | the authentication token |

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

```yaml
# serializer = name
{
    "page_size": 10,
    "page_number": 1,
    "page_count": 1,
    "count": 1,
    "next": null,
    "previous": null,
    "add_permission": true,
    "results": [
        {
            "sid": "xxx",
            "name": "date_start"
        }
    ]
}
# serializer = list
{
    "page_size": 10,
    "page_number": 1,
    "page_count": 1,
    "count": 1,
    "next": null,
    "previous": null,
    "add_permission": true,
    "results": [
        {
            "sid": "xxx",
            "widget": {
                "sid": "xxx",
                "name": "Date - Edit date value"
            },
            "row": {
                "sid": "xxx",
                "name": "EP625: Test Name 20200525133408"
            },
            "price": "$0.00",
            "change_permission": true
        }
    ]
}
# serializer = detail
{
    "page_size": 10,
    "page_number": 1,
    "page_count": 1,
    "count": 1,
    "next": null,
    "previous": null,
    "add_permission": true,
    "results": [
        {
            "sid": "xxx",
            "data": "2020-05-25",
            "row": {
                "sid": "xxx",
                "name": "EP625: Test Name 20200525133408"
            },
            "column": {
                "sid": "xxx",
                "name": "date_start"
            },
            "widget": {
                "sid": "xxx",
                "name": "Date - Edit date value"
            },
            "date_updated": "2020-05-25T20:34:39.293654Z",
            "date_created": "2020-05-25T20:34:39.292882Z",
            "change_permission": true
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Cell List

<mark style="color:green;">`POST`</mark> `/tables/cell/list/{level}/{sid}/{serializer}/`

Create a new cell for a row.

#### Path Parameters

| Name       | Type   | Description                     |
| ---------- | ------ | ------------------------------- |
| level      | string | level=organization              |
| sid        | string | sid=organization sid            |
| serializer | string | choose of \[name, list, detail] |

#### Query Parameters

| Name       | Type   | Description        |
| ---------- | ------ | ------------------ |
| row\_\_sid | string | the sid of the row |

#### Headers

| Name  | Type   | Description              |
| ----- | ------ | ------------------------ |
| token | string | the authentication token |

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

```yaml
{
    "sid": "xxx",
    "data": "2020-05-25",
    "row": {
        "sid": "xxx",
        "name": "EP625: Test Name 20200525133408"
    },
    "column": {
        "sid": "xxx",
        "name": "date_start"
    },
    "widget": {
        "sid": "xxx",
        "name": "Date - Edit date value"
    },
    "date_updated": "2020-05-25T20:34:39.293654Z",
    "date_created": "2020-05-25T20:34:39.292882Z",
    "change_permission": true
}
```

{% endtab %}

{% tab title="406 " %}

```
Error: Missing row__sid in the post link.
Error: Your organization does not have enough credits, contact sales@labii.com!
Error: The row (xxx) does not belong to the organization (xxx)
```

{% endtab %}
{% endtabs %}

## Cell Detail

<mark style="color:purple;">`PATCH`</mark> `/tables/cell/detail/{sid}/`

Update the content of a cell.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| sid  | string | cell sid    |

#### Headers

| Name  | Type   | Description              |
| ----- | ------ | ------------------------ |
| token | string | the authentication token |

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

```yaml
{
    "sid": "xxx",
    "data": "2020-05-25",
    "row": {
        "sid": "xxx",
        "name": "EP625: Test Name 20200525133408"
    },
    "column": {
        "sid": "xxx",
        "name": "date_start"
    },
    "widget": {
        "sid": "xxx",
        "name": "Date - Edit date value"
    },
    "date_updated": "2020-05-25T20:34:39.293654Z",
    "date_created": "2020-05-25T20:34:39.292882Z",
    "change_permission": true
}
```

{% endtab %}

{% tab title="406 " %}

```
Wrong id - the provided sid is not correct
Your organization does not have enough credits, contact sales@labii.com!
```

{% endtab %}
{% endtabs %}
