Přeskočit na hlavní obsah

Stoly

Ziskani seznamu stolu a jejich dostupnosti.

GET /:slug/tables

Vrati seznam vsech aktivnich stolu.

Pozadavek

curl -X GET \
-H "X-API-Key: vas_api_klic" \
https://api.zarezervujto.cz/api/v1/vas-projekt/tables

Query parametry

ParametrTypPopis
branchIdstringFiltrovat podle pobocky
zoneIdstringFiltrovat podle zony

Odpoved

{
"success": true,
"count": 10,
"tables": [
{
"id": "table-1",
"name": "Stolek 1",
"label": "A1",
"capacity": 4,
"branchId": "branch-1",
"zoneId": "zone-1",
"position": 1,
"visualX": 100,
"visualY": 200,
"visualWidth": 80,
"visualHeight": 80,
"visualRotation": 0,
"visualShape": "rectangle"
},
{
"id": "table-2",
"name": "Stolek 2",
"label": "A2",
"capacity": 2,
"branchId": "branch-1",
"zoneId": "zone-1",
"position": 2,
"visualX": 200,
"visualY": 200,
"visualWidth": 60,
"visualHeight": 60,
"visualRotation": 0,
"visualShape": "circle"
}
]
}

Popis poli

PoleTypPopis
idstringUnikatni ID stolu
namestringNazev stolu
labelstring | nullKratky popisek (napr. cislo)
capacitynumberMaximalni kapacita
branchIdstring | nullID pobocky
zoneIdstring | nullID zony (napr. terasa, interie)
positionnumberPoradi zobrazeni

Vizualni vlastnosti (pro mapu stolu)

PoleTypPopis
visualXnumber | nullX pozice na mape
visualYnumber | nullY pozice na mape
visualWidthnumber | nullSirka
visualHeightnumber | nullVyska
visualRotationnumber | nullRotace ve stupnich
visualShapestring | nullTvar (rectangle, circle, square)

Priklad pouziti

async function getTables(slug, apiKey, options = {}) {
const params = new URLSearchParams();

if (options.branchId) params.append('branchId', options.branchId);
if (options.zoneId) params.append('zoneId', options.zoneId);

const url = `https://api.zarezervujto.cz/api/v1/$:slug/tables?${params}`;

const response = await fetch(url, {
headers: { 'X-API-Key': apiKey }
});

const data = await response.json();
return data.tables;
}

// Pouziti
const tables = await getTables('restaurace-u-jana', 'zrt_live_...');

// Filtrovat stoly podle kapacity
const tablesFor4 = tables.filter(t => t.capacity >= 4);
console.log(`Stoly pro 4+ osoby: ${tablesFor4.length}`);

Filtrovani podle pobocky a zony

# Stoly na terase pobocky branch-1
curl -X GET \
-H "X-API-Key: vas_api_klic" \
"https://api.zarezervujto.cz/api/v1/vas-projekt/tables?branchId=branch-1&zoneId=terasa"

Vykresleni mapy stolu

function renderTableMap(tables, canvasContext) {
tables.forEach(table => {
if (!table.visualX || !table.visualY) return;

const ctx = canvasContext;
ctx.save();

// Presun a rotace
ctx.translate(table.visualX, table.visualY);
ctx.rotate((table.visualRotation || 0) * Math.PI / 180);

// Vykresleni podle tvaru
ctx.fillStyle = '#E5E7EB';
ctx.strokeStyle = '#9CA3AF';

if (table.visualShape === 'circle') {
ctx.beginPath();
ctx.arc(0, 0, table.visualWidth / 2, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
} else {
ctx.fillRect(
-table.visualWidth / 2,
-table.visualHeight / 2,
table.visualWidth,
table.visualHeight
);
ctx.strokeRect(
-table.visualWidth / 2,
-table.visualHeight / 2,
table.visualWidth,
table.visualHeight
);
}

// Popisek
ctx.fillStyle = '#374151';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(table.label || table.name, 0, 0);

ctx.restore();
});
}