Skip to content

Commit

Permalink
feat: AdminAccountActions.create メソッドの戻り値に CreatedUser を使うように
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Mar 4, 2024
1 parent cf9460f commit 4cdc1d8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mipac/actions/admins/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from mipac.abstract.action import AbstractAction
from mipac.http import HTTPClient, Route
from mipac.models.user import CreatedUser
from mipac.types.user import ICreatedUser

if TYPE_CHECKING:
from mipac.client import ClientManager
Expand All @@ -14,7 +16,7 @@ def __init__(self, *, session: HTTPClient, client: ClientManager):
self._session: HTTPClient = session
self._client: ClientManager = client

async def create(self, username: str, password: str): # TODO: 多分UserDetailed + tokenってキー
async def create(self, username: str, password: str) -> CreatedUser:
"""ユーザーを作成します
Endpoint: `/api/admin/accounts/create`
Expand All @@ -25,13 +27,18 @@ async def create(self, username: str, password: str): # TODO: 多分UserDetaile
ユーザー名
password : str
パスワード
Returns
-------
CreatedUser
作成されたユーザー
"""
data = {"username": username, "password": password}
res = await self._session.request(
raw_created_user: ICreatedUser = await self._session.request(
Route("POST", "/api/admin/accounts/create"),
json=data,
)
return res
return CreatedUser(raw_created_user, client=self._client)

async def delete(self, *, user_id: str) -> bool:
"""対象のユーザーを削除します
Expand Down

0 comments on commit 4cdc1d8

Please sign in to comment.