TAŇBA-OOH Әзірлеушілерге

Acknowledge a signed command

POST /d/v1/commands/{id}/ack

https://devices.tanba-ooh.kz/d/v1/commands/{id}/ack

Анықтамалықтың техникалық мәтіні ағылшын тілінде жазылған.

The signed body names the command. command_id must equal the id in the path, otherwise the answer is 400 command_id_mismatch, so the signed acknowledgement of one command cannot be posted to another. An acknowledgement without command_id is accepted for one more release and counted, then refused.

Аутентификация

Құрылғының клиенттік сертификаты (өзара TLS) және құрылғы кілтімен жасалған дене қолтаңбасы.

Параметрлер

АтауыОрныТүріМіндеттіСипаттамаМысал
X-Tanba-SignatureтақырыпstringиәES256 signature of the exact bytes of the body by the device key, raw r||s (64 bytes), base64url without padding.q3J2y0uO8e1m4n7pXc5Zk9d2Wv6Tg0hLsB-aRfN1YjE6uHxPzD3oVtKiC8wMbQe2nSgA4rUl7yFhJ9XcT0dZaw
idжолstring (uuid)иәIdentifier of the command being acknowledged.0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10

Сұраудың денесі

application/json

АтауыТүріМіндеттіСипаттамаМысал
command_idstring (uuid)The command acknowledged; it must equal the id in the path."0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10"
okbooleanиәTrue when the player carried the command out.true
state_snapshotobjectThe state of the player after the command.

Мысал

{
  "command_id": "0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10",
  "ok": true,
  "state_snapshot": {
    "state": "cutoff"
  }
}

Жауаптар

200 Recorded.

application/json

АтауыТүріМіндеттіСипаттамаМысал
statusstringиәAlways recorded. recorded

Мысал

{
  "status": "recorded"
}

Қателер

Қателер problem құжаты (application/problem+json) түрінде, тұрақты code өрісімен келеді.

МәртебесіМағынасы
400The body is not JSON (invalid_json) or command_id differs from the path (command_id_mismatch).
404Nothing there, or not visible to the caller.
defaultAn error as a problem document.

Код мысалдары

curl

curl -X POST 'https://devices.tanba-ooh.kz/d/v1/commands/0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10/ack' \
  -H 'X-Tanba-Signature: q3J2y0uO8e1m4n7pXc5Zk9d2Wv6Tg0hLsB-aRfN1YjE6uHxPzD3oVtKiC8wMbQe2nSgA4rUl7yFhJ9XcT0dZaw' \
  -H 'Content-Type: application/json' \
  -d '{
  "command_id": "0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10",
  "ok": true,
  "state_snapshot": {
    "state": "cutoff"
  }
}'
Python
import requests

response = requests.post(
    "https://devices.tanba-ooh.kz/d/v1/commands/0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10/ack",
    headers={
        "X-Tanba-Signature": "q3J2y0uO8e1m4n7pXc5Zk9d2Wv6Tg0hLsB-aRfN1YjE6uHxPzD3oVtKiC8wMbQe2nSgA4rUl7yFhJ9XcT0dZaw",
        "Content-Type": "application/json",
    },
    json={
        "command_id": "0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10",
        "ok": True,
        "state_snapshot": {
            "state": "cutoff",
        },
    },
)
print(response.status_code, response.text)
Go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	body := strings.NewReader(`{
  "command_id": "0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10",
  "ok": true,
  "state_snapshot": {
    "state": "cutoff"
  }
}`)
	req, err := http.NewRequest("POST", "https://devices.tanba-ooh.kz/d/v1/commands/0b1c3a52-6f0e-4c2e-9d3a-2f5d1e7a9c10/ack", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("X-Tanba-Signature", "q3J2y0uO8e1m4n7pXc5Zk9d2Wv6Tg0hLsB-aRfN1YjE6uHxPzD3oVtKiC8wMbQe2nSgA4rUl7yFhJ9XcT0dZaw")
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	data, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.Status, string(data))
}