Masa Detayı — GET /plugin-api/tables/get ✓ Canlı

table.close gate'i yalnızca bir referans taşır (target:{type:'table', id:'…'}); masanın DOLU içeriğini (ürünler, tutar, müşteri) bu uçtan, o id ile çekersiniz. Paket karşılığı packets/get ile aynı şekil/mapping'tir.

← API Uçları · ortak kurallar (base, auth, hata zarfı) orada.

İstek

GET {RESTOMENUM_BASE}/plugin-api/tables/get?id=<encodeURIComponent(target.id)>
Authorization: Bearer <apiKey>     // kurulumdaki (OAuth exchange) install API key
  • Base ({RESTOMENUM_BASE}): ortama göre — Sandbox https://sandbox.plugins.restomenum.app, Production https://plugins.restomenum.app (tüm liste: API Uçları).
  • Auth: Authorization: Bearer <apiKey> — kurulumda OAuth token exchange'te aldığın apiKey.
  • Scope: orders:read zorunlu (yoksa plugin.scope.denied).
URL-encode zorunlu: target.id URL-encoded olabilir (örn. bah%C3%A7e1 — Türkçe ç yüzünden). Query'de mutlaka encodeURIComponent(target.id) kullan; yoksa çift-decode olur → plugin.tables.notFound.

Yanıt

Paket karşılığı packets/get ile aynı kanonik desendedir (envelope { success, data } + temiz orders[]). Canlı örnek (gerçek masa Bahçe1):

{ "success": true, "data": {
  "tableId": "bah%C3%A7e1",      // doküman id (target.id ile aynı)
  "tableName": "Bahçe1",         // görünen ad
  "docNo": 7,
  "desing": "Bahçe",             // masa/alan
  "location": "Bahçe1",
  "personCount": 0,
  "total": 360.5,
  "paid": 50,
  "totalDiscount": 0,
  "orders": [
    { "id": "bah%C3%A7e1-7c08", "title": "HYPATİA KAHVALTI", "quantity": 1, "options": [], "extra": 0, "discount": 0,   "note": "", "lineTotal": 160 },
    { "id": "bah%C3%A7e1-9624", "title": "KÖRİ SOSLU TAVUK",  "quantity": 1, "options": [], "extra": 0, "discount": 6.5, "note": "", "lineTotal": 58.5 }
  ]
  // "customer": { … }   // dine-in'de genelde yok; varsa customers:read + consent ile
}}
AlanAçıklama
tableIdDoküman id (target.id ile aynı; URL-encoded olabilir).
tableName / desing / locationMasanın görünen adı / alanı / konumu.
total / paid / totalDiscountHesap toplamı / ödenen / indirim toplamı.
orders[]Sipariş satırları (aşağıdaki şema).
customerVarsa müşteri (PII; customers:read + consent ile). Dine-in'de genelde yok.

orders[] satırı

Temiz satır — iç alanlar (ham product objesi, log, requestId, storages…) gönderilmez; yalnız ihtiyacın olanlar:

AlanAçıklama
idSatır id (referans).
titleÜrün adı.
quantityAdet.
optionsSeçili seçenek adları (string array).
extra / discountEkstra / satır indirimi.
noteSatır notu.
lineTotalSatır toplamı (Restomenum hesaplar).

PII (customer)

customer alanları webhook ile aynı kuralla kırpılır: customers:read yoksa PII alanları (name, phone, address, email, tckn, vergino) silinir. Dine-in masalarda customer genelde hiç bulunmaz.

Hatalar

DurumYanıt
Masa yok (veya çift-decode'lu id){ success:false, message:"plugin.tables.notFound" }
Scope yok{ success:false, message:"plugin.scope.denied" }

Kullanım (table.close gate ile)

// table.close gate (/api/hook) içinde: gate yalnız target.id taşır → masanın DOLU hesabını çek.
const r = await fetch(`${BASE}/plugin-api/tables/get?id=${encodeURIComponent(hook.target.id)}`, {
  headers: { authorization: 'Bearer ' + apiKey },   // kurulumdaki install API key
}).then((x) => x.json());
const bill = r.data;          // bill.total, bill.orders → faturayı kes