Методы API для кассы ВкусВилл
Все успешные ответы от сервера имеют вид:
JavaScript
type Res = {
id: string
nodeId: string
result: Result
payload: Result
success: boolean
}
JavaScript
POST objects/${oid}/commands/check-state?withChildGroups=true
Ответ:
JavaScript
type CheckStateRes = {}
Пример запроса
JavaScript
curl --location --request POST '<https://app.rightech.io/api/v1/objects/{{oid}>}/commands/check-state?withChildGroups=true' \\\\\\\\
--header 'Authorization: Bearer {{token}}'
Пример ответа
JavaScript
{
"id": "b-oyrssUuzo-E4tH",
"nodeId": "check-state",
"result": {},
"payload": {},
"success": true
}
JavaScript
POST objects/${oid}/commands/make-order?withChildGroups=true
JavaScript
type MakeOrderReq = {
count: number
}
type MakeOrderRes = {
orderId: string
}
Пример запроса
JavaScript
curl --location '<https://app.rightech.io/api/v1/objects/{{oid}>}/commands/make-order?withChildGroups=true' \\\\\\\\
--header 'Content-Type: application/json' \\\\\\\\
--header 'Authorization: Bearer {{token}}' \\\\\\\\
--data '{"count": 10}'
Пример ответа
JavaScript
{
"id": "Jh6Pu25gkUZV3ov6",
"nodeId": "make-order",
"result": {
"orderId": "64887f2ac3b09928ec8fb57f"
},
"payload": {
"orderId": "64887f2ac3b09928ec8fb57f"
},
"success": true
}
JavaScript
POST objects/${oid}/commands/check-order?withChildGroups=true
JavaScript
type CheckOrderReq = {
orderId: string
}
type CheckOrderRes = {
oid: string
status: Status
total: number
current: number
progress: string // `${current}/${total}`
createdAt: number
steps: Array<{
status: Status
current: number
time: number
}>
completedAt?: number
}
Пример запроса
JavaScript
curl --location '<https://app.rightech.io/api/v1/objects/{{oid}>}/commands/check-order?withChildGroups=true' \\\\\\\\
--header 'Content-Type: application/json' \\\\\\\\
--header 'Authorization: Bearer {{token}}' \\\\\\\\
--data '{"orderId": "64887f2ac3b09928ec8fb57f"}'
Пример ответа
JavaScript
{
"id": "Pz_tLiriWBQmEJCe",
"nodeId": "check-order",
"result": {
"oid": "64303898e704830011b69d62",
"status": "pending",
"total": 10,
"current": 3,
"progress": "3/10",
"createdAt": 1686667050216,
"steps": [
{
"status": "pending",
"current": 0,
"time": 1686667050216
},
{
"status": "pending",
"current": 1,
"time": 1686667369359
},
{
"status": "pending",
"current": 2,
"time": 1686667371515
},
{
"status": "pending",
"current": 3,
"time": 1686667373159
}
],
"time": 1686667050536,
"_id": "64887f2ac3b09928ec8fb57f",
"success": true
},
"payload": {
"oid": "64303898e704830011b69d62",
"status": "pending",
"total": 10,
"current": 3,
"progress": "3/10",
"createdAt": 1686667050216,
"steps": [
{
"status": "pending",
"current": 0,
"time": 1686667050216
},
{
"status": "pending",
"current": 1,
"time": 1686667369359
},
{
"status": "pending",
"current": 2,
"time": 1686667371515
},
{
"status": "pending",
"current": 3,
"time": 1686667373159
}
],
"time": 1686667050536,
"_id": "64887f2ac3b09928ec8fb57f",
"success": true
},
"success": true
}
code | message |
|---|---|
A0 | Устройство оффлайн |
A1 | Устройство занято |
A2 | Неверный идентификатор заказа |
A3 | Неверное числовое значение |
При возникновении ошибки будет возвращен http статус, отличный от 200.
Причину и дополнительные сведения можно найти в res.helper.message и res.helper.errors.
Для check-state и make-order добавляется дополнительное поле orderId - идентификатор выполняемого заказа
Пример ответов с ошибкой
JavaScript
{
"success": false,
"name": "RicError",
"code": "422",
"message": "Unprocessable Entity",
"tags": [
"error_action_exec"
],
"codes": [
"error_action_exec"
],
"helper": {
"message": "Device busy",
"orderId": "64887f2ac3b09928ec8fb57f",
"errors": [
{
"code": "A1",
"message": "Устройство занято"
}
],
"request": {
"method": "POST",
"path": "/objects/64303898e704830011b69d62/commands/check-state",
"span": {
"ts": "2023-06-13T14:57:29.449Z",
"to": "2023-06-13T14:57:29.744Z"
}
}
}
}
JavaScript
{
"success": false,
"name": "RicError",
"code": "400",
"message": "Bad Request",
"tags": [
"error_action_exec"
],
"codes": [
"error_action_exec"
],
"helper": {
"message": "Error on device",
"errors": [
{
"code": "E2",
"message": "Отсутствует контейнер для молотого кофе"
},
{
"code": "E3",
"message": "Отсутствует контейнер с водой"
}
],
"request": {
"method": "POST",
"path": "/objects/64303898e704830011b69d62/commands/check-state",
"span": {
"ts": "2023-06-13T15:00:54.029Z",
"to": "2023-06-13T15:00:54.410Z"
}
}
}
}