diff --git a/hondana/client.py b/hondana/client.py index 50ee7b0..3922d8c 100644 --- a/hondana/client.py +++ b/hondana/client.py @@ -2385,6 +2385,43 @@ async def check_if_following_manga(self, manga_id: str, /) -> bool: else: return True + @require_authentication + async def get_my_custom_list_follows(self, limit: int = 10, offset: int = 0) -> list[CustomList]: + """|coro| + + This method will return the current authenticated user's custom list follows. + + Returns + -------- + list[:class:`CustomList`] + The list of custom lists you follow. + """ + data = await self._http._get_user_custom_list_follows(limit=limit, offset=offset) + + fmt: list[CustomList] = [] + for item in data["data"]: + fmt.append(CustomList(self._http, item)) + + return fmt + + @require_authentication + async def check_if_following_custom_list(self, custom_list_id: str, /) -> bool: + """|coro| + + This method will check if the current authenticated user is following the specified custom list. + + Returns + -------- + :class:`bool` + Whether you follow this custom list or not. + """ + try: + await self._http._check_if_following_list(custom_list_id) + except errors.NotFound: + return False + else: + return True + async def create_account(self, *, username: str, password: str, email: str) -> User: """|coro| @@ -2698,6 +2735,48 @@ async def delete_custom_list(self, custom_list_id: str, /) -> None: """ await self._http._delete_custom_list(custom_list_id) + @require_authentication + async def follow_custom_list(self, custom_list_id: str, /) -> None: + """|coro| + + This method will follow a custom list within the MangaDex API. + + Parameters + ----------- + custom_list_id: :class:`str` + The UUID relating to the custom list we wish to follow. + + Raises + ------- + :exc:`BadRequest` + The request was malformed. + :exc:`Forbidden` + You are not authorized to follow this custom list. + :exc:`NotFound` + The specified custom list does not exist. + """ + await self._http._follow_custom_list(custom_list_id) + + @require_authentication + async def unfollow_custom_list(self, custom_list_id: str, /) -> None: + """|coro| + + The method will unfollow a custom list within the MangaDex API. + + Parameters + ----------- + custom_list_id: :class:`str` + The UUID relating to the custom list we wish to unfollow. + + Raises + ------- + :exc:`Forbidden` + You are not authorized to unfollow this custom list. + :exc:`NotFound` + The specified custom list does not exist. + """ + await self._http._unfollow_custom_list(custom_list_id) + @require_authentication async def get_my_custom_lists(self, *, limit: Optional[int] = 10, offset: int = 0) -> CustomListCollection: """|coro| diff --git a/hondana/custom_list.py b/hondana/custom_list.py index 22c86a3..3f06e5a 100644 --- a/hondana/custom_list.py +++ b/hondana/custom_list.py @@ -287,3 +287,33 @@ async def delete_custom_list(self) -> None: The custom list with this UUID was not found. """ await self._http._delete_custom_list(self.id) + + @require_authentication + async def follow(self) -> None: + """|coro| + + The method will follow a custom list within the MangaDex API. + + Raises + ------- + :exc:`Forbidden` + You are not authorized to follow this custom list. + :exc:`NotFound` + The specified custom list does not exist. + """ + await self._http._follow_custom_list(self.id) + + @require_authentication + async def unfollow(self) -> None: + """|coro| + + The method will unfollow a custom list within the MangaDex API. + + Raises + ------- + :exc:`Forbidden` + You are not authorized to unfollow this custom list. + :exc:`NotFound` + The specified custom list does not exist. + """ + await self._http._unfollow_custom_list(self.id) diff --git a/hondana/http.py b/hondana/http.py index d0e59f6..d5d80bf 100644 --- a/hondana/http.py +++ b/hondana/http.py @@ -1385,6 +1385,18 @@ def _check_if_following_manga(self, manga_id: str, /) -> Response[dict[Literal[" route = Route("GET", "/user/follows/manga/{manga_id}", manga_id=manga_id) return self.request(route) + def _get_user_custom_list_follows(self, limit: int, offset: int) -> Response[custom_list.GetMultiCustomListResponse]: + route = Route("GET", "/user/follows/list") + + limit, offset = calculate_limits(limit, offset, max_limit=100) + query: dict[str, Any] = {"limit": limit, "offset": offset} + + return self.request(route, params=query) + + def _check_if_following_list(self, custom_list_id: str, /) -> Response[dict[Literal["result"], Literal["ok"]]]: + route = Route("GET", "/user/follows/list/{custom_list_id}", custom_list_id=custom_list_id) + return self.request(route) + def _get_user_followed_manga( self, limit: int, offset: int, includes: Optional[MangaIncludes] ) -> Response[manga.MangaSearchResponse]: @@ -1501,6 +1513,14 @@ def _delete_custom_list(self, custom_list_id: str, /) -> Response[dict[Literal[" route = Route("DELETE", "/list/{custom_list_id}", custom_list_id=custom_list_id) return self.request(route) + def _follow_custom_list(self, custom_list_id: str, /) -> Response[dict[Literal["result"], Literal["ok", "error"]]]: + route = Route("POST", "/list/{custom_list_id}/follow", custom_list_id=custom_list_id) + return self.request(route) + + def _unfollow_custom_list(self, custom_list_id: str, /) -> Response[dict[Literal["result"], Literal["ok", "error"]]]: + route = Route("DELETE", "/list/{custom_list_id}/follow", custom_list_id=custom_list_id) + return self.request(route) + def _add_manga_to_custom_list( self, *, custom_list_id: str, manga_id: str ) -> Response[dict[Literal["result"], Literal["ok", "error"]]]: