diff --git a/hopper/api/views.py b/hopper/api/views.py index 14d36d0..5102edb 100644 --- a/hopper/api/views.py +++ b/hopper/api/views.py @@ -17,7 +17,12 @@ from hopper.api.dto import ( ) from hopper.engine import GameEngine from hopper.enums import Direction, PlayerMoveResult -from hopper.errors import Collision, GameLockForMovement, PositionOutOfBounds, PurchaseForbiddenForPlayer +from hopper.errors import ( + Collision, + GameLockForMovement, + PositionOutOfBounds, + PurchaseForbiddenForPlayer, +) from hopper.models.player import Player from settings import settings @@ -81,11 +86,11 @@ async def start_game( responses={ status.HTTP_403_FORBIDDEN: { "model": ErrorResponseDto, - "description": " Player inactive", + "description": "Player inactive", }, status.HTTP_404_NOT_FOUND: { "model": ErrorResponseDto, - "description": " Player with id not found, probably kicked out", + "description": "Player with id not found, probably kicked out", }, }, ) @@ -106,19 +111,19 @@ async def get_player_info( }, status.HTTP_403_FORBIDDEN: { "model": ErrorResponseDto, - "description": " Player inactive", + "description": "Player inactive", }, status.HTTP_404_NOT_FOUND: { "model": ErrorResponseDto, - "description": " Player with id not found, probably kicked out", + "description": "Player with id not found, probably kicked out", }, status.HTTP_409_CONFLICT: { "model": ErrorResponseDto, - "description": " Position out of bounds or collision with an object", + "description": "Position out of bounds or collision with an object", }, status.HTTP_423_LOCKED: { "model": ErrorResponseDto, - "description": " Player reached destination. Can't move anymore.", + "description": "Player reached destination. Can't move anymore.", }, }, ) @@ -167,7 +172,24 @@ async def get_product(id: str) -> ProductDto: ) -@router.post("/player/{id}/product/purchase", response_model=ProductDto) +@router.post( + "/player/{id}/product/purchase", + response_model=ProductDto, + responses={ + status.HTTP_200_OK: { + "model": ProductDto, + "description": "Product purchased", + }, + status.HTTP_403_FORBIDDEN: { + "model": ErrorResponseDto, + "description": "Purchase forbidden for this player", + }, + status.HTTP_404_NOT_FOUND: { + "model": ErrorResponseDto, + "description": " Player with id not found, probably kicked out", + }, + }, +) async def purchase_product( body: PurchaseProductDto, engine: GameEngine = Depends(get_game_engine),