Add purchase product errors docs
This commit is contained in:
@ -17,7 +17,12 @@ from hopper.api.dto import (
|
|||||||
)
|
)
|
||||||
from hopper.engine import GameEngine
|
from hopper.engine import GameEngine
|
||||||
from hopper.enums import Direction, PlayerMoveResult
|
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 hopper.models.player import Player
|
||||||
from settings import settings
|
from settings import settings
|
||||||
|
|
||||||
@ -81,11 +86,11 @@ async def start_game(
|
|||||||
responses={
|
responses={
|
||||||
status.HTTP_403_FORBIDDEN: {
|
status.HTTP_403_FORBIDDEN: {
|
||||||
"model": ErrorResponseDto,
|
"model": ErrorResponseDto,
|
||||||
"description": " Player inactive",
|
"description": "Player inactive",
|
||||||
},
|
},
|
||||||
status.HTTP_404_NOT_FOUND: {
|
status.HTTP_404_NOT_FOUND: {
|
||||||
"model": ErrorResponseDto,
|
"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: {
|
status.HTTP_403_FORBIDDEN: {
|
||||||
"model": ErrorResponseDto,
|
"model": ErrorResponseDto,
|
||||||
"description": " Player inactive",
|
"description": "Player inactive",
|
||||||
},
|
},
|
||||||
status.HTTP_404_NOT_FOUND: {
|
status.HTTP_404_NOT_FOUND: {
|
||||||
"model": ErrorResponseDto,
|
"model": ErrorResponseDto,
|
||||||
"description": " Player with id not found, probably kicked out",
|
"description": "Player with id not found, probably kicked out",
|
||||||
},
|
},
|
||||||
status.HTTP_409_CONFLICT: {
|
status.HTTP_409_CONFLICT: {
|
||||||
"model": ErrorResponseDto,
|
"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: {
|
status.HTTP_423_LOCKED: {
|
||||||
"model": ErrorResponseDto,
|
"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(
|
async def purchase_product(
|
||||||
body: PurchaseProductDto,
|
body: PurchaseProductDto,
|
||||||
engine: GameEngine = Depends(get_game_engine),
|
engine: GameEngine = Depends(get_game_engine),
|
||||||
|
|||||||
Reference in New Issue
Block a user