# Zones

The zone represents visual representation of a specific area, such as a room, terrace, or any other defined space. It contains the layout, dimensions, and arrangement of objects within that area.

The data model for zone is represented by [`Zone`](https://developers.portos.sk/data-models#zone) class.

## API methods

## Get zones

<mark style="color:blue;">`GET`</mark> `http://{server-address}/zones`

Returns all zones that matches query parameters. Result is of type [`QueryResult<Zone>`](https://developers.portos.sk/data-models#queryresult).

#### Query Parameters

| Name              | Type      | Description                                                                                                              |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| Name              | string    | Supports NData syntax.                                                                                                   |
| DefaultFiscalName | string    | Supports NData syntax.                                                                                                   |
| $skip             | int       | Pagination property. Describing number of records to skip from beginning of result collection.                           |
| $take             | int       | Pagination property. Maximum count of items to be returned.                                                              |
| $sort             | string\[] | <p>Comma separated list of property names. Please see NData syntax.<br></p>                                              |
| $count            | bool      | If set to `true`, response will not contain `items` collection. Use to get resource count, not the resources themselves. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successful response" %}

```javascript
{
    "items":
    [
        {
            "name": "Bar",
            "defaultFiscalName": null,
            "items":
            [
                {
                    "name": "B01",
                    "isTable": true,
                    "meta":
                    {
                        "position":
                        {
                            "x": 0.10,
                            "y": 0.10
                        },
                        "width": 0.12,
                        "height": 0.12,
                        "shape": "Rectangle",
                        "rotation": 0,
                        "color": "#cccccc"
                    }
                },
                {
                    "name": "B02",
                    "isTable": true,
                    "meta":
                    {
                        "position":
                        {
                            "x": 0.30,
                            "y": 0.10
                        },
                        "width": 0.12,
                        "height": 0.12,
                        "shape": "Rectangle",
                        "rotation": 0,
                        "color": "#cccccc"
                    }
                }
            ],
            "sortHint": 1,
            "_v": 1
        }
    ],
    "count": 1,
    "totalCount": 1
}
```

{% endtab %}
{% endtabs %}

## Get zone by name

<mark style="color:blue;">`GET`</mark> `http://{server-address}/zones/{name}`

Result is of type [Zone](https://developers.portos.sk/data-models#zone).

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| name<mark style="color:red;">\*</mark> | string | Unique zone name. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

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

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Zone with given name is not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Create zone

<mark style="color:green;">`POST`</mark> `http://{server-address}/zones`

Creates new zone. Result is of type [Zone](https://developers.portos.sk/data-models#zone).

**Required rights**

Authorized user must have `ZoneCreate` [right ](https://developers.portos.sk/user-rights)assigned.

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type | Description          |
| ---------------------------------------- | ---- | -------------------- |
| (body)<mark style="color:red;">\*</mark> | Zone | Zone model to create |

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

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update zone

<mark style="color:orange;">`PUT`</mark> `http://{server-address}/zones/{name}`

Updates existing or creates new zone. Result is of type [Zone](https://developers.portos.sk/data-models#zone).

**Required rights**

Authorized user must have assigned `ZoneCreate` or `ZoneUpdate` [right](https://developers.portos.sk/user-rights).

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| name<mark style="color:red;">\*</mark> | string | Unique zone name. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type | Description                     |
| ---------------------------------------- | ---- | ------------------------------- |
| (body)<mark style="color:red;">\*</mark> | Zone | Zone model to create or update. |

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

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Delete zone by name

<mark style="color:red;">`DELETE`</mark> `http://{server-address}/zones/{name}`

**Required rights**

Authorized user must have `ZoneDelete` [right ](https://developers.portos.sk/user-rights)assigned.

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| name<mark style="color:red;">\*</mark> | string | Unique zone name. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

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

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}
