refactor(api): rename client endpoints to tiers for consistency (Generalized contact's creation endpoint)
This commit is contained in:
parent
efe5961bea
commit
0e2398278f
1 changed files with 10 additions and 14 deletions
24
api.py
24
api.py
|
|
@ -5995,13 +5995,13 @@ async def get_document_pdf(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/clients/{numero}/contacts", response_model=Contact, tags=["Contacts"])
|
@app.post("/tiers/{numero}/contacts", response_model=Contact, tags=["Contacts"])
|
||||||
async def creer_contact(numero: str, contact: ContactCreate):
|
async def creer_contact(numero: str, contact: ContactCreate):
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
sage_client.lire_client(numero)
|
sage_client.lire_tiers(numero)
|
||||||
except:
|
except:
|
||||||
raise HTTPException(404, f"Client {numero} non trouvé")
|
raise HTTPException(404, f"Tiers {numero} non trouvé")
|
||||||
|
|
||||||
if contact.numero != numero:
|
if contact.numero != numero:
|
||||||
contact.numero = numero
|
contact.numero = numero
|
||||||
|
|
@ -6016,8 +6016,8 @@ async def creer_contact(numero: str, contact: ContactCreate):
|
||||||
raise HTTPException(500, str(e))
|
raise HTTPException(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
@app.get("/clients/{numero}/contacts", response_model=List[Contact], tags=["Contacts"])
|
@app.get("/tiers/{numero}/contacts", response_model=List[Contact], tags=["Contacts"])
|
||||||
async def lister_contacts_client(numero: str):
|
async def lister_contacts(numero: str):
|
||||||
try:
|
try:
|
||||||
contacts = sage_client.lister_contacts(numero)
|
contacts = sage_client.lister_contacts(numero)
|
||||||
return [Contact(**c) for c in contacts]
|
return [Contact(**c) for c in contacts]
|
||||||
|
|
@ -6026,7 +6026,7 @@ async def lister_contacts_client(numero: str):
|
||||||
raise HTTPException(500, str(e))
|
raise HTTPException(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
@app.get("/clients/{numero}/contacts/{contact_numero}", response_model=Contact, tags=["Contacts"])
|
@app.get("/tiers/{numero}/contacts/{contact_numero}", response_model=Contact, tags=["Contacts"])
|
||||||
async def obtenir_contact(numero: str, contact_numero: int):
|
async def obtenir_contact(numero: str, contact_numero: int):
|
||||||
try:
|
try:
|
||||||
contact = sage_client.obtenir_contact(numero, contact_numero)
|
contact = sage_client.obtenir_contact(numero, contact_numero)
|
||||||
|
|
@ -6040,7 +6040,7 @@ async def obtenir_contact(numero: str, contact_numero: int):
|
||||||
raise HTTPException(500, str(e))
|
raise HTTPException(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
@app.put("/clients/{numero}/contacts/{contact_numero}", response_model=Contact, tags=["Contacts"])
|
@app.put("/tiers/{numero}/contacts/{contact_numero}", response_model=Contact, tags=["Contacts"])
|
||||||
async def modifier_contact(numero: str, contact_numero: int, contact: ContactUpdate):
|
async def modifier_contact(numero: str, contact_numero: int, contact: ContactUpdate):
|
||||||
try:
|
try:
|
||||||
contact_existant = sage_client.obtenir_contact(numero, contact_numero)
|
contact_existant = sage_client.obtenir_contact(numero, contact_numero)
|
||||||
|
|
@ -6062,7 +6062,7 @@ async def modifier_contact(numero: str, contact_numero: int, contact: ContactUpd
|
||||||
raise HTTPException(500, str(e))
|
raise HTTPException(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
@app.delete("/clients/{numero}/contacts/{contact_numero}", tags=["Contacts"])
|
@app.delete("/tiers/{numero}/contacts/{contact_numero}", tags=["Contacts"])
|
||||||
async def supprimer_contact(numero: str, contact_numero: int):
|
async def supprimer_contact(numero: str, contact_numero: int):
|
||||||
try:
|
try:
|
||||||
resultat = sage_client.supprimer_contact(numero, contact_numero)
|
resultat = sage_client.supprimer_contact(numero, contact_numero)
|
||||||
|
|
@ -6072,7 +6072,7 @@ async def supprimer_contact(numero: str, contact_numero: int):
|
||||||
raise HTTPException(500, str(e))
|
raise HTTPException(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
@app.post("/clients/{numero}/contacts/{contact_numero}/definir-defaut", tags=["Contacts"])
|
@app.post("/tiers/{numero}/contacts/{contact_numero}/definir-defaut", tags=["Contacts"])
|
||||||
async def definir_contact_defaut(numero: str, contact_numero: int):
|
async def definir_contact_defaut(numero: str, contact_numero: int):
|
||||||
try:
|
try:
|
||||||
resultat = sage_client.definir_contact_defaut(numero, contact_numero)
|
resultat = sage_client.definir_contact_defaut(numero, contact_numero)
|
||||||
|
|
@ -6111,11 +6111,7 @@ async def obtenir_tiers(
|
||||||
|
|
||||||
@app.get("/tiers/{code}", response_model=TiersDetails, tags=["Tiers"])
|
@app.get("/tiers/{code}", response_model=TiersDetails, tags=["Tiers"])
|
||||||
async def lire_tiers_detail(code: str):
|
async def lire_tiers_detail(code: str):
|
||||||
"""
|
|
||||||
Lecture détaillée d'un tiers par son code.
|
|
||||||
|
|
||||||
Retourne toutes les informations du tiers ainsi que ses contacts.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
tiers = sage_client.lire_tiers(code)
|
tiers = sage_client.lire_tiers(code)
|
||||||
if not tiers:
|
if not tiers:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue