2024-07-24 22:53:56 +02:00
|
|
|
from typing import Union
|
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
2024-08-01 12:34:55 +02:00
|
|
|
from classes.boardgame import BoardGame, BoardGameExpansion, CollectionBoardGame, CollectionBoardGameExpansion, WishlistBoardGame
|
2024-08-01 10:35:51 +02:00
|
|
|
from bgg_connection import get_boardgame, get_user_owned_collection, get_user_wishlist_collection
|
2024-07-25 17:53:59 +02:00
|
|
|
|
2024-07-24 22:53:56 +02:00
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/")
|
|
|
|
|
def read_root():
|
|
|
|
|
return {"Hello": "World"}
|
|
|
|
|
|
2024-07-25 19:38:20 +02:00
|
|
|
@app.get("/boardgame/{boardgame_id}", response_model=BoardGame)
|
|
|
|
|
def get_boardgame_by_id(boardgame_id: int):
|
2024-07-26 12:04:44 +02:00
|
|
|
requested_boardgame: BoardGame = get_boardgame(boardgame_id)
|
2024-07-31 16:03:24 +02:00
|
|
|
return requested_boardgame
|
|
|
|
|
|
2024-08-01 12:34:55 +02:00
|
|
|
@app.get("/collection", response_model=list[CollectionBoardGame])
|
2024-07-31 16:03:24 +02:00
|
|
|
def get_owned_collection():
|
2024-08-01 12:34:55 +02:00
|
|
|
requested_collection: list[CollectionBoardGame] = get_user_owned_collection()
|
2024-08-01 10:35:51 +02:00
|
|
|
return requested_collection
|
|
|
|
|
|
|
|
|
|
|
2024-08-01 12:34:55 +02:00
|
|
|
@app.get("/wishlist", response_model=list[WishlistBoardGame])
|
2024-08-01 10:35:51 +02:00
|
|
|
def get_wishlist_collection():
|
2024-08-01 12:34:55 +02:00
|
|
|
requested_collection: list[WishlistBoardGame] = get_user_wishlist_collection()
|
2024-07-31 16:03:24 +02:00
|
|
|
return requested_collection
|