# Prices and restrictions

## Import prices and restrictions

<mark style="color:green;">`POST`</mark> `https://api.mobile-calendar.com/v0/get/pricing`

This enpoint resturn the price list for date range as well as for given rooms.

#### Headers

| Name          | Type   | Description                                                              |
| ------------- | ------ | ------------------------------------------------------------------------ |
| Authorization | string | API login and password are required header parameters for authentication |

#### Request Body

| Name      | Type   | Description                                                                                                                                   |
| --------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| from      | string | <p>"Date from" to import price list<br>Correct format: <code>YYYY-MM-DD</code></p>                                                            |
| to        | string | <p>"Date to" to import price list<br>Correct format: <code>YYYY-MM-DD</code></p>                                                              |
| room\_ids | array  | Room IDs for which the price list should be imported. This field is not required. If it is not set, the API will return prices for all rooms. |

{% tabs %}
{% tab title="200 Correct answer. Api returned price lists for two rooms (ID: 5630 and 5645)
and for date range Jan 1 - Jan 2 2021." %}

```javascript
{
    "status": "success",
    "data": {
        "currency": "PLN",
        "rooms": {
            "5630": {
                "room_name": "Room1",
                "pricing_type": "PRICE_PER_ROOM",
                "prices_and_restrictions": {
                    "2021-01-01": {
                        "price": "200",
                        "min_stay": "3",
                        "max_stay": "30",
                        "avail_arrival": "1",
                        "avail_departure": "1",
                        "discount": {
                            "min_stay": "7",
                            "price": "10",
                            "type": "1"
                        }
                    },
                    "2021-01-02": {
                        "price": "200",
                        "min_stay": "3",
                        "max_stay": "30",
                        "avail_arrival": "1",
                        "avail_departure": "1",
                        "discount": {
                            "min_stay": "7",
                            "price": "10",
                            "type": "0"
                        }
                    }
                }
            },
            "5645": {
                "room_name": "Room2",
                "pricing_type": "DERIVED_PRICE_MODEL",
                "prices_and_restrictions": {
                    "2021-01-01": {
                        "price": "200"
                    },
                    "2021-01-02": {
                        "price": "200"
                    }
                },
                "options": {
                    "leading_occupancy": "3",
                    "persons": [
                        {
                            "person": 2,
                            "type": "%",
                            "prefix": "-",
                            "amount": "30"
                        },
                        {
                            "person": 1,
                            "type": "%",
                            "prefix": "-",
                            "amount": "50"
                        }
                    ]
                }
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

### Example of request

The request below gets prices for **January 1, 2021, through January 2, 2021** \
and for rooms with ID **5630 and 5645.**

{% hint style="warning" %}
If there is no **`room_ids`** parameter, the API will return prices for all rooms.
{% endhint %}

```
{
    "from" : "2021-01-01", 
    "to" : "2021-01-02",
    "room_ids" : [5630, 5645]
}
```

{% hint style="info" %}
You can find the **room ID** in the rooms details form.
{% endhint %}

<img src="https://685154589-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MkadaB-PDnQKsapJqNT%2F-MkbD5ZBZYAw1zeIBZvq%2F-MkbDfv47l13-9X758jy%2Froom_id.PNG?alt=media&#x26;token=5ee24338-8cff-4b64-9720-506f1c8eb2ba" alt="Room details form" data-size="original">

### The price list object

<table data-header-hidden><thead><tr><th width="150">Pole</th><th width="150">Zagnieżdżenie</th><th width="150">Typ</th><th>Opis</th></tr></thead><tbody><tr><td>Field</td><td>Level</td><td>Type</td><td>Description</td></tr><tr><td>status</td><td>L0</td><td>string</td><td>Responsne status <code>success | errror</code></td></tr><tr><td>errors</td><td>L0</td><td>array</td><td>Informations about errors</td></tr><tr><td>data</td><td>L0</td><td>object</td><td>Main object "Pricing"</td></tr><tr><td>currency</td><td>L1</td><td>string(3)</td><td>Price list currency, 3-character currency format compatilbe with<strong><code>ISO 4217 Standard</code></strong></td></tr><tr><td>room</td><td>L1</td><td>array</td><td>List of rooms, the key of given room is it's ID</td></tr><tr><td>room_name</td><td>L3</td><td>string</td><td>Room name</td></tr><tr><td>pricing_type</td><td>L3</td><td>string</td><td><p>Type of price list. Allowed formats:</p><p><code>PRICE_PER_ROOM | PRICE_PER_PERSON | DERIVED_PRICE_MODEL</code></p></td></tr><tr><td>options</td><td>L3</td><td>array</td><td>Prices for different person. Only available in the pricing model <em><code>DERIVED_PRICE_MODEL</code></em></td></tr><tr><td>leading_occupancy</td><td>L4</td><td>integer</td><td>Leading occupancy. Only occur with the parent field <code>options</code></td></tr><tr><td>persons</td><td>L4</td><td>array</td><td>Individual options. Only occur with the parent field <code>options</code></td></tr><tr><td>person</td><td>L5</td><td>integer</td><td>Number of people referenced by prices</td></tr><tr><td>type</td><td>L5</td><td>string</td><td><p>Indicates whether the discount is to be a percentage or an amount. Formats:</p><p><strong><code>additional</code></strong><code> - currency / amount discount</code></p><p><strong><code>%</code></strong><code> - percentage discount</code></p></td></tr><tr><td>prefix</td><td>L5</td><td>string(1)</td><td>Indicates whether the amount should be negative or positive. Formats: <code>+ | -</code></td></tr><tr><td>amount</td><td>L5</td><td>float</td><td>Amount, correct format: <code>100 | 100.00</code></td></tr><tr><td>prices_and_restrictions</td><td>L3</td><td>array</td><td>Prices and restrictions for a given day, the key of a given day is its date</td></tr><tr><td>price</td><td>L5</td><td>float</td><td>Price, correct format: <code>100 | 100.00</code></td></tr><tr><td>min_price</td><td>L5</td><td>float</td><td>Minimal price, Only available in the pricing model <em><code>PRICE_PER_PERSON</code></em><br>correct format: <code>100 | 100.00</code></td></tr><tr><td>price_child</td><td>L5</td><td>float</td><td>Price for a child, Only available in the pricing model<em><code>PRICE_PER_PERSON</code></em><br>correct format: <code>100 | 100.00</code></td></tr><tr><td>min_stay</td><td>L5</td><td>integer</td><td>Minimum period of stay</td></tr><tr><td>max_stay</td><td>L5</td><td>integer</td><td>Maximum period of stay</td></tr><tr><td>avail_arrival</td><td>L5</td><td>bool</td><td>Available arrival, format: <code>0 | 1</code></td></tr><tr><td>avail_departure</td><td>L5</td><td>bool</td><td>Available departure, format <code>0 | 1</code> </td></tr><tr><td>discount</td><td>L5</td><td>array</td><td>Discount for the stay</td></tr><tr><td>discount.min_stay</td><td>L6</td><td>integer</td><td>The minimum period of stay for which the discount begins</td></tr><tr><td>discount.price</td><td>L6</td><td>float</td><td>Amount or % discount, correct format: <code>100 | 100.00</code></td></tr><tr><td>discount.type</td><td>L6</td><td>integer</td><td><p>Percentage or currency discount type. </p><p><code>0 - oznacza procentowy</code></p><p><code>1 - oznacza walutowy</code></p></td></tr></tbody></table>

### Pricing models

{% tabs %}
{% tab title="PRICE\_PER\_ROOM" %}
"Price per room" pricing model. Means that the price per room is fixed, regardless of the number of people.

{% endtab %}

{% tab title="PRICE\_PER\_PERSON" %}
"Price per person" pricing model. The price is calculated on the basis of the number of people and / or the number of children. You can set a minimum price. If the price for people / children is lower than the minimum price, the minimum price is selected.
{% endtab %}

{% tab title="DERIVED\_PRICE\_MODEL" %}
"Derived pricing model" - in this pricing model we can set a different price for any number of people.&#x20;

There is always in the derived pricing model field **`options`.** \
\&#xNAN;**`Leading_occupany`**&#x64;enotes the base price. The basic price is set in the field **`price`** field.\
For the example below, if the base price is 200:\
**Price for 5 people** = 200 (leading\_occupancy) \
**Price for 4 people** = 150 (leading\_occupany - 25%) \
**Price for 3 people** = 140 (leading\_occupany - 30%) \
**Price for 2 people** = 130 (leading\_occupany - 35%) \
**Price for 1 person** = 120 (leading\_occupany - 40%)

```
 "options": [
    "leading_occupancy": "5",
    "persons": [
        {
            "person": 4,
            "type": "%",
            "prefix": "-",
            "amount": "25"
        },
        {
            "person": 3,
            "type": "%",
            "prefix": "-",
            "amount": "30"
        },
        {
            "person": 2,
            "type": "%",
            "prefix": "-",
            "amount": "35"
        },
        {
            "person": 1,
            "type": "%",
            "prefix": "-",
            "amount": "40"
        }
    ]
]
```

{% endtab %}
{% endtabs %}

### Troubleshooting

#### Informations about errors

| Error                                                                                                        | Description                                                                 |
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| <p>Set date range. <br>Field "From" and "To" is required.</p>                                                | Fiel&#x64;**`From`** and  **`To`** are required parameters                  |
| Incorrect format of "From" and/or "To" fields. Correct format YYYY-MM-DD                                     | Invalid date format. The correct format is: `YYYY-MM-DD`                    |
| <p>"From" date can not be greater than or equal to "To" date.</p><p></p><p>Incorrect date "From" or "To"</p> | Date **`From`** can not be greather than **`to`** date                      |
| Maximum date range is 90 days                                                                                | The maximum range for dates is **90 days**                                  |
| Add room IDs                                                                                                 | If you set **`room_ids`**&#x70;arameter, then you must enter value          |
| Wrong room IDs                                                                                               | You entered the wrong room ID or the rooms are not assigned to your account |

#### An example of a respone with an error

HTTP status **200 OK.**

{% hint style="warning" %}
Note that the **HTTP 200 OK** code does not mean the answer is correct at all!
{% endhint %}

```javascript
{
    "status": "error",
    "data": [],
    "errors": [
        "Incorrect format of \"From\" and/or \"To\" fields. Correct format YYYY-MM-DD",
        "Incorrect date \"From\" or \"To\""
    ]
}
```
