From 9d62d3fb6a2d8e8963b0696fb00a0968d50689e2 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Mon, 22 May 2023 13:46:19 +0900 Subject: [PATCH] follow changes to auth api on 2023-05-22. --- mdrsclient/api/user.py | 9 ++++++--- mdrsclient/models/user.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mdrsclient/api/user.py b/mdrsclient/api/user.py index 81c34d4..9b98cd8 100644 --- a/mdrsclient/api/user.py +++ b/mdrsclient/api/user.py @@ -11,8 +11,9 @@ from mdrsclient.models import Token, User @dataclass(frozen=True) class UserAuthResponse(Token): - laboratory: str - lab_id: int + is_reviewer: bool | None = None + laboratory: str | None = None + lab_id: int | None = None class UserApi(BaseApi): @@ -28,7 +29,9 @@ class UserApi(BaseApi): self._raise_response_error(response) obj = parse_obj_as(UserAuthResponse, response.json()) token = Token(access=obj.access, refresh=obj.refresh) - user = User(id=token.user_id, username=username, laboratory_id=obj.lab_id, laboratory=obj.laboratory) + laboratory_ids = [obj.lab_id] if obj.lab_id is not None else [] + is_reviewer = obj.is_reviewer if obj.is_reviewer is not None else False + user = User(id=token.user_id, username=username, laboratory_ids=laboratory_ids, is_reviewer=is_reviewer) return (user, token) def refresh(self, token: Token) -> Token: diff --git a/mdrsclient/models/user.py b/mdrsclient/models/user.py index c73cdb4..a968a52 100644 --- a/mdrsclient/models/user.py +++ b/mdrsclient/models/user.py @@ -46,5 +46,5 @@ class Token: class User: id: int username: str - laboratory_id: int - laboratory: str + laboratory_ids: list[int] + is_reviewer: bool