# Підключення за допомогою Postman

Перед початком підключення рекомендуємо ознайомитись з:

* [Документацією Postman](https://learning.postman.com/labs/postman-api-client/websocket-client/websocket-client-overview/) щодо використання WebSocket.

Для підключення через WebSocket використовується адреса:

```http
wss://api.shaketopay.com.ua/restaurantEntryPoint
```

***

## Авторизація

Передати у header параметр `Authorization` згенерований наступним чином:

"`Basic X`" - у якому `Х` це [`RESTO_ID:SECRET_KEY`](/api/integration/prepare.md) закодоване у base64.

<figure><img src="/files/LqNJgsWm8GSNJ6soyqty" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
При вдалому підключенні має відобразитись 2 повідомлення у консоль Postman.
{% endhint %}

***

## Приклад запиту - отримання столів

> Перед обробкою запиту переконайтесь,що в Postman встановлено з'єднання по WebSocket.

Зайдіть в [Expirenza admin-panel](https://admin.expirenza.com) у вкладку "Столи та QR-коди "

Консоль Postman має відобразити наступне:

```json
{
    "rID": "2022-11-18 13:18:51.694125371#Lm4R2EQ",
    "operation": "tablesInfo"
}
```

**У окремій вкладці** Postman необхідно викликати [/callback/tablesInfo](/api/messages/tableinfo.md) упродовж 80 секунд.

На момент виклику [/callback/tablesInfo ](/api/messages/tableinfo.md)для форматування заголовку `signature` необхідно використати **Pre-request Script.**

<details>

<summary>Pre-request Script:/callback/tablesInfo</summary>

{% code title="JavaScript" lineNumbers="true" %}

```javascript
var key = "SECRET_KEY";
var body = request.data;
console.log("body ==>" + body);
var hash = CryptoJS.HmacSHA256(body, key);
console.log("hash: " + hash);
var result = hash.toString(CryptoJS.enc.Base64);
console.log("sign result: " + result);
pm.environment.set("signature", result);
```

{% endcode %}

</details>

<figure><img src="/files/yavVVkUAdh5mes7M4nrI" alt=""><figcaption><p>Pre-request Script</p></figcaption></figure>

У Body внести:

{% code title="JSON" lineNumbers="true" %}

```json
{
    "rID": "2022-11-18 13:20:58.329551967#IRuFbD3",
    "tables": [
        {
            "id": "xxx",
            "name": "у камина",
            "number": 12,
            "hallplanId": "Зала 1",
        }
    ]
}
```

{% endcode %}

`rID` - отримати з останнього повідомлення з типом надійшовшого `rID` [**у першій вкладці** Postman.](/api/postman.md#avtorizaciya)

<figure><img src="/files/fz14JDBzMIBFU1Jqwimz" alt=""><figcaption></figcaption></figure>

Додати 2 заголовки у Headers:

* `restoId` - що є [RESTO\_ID](/api/integration/prepare.md).
* `signature` - що сформований у [Pre-request Script](/api/postman.md#pre-request-script-callback-tablesinfo).

<figure><img src="/files/EtMpAb4jx6hWUgbUUyoI" alt=""><figcaption><p>Headers</p></figcaption></figure>

***

## Завершення підключення за допомогою Postman

Якщо усі кроки були виконані коректно - в [Expirenza admin-panel](https://admin.expirenza.com) мають з'явитись столи зі сформованого раніше у Postman запиту.

<figure><img src="/files/S2ZadnsQ3lWPRBb4ML9H" alt=""><figcaption><p>Успішно передані столи</p></figcaption></figure>

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.expirenza.com/api/postman.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
