Новый эндпоинт: get_user

This commit is contained in:
2025-11-26 01:24:41 +03:00
parent 337c71986b
commit fee6826f79
3 changed files with 178 additions and 40 deletions

View File

@ -317,3 +317,39 @@ class osuAPIClient(AioHTTPXClient):
# TODO: implement other endpoints
# https://osu.ppy.sh/docs/index.html#get-user-beatmaps
async def get_user(
self,
access_token: str,
user_id: int,
mode: Literal['fruits', 'mania', 'osu', 'taiko'] | None = None,
key: Literal['username', 'id'] | None = None,
):
url = f'/users/{user_id}'
if mode:
url += f'/{mode}'
req = await self.get(
url,
params=self.clean_dict({'key': key}),
headers=self.clean_dict(
{
'Authorization': f'Bearer {access_token}',
}
),
)
match req.status_code:
case st.OK:
return s.GetUserSchema.model_validate(req.json())
case st.NOT_FOUND:
raise s.Error(req.status_code, 'Not Found')
case st.UNAUTHORIZED:
raise s.Error(req.status_code, 'Unauthorized')
case _:
self.logger.error(req.text)
raise s.Error(500, 'Internal Server Error')