# Article categories

Each product or service within the PORTOS system is linked to a specific category (e.g. desserts, soups, meals, ...), which is referred to as the **article category**. This categorization helps in organizing and classifying items, allowing for efficient management and navigation within the system.

Article category is represented by [`ArticleCategory`](https://developers.portos.sk/data-models#articlecategory) class.

## API methods

## Get article categories

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

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

#### Query Parameters

| Name         | Type      | Description                                                                                                              |
| ------------ | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| color        | string    | Supports NData syntax.                                                                                                   |
| courseNumber | int       | 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. |
| label        | string    | Supports NData syn                                                                                                       |

#### 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":
    [
        {
            "_v": 1,
            "description": "Daily menu",
            "label": "MNU",
            "color": "#AED581",
            "courseNumber": null,
            "customerDescription": "Meals according to the daily menu",
            "sortHint": 1,
            "tags":
            [
                "Kitchen"
            ],
            "ordering":
            [
                {
                    "orderOrigin": "Online",
                    "enabled": true,
                    "weeklySchedule":
                    [
                        {
                            "days":
                            [
                                "Monday",
                                "Tuesday",
                                "Wednesday",
                                "Thursday",
                                "Friday"
                            ],
                            "timeRange":
                            {
                                "from": "11:00:00",
                                "to": "13:30:00"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "label": "BRS",
            "description": "Beers",
            "customerDescription": null,
            "courseNumber": null,
            "color": "#FF8F00",
            "sortHint": 1,
            "tags":
            [],
            "_v": 1
        },
        {
            "label": "SOF",
            "description": "Soft Drinks",
            "customerDescription": null,
            "courseNumber": null,
            "color": null,
            "sortHint": null,
            "tags":
            [],
            "_v": 1
        }
    ],
    "count": 3,
    "totalCount": 3
}
```

{% endtab %}
{% endtabs %}

## Get article category by label

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

Result is of type [Article category](https://developers.portos.sk/data-models#articlecategory).

#### Path Parameters

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

#### Headers

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

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

```javascript
{
    "_v": 1,
    "description": "Daily menu",
    "label": "MNU",
    "color": "#AED581",
    "courseNumber": null,
    "customerDescription": "Meals according to the daily menu",
    "sortHint": 1,
    "tags":
    [
        "Kitchen"
    ],
    "ordering":
    [
        {
            "orderOrigin": "Online",
            "enabled": true,
            "weeklySchedule":
            [
                {
                    "days":
                    [
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday"
                    ],
                    "timeRange":
                    {
                        "from": "11:00:00",
                        "to": "13:30:00"
                    }
                }
            ]
        }
    ]
}
```

{% endtab %}

{% tab title="404: Not Found Article category with given label is not found." %}

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

{% endtab %}
{% endtabs %}

## Create article category

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

Creates new article category. Result is of type [Article category](https://developers.portos.sk/data-models#articlecategory).

**Required rights**

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

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

```javascript
{
    "_v": 1,
    "description": "Daily menu",
    "label": "MNU",
    "color": "#AED581",
    "courseNumber": null,
    "customerDescription": "Meals according to the daily menu",
    "sortHint": 1,
    "tags":
    [
        "Kitchen"
    ],
    "ordering":
    [
        {
            "orderOrigin": "Online",
            "enabled": true,
            "weeklySchedule":
            [
                {
                    "days":
                    [
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday"
                    ],
                    "timeRange":
                    {
                        "from": "11:00:00",
                        "to": "13:30:00"
                    }
                }
            ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Create or update article category

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

Creates new or updates existing article category. Result is of type [Article category](https://developers.portos.sk/data-models#articlecategory).

**Required rights**

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

#### Path Parameters

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

#### 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> | ArticleCategory | Model to create or update. |

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

```javascript
{
    "_v": 1,
    "description": "Daily menu",
    "label": "MNU",
    "color": "#AED581",
    "courseNumber": null,
    "customerDescription": "Meals according to the daily menu",
    "sortHint": 1,
    "tags":
    [
        "Kitchen"
    ],
    "ordering":
    [
        {
            "orderOrigin": "Online",
            "enabled": true,
            "weeklySchedule":
            [
                {
                    "days":
                    [
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday"
                    ],
                    "timeRange":
                    {
                        "from": "11:00:00",
                        "to": "13:30:00"
                    }
                }
            ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Delete article category by label

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

**Required rights**

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

#### Path Parameters

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

#### Headers

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

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

```javascript
{
    "_v": 1,
    "description": "Daily menu",
    "label": "MNU",
    "color": "#AED581",
    "courseNumber": null,
    "customerDescription": "Meals according to the daily menu",
    "sortHint": 1,
    "tags":
    [
        "Kitchen"
    ],
    "ordering":
    [
        {
            "orderOrigin": "Online",
            "enabled": true,
            "weeklySchedule":
            [
                {
                    "days":
                    [
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday"
                    ],
                    "timeRange":
                    {
                        "from": "11:00:00",
                        "to": "13:30:00"
                    }
                }
            ]
        }
    ]
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}
