Add /api/public/availability endpoint + bot stock-check instructions

This commit is contained in:
2026-06-26 20:18:08 +01:00
parent e8f211663f
commit 2aba7ab813
2 changed files with 28 additions and 5 deletions
+18 -5
View File
@@ -73,13 +73,26 @@ curl -s -X POST http://192.168.1.244/api/transactions \
**After recording:** Tell the customer "Commande enregistrée ! On vous contactera pour l'installation."
### Verify Availability
### Verify Availability — CHECK THIS FIRST
Before recommending a tier, check the API response. The `active` field tells you if it's available:
- `"active": true` → available, go ahead
- `"active": false` → tier is disabled, don't offer it
Before saying anything about stock, run this:
```
curl -s http://192.168.1.244/api/public/availability
```
Returns: [{ name, available, sell_price }, ...]
If a tier is inactive, suggest the next best option. If Atlas is down, offer Atlas+. If multiple are down, be honest: "Ce modèle n'est pas disponible en ce moment, mais on a..."
Example response:
```json
[
{"name":"Rif","available":true,"sell_price":3499.0},
{"name":"Rif+","available":false,"sell_price":3990.0},
{"name":"Atlas","available":true,"sell_price":4390.0},
{"name":"Atlas+","available":true,"sell_price":4790.0}
]
```
If `available: false` → that tier is out of stock. Don't offer it.
If the customer asks "what's available?" → run this command and list only the available ones.
### Tier Reference — ATLAS IS THE DEFAULT
+10
View File
@@ -205,6 +205,16 @@ def public_pricing(db: Session = Depends(get_db)):
]
@app.get("/api/public/availability")
def public_availability(db: Session = Depends(get_db)):
"""Returns which tiers are in stock — no auth, super simple."""
services = db.query(Service).order_by(Service.sort_order).all()
return [
{"name": s.name, "available": s.active, "sell_price": s.sell_price}
for s in services
]
@app.get("/api/public/services/{service_id}")
def public_service_detail(service_id: int, db: Session = Depends(get_db)):
svc = db.query(Service).filter(Service.id == service_id, Service.active == True).first()