Skip to content

Commit

Permalink
feat: 作成したユーザーを表すモデルを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Mar 4, 2024
1 parent cf0286e commit cf9460f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions mipac/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
EmailNotificationTypes,
GetFrequentlyRepliedUsersResponse,
IAchievement,
ICreatedUser,
IFfVisibility,
IMeDetailedOnlySchema,
IMeDetailedSchema,
Expand Down Expand Up @@ -491,10 +492,8 @@ def __init__(self, raw_user: T, *, client: ClientManager) -> None:
super().__init__(raw_user, client=client)


class MeDetailed(UserDetailedNotMe[IMeDetailedSchema], MeDetailedOnly): # pyright: ignore 直せない
"""自分の詳細情報"""

def __init__(self, raw_user: IMeDetailedSchema, *, client: ClientManager):
class MeDetailed[T: IMeDetailedSchema](UserDetailedNotMe[T], MeDetailedOnly): # pyright: ignore 直せない
def __init__(self, raw_user: T, *, client: ClientManager):
super().__init__(raw_user, client=client)


Expand Down Expand Up @@ -592,3 +591,12 @@ def weight(self) -> int:

def _get(self, key: str) -> Any | None:
return self._raw_frequently_replied_user.get(key)


class CreatedUser[T: ICreatedUser](MeDetailed[T]):
def __init__(self, raw_user: T, *, client: ClientManager) -> None:
super().__init__(raw_user, client=client)

@property
def token(self) -> str:
return self._raw_user["token"]
4 changes: 4 additions & 0 deletions mipac/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ class IMeDetailedSchema(IUserDetailedNotMeSchema, IMeDetailedOnlySchema):
pass


class ICreatedUser(IMeDetailedSchema):
token: str


IUserDetailed = IUserDetailedNotMeSchema | IMeDetailedSchema

IUser = IPartialUser | IUserDetailed
Expand Down

0 comments on commit cf9460f

Please sign in to comment.