# Settings

The API offers a range of modules and extensions that require configuration. In order to faciliate the process of module configuration, the API provides methods for accessing and managing stored configurations. These configurations are represented by a [`Settings`](https://developers.portos.sk/api-reference/settings) class.

Every module has its unique identifier, which is used as key when accessing given configuration section.

## API methods

## Get settings

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

Returns all stored settings. Result is of type `Dictionary<string,`[`Settings`](https://developers.portos.sk/data-models#settings)`>`. The dictionary keys represents settings section keys.

#### Headers

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

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

```javascript
{
    "Portos.Features.Qerko":
    {
        "IsEnabled": true,
        "ApiKey": "aaaa-bbbb-cccc-dddd-eeee-ffff",
        "Environment": "development",
        "StockName": "Qerko",
        "FiscalName": "eKasa",
        "TicketForm": "Print",
        "PaymentTypeNumber": 2,
        "AllowPartialPayment": true,
        "IsTipAllowed": true,
        "IsOrderToTicketEnabled": true,
        "IsOrderToTableEnabled": true,
        "IsTakeAwayOrderEnabled": true,
        "IsOrderConfirmationPrintingEnabled": true,
        "IsPaymentConfirmationPrintingEnabled": true,
        "IsNettoTipOnPaymentConfirmationEnabled": false,
        "UploadMenuOnStart": true,
        "OutOfStockMode": "belowMinimalStockQuantity",
        "TipVatCategory": 1,
        "DiscountVatCategory": 1
    },
    "Portos.Features.Camarero":
    {
        "IsEnabled": false,
        "InputDirectoryPath": "C:/POS/",
        "UnprocessableFilesDirectoryPath": "C:/POS/FAILED/",
        "FileReadMaxRetryCount": 3,
        "FileReadRetryDelayMs": 300,
        "FileExtension": ".pda",
        "QuantityScale": 2,
        "UnitPriceScale": 2,
        "DefaultStockName": "S02",
        "DefaultFiscalName": null,
        "DefaultVatCategory": 1,
        "DefaultUnit": "ks",
        "DefaultPurchaseType": "WalkIn",
        "RoundingTreshold": 0.05,
        "SkipOrdersProcessing": true,
        "ProcessOrders": false
    },
    "Portos.Features.OrderManagement":
    {
        "LastOrderNumber": 1
    }
}
```

{% endtab %}
{% endtabs %}

## Get settings section

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

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

#### Path Parameters

| Name                                  | Type   | Description                      |
| ------------------------------------- | ------ | -------------------------------- |
| key<mark style="color:red;">\*</mark> | string | The settings section identifier. |

#### Headers

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

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

```javascript
{
    "LastOrderNumber": 1
}
```

{% endtab %}

{% tab title="404: Not Found Settings section is not found." %}

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

{% endtab %}
{% endtabs %}

## Create or update settings section

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

Updates existing or creates new settings section. The result of this operation is of type [Settings](https://developers.portos.sk/data-models#settings).

**Required rights**

No user rights are required.

#### Path Parameters

| Name                                  | Type   | Description                      |
| ------------------------------------- | ------ | -------------------------------- |
| key<mark style="color:red;">\*</mark> | string | The settings section identifier. |

#### 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> | Settings | Settings object to store. |

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

```javascript
{
    "LastOrderNumber": 1
}
```

{% endtab %}
{% endtabs %}

## Partially update settings section

<mark style="color:purple;">`PATCH`</mark> `http://{server-address}/settings`

This method updates only a subset of the settings section. Any properties that are not present in the request body will remain unchanged. The result of this operation is of type [Settings](https://developers.portos.sk/data-models#settings).

**Required rights**

No user rights are required.

#### 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> | Settings | Partial settings object to store. |

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

```javascript
{
    "LastOrderNumber": 1
}
```

{% endtab %}
{% endtabs %}

## Delete settings section

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

**Required rights**

No user rights are required.

#### Path Parameters

| Name                                   | Type   | Description                      |
| -------------------------------------- | ------ | -------------------------------- |
| name<mark style="color:red;">\*</mark> | string | The settings section identifier. |

#### Headers

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

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

```javascript
{
    "LastOrderNumber": 1
}
```

{% endtab %}
{% endtabs %}
