# Order endpoints

Once the product (PLU) is added to the [`Ticket`](https://developers.portos.sk/data-models#ticket), an [`Order`](https://developers.portos.sk/data-models#order) is created. Based on product settings, order is sent to one or multiple [order endpoints](https://developers.portos.sk/data-models#orderendpoint) for processing. The order endpoint serves as a device that handles incoming orders. This endpoint can take the form of either a printer, such as a kitchen printer, which generates printed instructions for the food preparation team, or a tablet that enables personnel to provide feedback to cashiers once the food is being prepared or is ready for pickup.

Order endpoint device is represented by [`OrderEndpoint`](https://developers.portos.sk/data-models#orderendpoint) class.

## API methods

## Get order endpoints

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

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

#### Query Parameters

| Name     | Type      | Description                                                                                                              |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| name     | 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. |
| isActive | bool      | Supports NData syntax.                                                                                                   |
| type     | string    | Supports NData syntax.                                                                                                   |
| address  | string    | Supports NData syntax.                                                                                                   |

#### 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": "Kitchen",
            "isActive": false,
            "address": "\\\\computer_name\\Kitchen",
            "type": "SRP350",
            "settings":
            {
                "IsBeepEnabled": "true",
                "HighlightOrderNumber": "true",
                "DoubleHeightFont": "true",
                "DoubleWidthFont": "true"
            },
            "_v": 1
        },
        {
            "name": "Pizza",
            "isActive": false,
            "address": "\\\\computer_name\\Pizza",
            "type": "TM88",
            "settings":
            {},
            "_v": 1
        }
    ],
    "count": 2,
    "totalCount": 2
}
```

{% endtab %}
{% endtabs %}

## Get order endpoint by name

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

Result is of type [`OrderEndpoint`](https://developers.portos.sk/data-models#orderendpoint).

#### Path Parameters

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

#### Headers

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

{% tabs %}
{% tab title="200: OK Resource found." %}

```javascript
{
    "name": "Kitchen",
    "isActive": false,
    "address": "\\\\computer_name\\Kitchen",
    "type": "SRP350",
    "settings":
    {
        "IsBeepEnabled": "true",
        "HighlightOrderNumber": "true",
        "DoubleHeightFont": "true",
        "DoubleWidthFont": "true"
    },
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

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

{% endtab %}
{% endtabs %}

## Create order endpoint

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

Creates new order endpoint. Result is of type [`OrderEndpoint`](https://developers.portos.sk/data-models#orderendpoint).

**Required rights**

Authorized user must have `OrderEndpointCreate` [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> | OrderEndpoint | Model to create. |

{% tabs %}
{% tab title="201: Created Successfuly created." %}

```javascript
{
    "name": "Kitchen",
    "isActive": false,
    "address": "\\\\computer_name\\Kitchen",
    "type": "SRP350",
    "settings":
    {
        "IsBeepEnabled": "true",
        "HighlightOrderNumber": "true",
        "DoubleHeightFont": "true",
        "DoubleWidthFont": "true"
    },
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update order endpoint

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

Creates new or updates existing order endpoint. Result is of type [`OrderEndpoint`](https://developers.portos.sk/data-models#orderendpoint).

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description                 |
| -------------------------------------- | ------ | --------------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique order endpoint 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> | OrderEndpoint | Model to create or update. |

{% tabs %}
{% tab title="200: OK Successfuly created or updated." %}

```javascript
{
    "name": "Kitchen",
    "isActive": false,
    "address": "\\\\computer_name\\Kitchen",
    "type": "SRP350",
    "settings":
    {
        "IsBeepEnabled": "true",
        "HighlightOrderNumber": "true",
        "DoubleHeightFont": "true",
        "DoubleWidthFont": "true"
    },
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Delete order endpoint by name

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

**Required rights**

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

#### Path Parameters

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

#### Headers

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

{% tabs %}
{% tab title="200: OK Successfuly deleted." %}

```javascript
{
    "name": "Kitchen",
    "isActive": false,
    "address": "\\\\computer_name\\Kitchen",
    "type": "SRP350",
    "settings":
    {
        "IsBeepEnabled": "true",
        "HighlightOrderNumber": "true",
        "DoubleHeightFont": "true",
        "DoubleWidthFont": "true"
    },
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

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

{% endtab %}
{% endtabs %}
