32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from board_mate_client import ApiClient, DefaultApi, GameDto
|
|
|
|
|
|
class ApiController:
|
|
|
|
def __init__(self, config) -> None:
|
|
self.config = config
|
|
|
|
def create_party(self, white_name, black_name, time_value, increment) -> str | None:
|
|
try:
|
|
with ApiClient(self.config) as client:
|
|
api = DefaultApi(client)
|
|
|
|
game = GameDto(
|
|
white_name="Alice",
|
|
black_name="Bob",
|
|
time_value=300,
|
|
increment=10
|
|
)
|
|
|
|
response = api.create_party(game)
|
|
print("Raw response:", response)
|
|
return str(response.data)
|
|
except Exception as e:
|
|
print("Error during create_party:", e)
|
|
return None
|
|
|
|
def retrieve_game(self, game_id) -> GameDto:
|
|
with ApiClient(self.config) as client:
|
|
api = DefaultApi(client)
|
|
response = api.retrieve_games(game_id)
|
|
return GameDto.from_dict(response.data) |