Modified main.py to accept JSON body
This commit is contained in:
parent
cec8389302
commit
53ecccd712
1 changed files with 9 additions and 3 deletions
12
main.py
12
main.py
|
|
@ -36,6 +36,12 @@ class TypeDocument(int, Enum):
|
|||
# =====================================================
|
||||
# MODÈLES
|
||||
# =====================================================
|
||||
|
||||
class DocumentGetRequest(BaseModel):
|
||||
numero: str
|
||||
type_doc: int
|
||||
|
||||
|
||||
class FiltreRequest(BaseModel):
|
||||
filtre: Optional[str] = ""
|
||||
|
||||
|
|
@ -473,12 +479,12 @@ def changer_statut_devis_endpoint(numero: str, nouveau_statut: int):
|
|||
# ENDPOINTS - DOCUMENTS
|
||||
# =====================================================
|
||||
@app.post("/sage/documents/get", dependencies=[Depends(verify_token)])
|
||||
def lire_document(numero: str, type_doc: int):
|
||||
def lire_document(req: DocumentGetRequest):
|
||||
"""Lecture d'un document (commande, facture, etc.)"""
|
||||
try:
|
||||
doc = sage.lire_document(numero, type_doc)
|
||||
doc = sage.lire_document(req.numero, req.type_doc)
|
||||
if not doc:
|
||||
raise HTTPException(404, f"Document {numero} non trouvé")
|
||||
raise HTTPException(404, f"Document {req.numero} non trouvé")
|
||||
return {"success": True, "data": doc}
|
||||
except HTTPException:
|
||||
raise
|
||||
|
|
|
|||
Loading…
Reference in a new issue