22from fastapi .responses import JSONResponse , Response
33from kink import di
44
5+ from src .building_blocks .errors import APIErrorMessage
56from src .clients .application .client_service import ClientService
67from src .clients .application .dto import (
78 ArchiveClientDTO ,
1415router = APIRouter ()
1516
1617
17- @router .post ("/clients" , response_model = ClientDTO , tags = ["clients" ])
18+ @router .post (
19+ "/clients" ,
20+ response_model = ClientDTO ,
21+ responses = {400 : {"model" : APIErrorMessage }, 500 : {"model" : APIErrorMessage }},
22+ tags = ["clients" ],
23+ )
1824async def create_client (
1925 request : CreateClientDTO , service : ClientService = Depends (lambda : di [ClientService ])
2026) -> JSONResponse :
2127 result = service .create (request )
2228 return JSONResponse (content = result .dict (), status_code = status .HTTP_201_CREATED )
2329
2430
25- @router .put ("/clients/{client_id}" , response_model = ClientDTO , tags = ["clients" ])
31+ @router .put (
32+ "/clients/{client_id}" ,
33+ response_model = ClientDTO ,
34+ responses = {400 : {"model" : APIErrorMessage }, 404 : {"model" : APIErrorMessage }, 500 : {"model" : APIErrorMessage }},
35+ tags = ["clients" ],
36+ )
2637async def change_personal_data (
2738 client_id : str , request : ChangeClientPersonalDataDTO , service : ClientService = Depends (lambda : di [ClientService ])
2839) -> JSONResponse :
@@ -31,15 +42,23 @@ async def change_personal_data(
3142 return JSONResponse (content = result .dict (), status_code = status .HTTP_200_OK )
3243
3344
34- @router .delete ("/clients/{client_id}" , status_code = status .HTTP_204_NO_CONTENT , tags = ["clients" ])
45+ @router .delete (
46+ "/clients/{client_id}" ,
47+ status_code = status .HTTP_204_NO_CONTENT ,
48+ responses = {400 : {"model" : APIErrorMessage }, 404 : {"model" : APIErrorMessage }, 500 : {"model" : APIErrorMessage }},
49+ tags = ["clients" ],
50+ )
3551async def archive (client_id : str , service : ClientService = Depends (lambda : di [ClientService ])) -> Response :
3652 service .archive (ArchiveClientDTO (client_id = client_id ))
3753 return Response (status_code = status .HTTP_204_NO_CONTENT )
3854
3955
40- @router .post ("/clients/exports" , status_code = status .HTTP_204_NO_CONTENT , tags = ["clients" ])
41- async def export (
42- request : ExportClientsDTO , service : ClientService = Depends (lambda : di [ClientService ])
43- ) -> Response :
56+ @router .post (
57+ "/clients/exports" ,
58+ status_code = status .HTTP_204_NO_CONTENT ,
59+ responses = {400 : {"model" : APIErrorMessage }, 500 : {"model" : APIErrorMessage }},
60+ tags = ["clients" ],
61+ )
62+ async def export (request : ExportClientsDTO , service : ClientService = Depends (lambda : di [ClientService ])) -> Response :
4463 service .export (request )
4564 return Response (status_code = status .HTTP_204_NO_CONTENT )
0 commit comments