diff --git a/SOUL.md b/SOUL.md index 0300f41..c40aa4d 100644 --- a/SOUL.md +++ b/SOUL.md @@ -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 diff --git a/main.py b/main.py index daed965..8d4127a 100644 --- a/main.py +++ b/main.py @@ -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()