Added endpoint to retrieve wishlist
This commit is contained in:
parent
04906e67c7
commit
cfff61853a
2 changed files with 13 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ authenticated_session: requests.Session = requests.Session()
|
|||
|
||||
def url_to_xml_object(url: HttpUrl) -> ET.Element:
|
||||
r = authenticated_session.get(url)
|
||||
assert r.status_code == 200
|
||||
assert r.status_code == 200, "Got {} status code".format(r.status_code)
|
||||
root = ET.fromstring(r.content)
|
||||
return root
|
||||
|
||||
|
|
@ -144,6 +144,11 @@ def get_user_owned_collection() -> list[BoardGame]:
|
|||
|
||||
return owned_boardgames
|
||||
|
||||
def get_user_wishlist_collection() -> list[BoardGame]:
|
||||
url = 'https://boardgamegeek.com/xmlapi2/collection?username={}&wishlist=1&stats=1&showprivate=1&version=1'.format(auth_manager.username)
|
||||
wishlisted_boardgames = get_boardgames_from_collection_url(url)
|
||||
|
||||
return wishlisted_boardgames
|
||||
|
||||
|
||||
def load_authenticated_bgg_session(username: str, password: str) -> requests.Session:
|
||||
|
|
|
|||
8
main.py
8
main.py
|
|
@ -2,7 +2,7 @@ from typing import Union
|
|||
from fastapi import FastAPI
|
||||
|
||||
from classes.boardgame import BoardGame, BoardGameExpansion
|
||||
from bgg_connection import get_boardgame, get_user_owned_collection
|
||||
from bgg_connection import get_boardgame, get_user_owned_collection, get_user_wishlist_collection
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
|
@ -24,4 +24,10 @@ def get_boardgame_by_id(boardgame_id: int):
|
|||
@app.get("/collection", response_model=list[BoardGame])
|
||||
def get_owned_collection():
|
||||
requested_collection: list[BoardGame] = get_user_owned_collection()
|
||||
return requested_collection
|
||||
|
||||
|
||||
@app.get("/wishlist", response_model=list[BoardGame])
|
||||
def get_wishlist_collection():
|
||||
requested_collection: list[BoardGame] = get_user_wishlist_collection()
|
||||
return requested_collection
|
||||
Loading…
Reference in a new issue