https://alwady.softok.cloud/api-platform
Documentație: https://alwady.softok.cloud/api-platform/
ORDER BY Id ASC).
Fiecare comandă platformă = un bon nou (nu se lipește pe bonul existent al mesei).
Autentificare
Toate endpoint-urile (exceptând această pagină) necesită API key.
- Header recomandat:
X-Api-Key: <cheie> - Alternativ:
Authorization: Bearer <cheie>
Cheia se configurează în api-platform/config.php (API_KEY). Valoarea curentă pe acest server:
sk_a3b42c91d4e6a1b2
Schimbă cheia înainte de producție. Opțional setează PLATFORM_USER_ID (user SoftOK pe bonuri; 0 = primul user activ).
Configurare bază de date
Conexiunea MySQL se setează tot în api-platform/config.php (nu folosește db_connection.txt din API-ul Android):
'DB_SERVER' => '192.168.0.170',
'DB_PORT' => 3306,
'DB_DATABASE' => 'softok',
'DB_USER' => 'softok',
'DB_PASSWORD' => '***',
'DB_POSID' => 1,
Format răspuns
Succes:
{ "ok": true, "data": { ... } }
Eroare:
{ "ok": false, "error": "mesaj" }
Coduri HTTP uzuale: 400 date invalide, 401 neautorizat, 404 negăsit, 405 metodă greșită, 500 eroare server.
Endpoint-uri
| Metodă | URL | Descriere |
|---|---|---|
| GET | /categories.php |
Categorii vandabile |
| GET | /products.php |
Produse (căutare / filtru categorie) |
| POST | /orders.php |
Creează comandă pe sala Online |
| GET | /order-status.php |
Status comandă + linii |
1. Categorii
GET https://alwady.softok.cloud/api-platform/categories.php
Returnează categoriile active care au cel puțin un produs vandabil (aceeași logică ca API-ul Android).
Exemplu curl
curl -s -H "X-Api-Key: sk_a3b42c91d4e6a1b2" \
"https://alwady.softok.cloud/api-platform/categories.php"
Răspuns exemplu
{
"ok": true,
"data": {
"items": [
{ "id": 3, "name": "Pizza", "tipCategorie": "Bucatarie" },
{ "id": 5, "name": "Bauturi", "tipCategorie": "Bar" }
]
}
}
2. Produse
GET https://alwady.softok.cloud/api-platform/products.php
Query params
| Param | Tip | Descriere |
|---|---|---|
q | string | Căutare după denumire / cod bare / PLU |
categoryId | int | Filtru pe categorie (ignorat dacă q e setat) |
subcategoryId | int | Filtru pe subcategorie |
limit | int | Default 100, max 300 |
Exemplu curl
curl -s -H "X-Api-Key: sk_a3b42c91d4e6a1b2" \
"https://alwady.softok.cloud/api-platform/products.php?categoryId=3&limit=50"
curl -s -H "X-Api-Key: sk_a3b42c91d4e6a1b2" \
"https://alwady.softok.cloud/api-platform/products.php?q=margherita"
Răspuns exemplu
{
"ok": true,
"data": {
"items": [
{
"id": 10,
"name": "Pizza Margherita",
"barcode": "2000010",
"price": 32.5,
"stock": 0,
"description": "",
"categoryId": 3,
"subcategoryId": 1,
"categoryTipCategorie": "Bucatarie"
}
]
}
}
3. Creare comandă
POST https://alwady.softok.cloud/api-platform/orders.php
Body JSON. Comanda intră în SoftOK ca bon în așteptare + oglindă bucătărie, pe sala Online / prima masă.
Body
| Câmp | Obligatoriu | Descriere |
|---|---|---|
lines | da | Array: productId, qty, opțional comment |
externalOrderId | nu | ID-ul comenzii pe platformă (idempotență la retry) |
customerName | nu | Nume client (salvat în observații) |
customerPhone | nu | Telefon client |
notes | nu | Note generale comandă |
externalOrderId de două ori, a doua oară primești aceeași comandă cu idempotent: true (fără dublură).
Exemplu curl
curl -s -X POST \
-H "Content-Type: application/json" \
-H "X-Api-Key: sk_a3b42c91d4e6a1b2" \
-d '{
"externalOrderId": "PLT-12345",
"customerName": "Ion Popescu",
"customerPhone": "0700000000",
"notes": "fara ceapa",
"lines": [
{ "productId": 10, "qty": 2, "comment": "extra sos" },
{ "productId": 22, "qty": 1 }
]
}' \
"https://alwady.softok.cloud/api-platform/orders.php"
Răspuns exemplu
{
"ok": true,
"data": {
"orderId": 1582,
"externalOrderId": "PLT-12345",
"nrBon": 421,
"nrZi": 12,
"totalBon": 78.5,
"salaId": 4,
"masaId": 18,
"idempotent": false
}
}
orderId = ID bon așteptare SoftOK (BonuriAsteptare.Id). Folosește-l la status.
4. Status comandă
GET https://alwady.softok.cloud/api-platform/order-status.php
Query params
| Param | Descriere |
|---|---|
orderId | ID intern SoftOK (din răspunsul la creare) |
externalOrderId | ID platformă (dacă a fost trimis la creare) |
Furnizează unul dintre cele două.
Exemple curl
curl -s -H "X-Api-Key: sk_a3b42c91d4e6a1b2" \
"https://alwady.softok.cloud/api-platform/order-status.php?orderId=1582"
curl -s -H "X-Api-Key: sk_a3b42c91d4e6a1b2" \
"https://alwady.softok.cloud/api-platform/order-status.php?externalOrderId=PLT-12345"
Răspuns exemplu
{
"ok": true,
"data": {
"orderId": 1582,
"externalOrderId": "PLT-12345",
"nrBon": 421,
"nrZi": 12,
"totalBon": 78.5,
"salaId": 4,
"masaId": 18,
"bonStatus": 1,
"status": "preparing",
"lines": [
{
"lineId": 9001,
"productId": 10,
"name": "Pizza Margherita",
"qty": 2,
"comment": "extra sos",
"prepStatus": 1,
"status": "preparing"
},
{
"lineId": 9002,
"productId": 22,
"name": "Cola 0.5L",
"qty": 1,
"comment": "",
"prepStatus": 0,
"status": "received"
}
]
}
}
Mapare status preparare
| prepStatus | status (linie) | În bucătărie |
|---|---|---|
| 0 | received | Preluat / așteptare |
| 1 | preparing | În preparare |
| 2 | ready | Gata |
Status agregat comandă (data.status):
received— toate liniile la 0preparing— cel puțin o linie ≥ 1, dar nu toate gataready— toate liniile la 2unknown— fără linii
Erori tipice
| Situație | HTTP | error |
|---|---|---|
| Lipsește / greșită cheia | 401 | Neautorizat. |
| Lipsesc lines / produse invalide | 400 | mesaj descriptiv |
| Sala Online inexistentă | 404 | Sala "Online" nu exista... |
| Comandă negăsită la status | 404 | Comanda nu a fost gasita. |
Flux recomandat pentru platformă
- Sincronizează catalogul:
GET /categories.phpapoiGET /products.php - La checkout:
POST /orders.phpcuexternalOrderIdunic + linii - Polling status:
GET /order-status.php?orderId=...până laready