Skip to content

Commit

Permalink
feat: /api/users/lists/update をサポート
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Dec 29, 2023
1 parent 44ccd07 commit 07931fd
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions mipac/actions/users/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from mipac.models.note import Note
from mipac.models.user import UserList
from mipac.types.user import IUserList
from mipac.utils.format import remove_dict_missing
from mipac.utils.util import MISSING

if TYPE_CHECKING:
from mipac.client import ClientManager
Expand Down Expand Up @@ -237,6 +239,42 @@ async def unfavorite(self, *, list_id: str | None = None) -> bool:
)
return res

async def update(
self, name: str = MISSING, is_public: bool = MISSING, *, list_id: str | None = None
) -> UserList:
"""Update a user list
Endpoint `/api/users/lists/update`
Parameters
----------
name : str, optional
The new name of the user list, by default MISSING
is_public : bool, optional
Whether the user list should be public, by default MISSING
list_id : str, optional
The id of the user list to update, by default None
Returns
-------
UserList
The updated user list
"""
list_id = list_id or self.__list_id

if list_id is None:
raise ParameterError("required parameter list_id is missing")

data = remove_dict_missing({"listId": list_id, "name": name, "public": is_public})

res: IUserList = await self._session.request(
Route("POST", "/api/users/lists/update"),
json=data,
auth=True,
)
return UserList(raw_user_list=res, client=self._client)

# ここからはusers/lists系じゃないが、ここにあってほしい物
async def get_time_line(
self,
limit: int = 10,
Expand Down Expand Up @@ -351,6 +389,10 @@ async def favorite(self, list_id: str) -> bool:
async def unfavorite(self, list_id: str) -> bool:
return await super().unfavorite(list_id=list_id)

@override
async def update(self, name: str = MISSING, is_public: bool = MISSING, *, list_id: str | None = None) -> UserList:
return await super().update(name, is_public, list_id=list_id)

@override
async def get_time_line(
self,
Expand Down

0 comments on commit 07931fd

Please sign in to comment.