# Currencies

Collection of currencies contains exactly **one** currency marked as domestic. All system transactions are conducted exclusively in the domestic currency.

Currency is represented by [`Currency`](https://developers.portos.sk/data-models#currency) class.

## API methods

## Get currencies

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

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

#### Query Parameters

| Name       | Type      | Description                                                                                                              |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| label      | 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. |
| isDomestic | bool      | 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":
    [
        {
            "IsDomestic": true,
            "Label": "EUR",
            "Sign": "€",
            "ExchangeRate": 1,
            "Description": "Euro",
            "_v": 1
        },
        {
            "IsDomestic": false,
            "Label": "USD",
            "Sign": "$",
            "ExchangeRate": 1.1214,
            "Description": "US Dollar",
            "_v": 1
        },
        {
            "IsDomestic": false,
            "Label": "CZK",
            "Sign": null,
            "ExchangeRate": 23.7529,
            "Description": "Czech Crown",
            "_v": 1
        }
    ],
    "count": 3,
    "totalCount": 3
}
```

{% endtab %}
{% endtabs %}

## Get currency by label

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

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

#### Path Parameters

| Name                                    | Type   | Description            |
| --------------------------------------- | ------ | ---------------------- |
| label<mark style="color:red;">\*</mark> | string | Unique currency 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
{
    "IsDomestic": true,
    "Label": "EUR",
    "Sign": "€",
    "ExchangeRate": 1,
    "Description": "Euro",
    "_v": 1
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

## Create currency

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

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

**Required rights**

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

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

```javascript
{
    "IsDomestic": true,
    "Label": "EUR",
    "Sign": "€",
    "ExchangeRate": 1,
    "Description": "Euro",
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update currency

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

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

**Required rights**

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

#### Path Parameters

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

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

```javascript
{
    "IsDomestic": true,
    "Label": "EUR",
    "Sign": "€",
    "ExchangeRate": 1,
    "Description": "Euro",
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Delete currency by label

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

**Required rights**

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

#### Path Parameters

| Name                                    | Type   | Description            |
| --------------------------------------- | ------ | ---------------------- |
| label<mark style="color:red;">\*</mark> | string | Unique currency 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
{
    "IsDomestic": true,
    "Label": "EUR",
    "Sign": "€",
    "ExchangeRate": 1,
    "Description": "Euro",
    "_v": 1
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}
