Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
feat(resources): update clubs methods
Browse files Browse the repository at this point in the history
Add pagination with limit for `/images` and `/members`
Correct docstring for `/members`
  • Loading branch information
SecondThundeR committed Jul 26, 2023
1 parent 702556d commit 65147dd
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions shikithon/resources/clubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,35 +326,57 @@ async def clubs(self, club_id: int, page: Optional[int] = None):

@method_endpoint('/api/clubs/:id/members')
@exceptions_handler(ShikimoriAPIResponseError, fallback=[])
async def members(self, club_id: int):
"""Returns member list of club.
async def members(self,
club_id: int,
page: Optional[int] = None,
limit: Optional[int] = None):
"""Returns list of club members.
:param club_id: Club ID to get member list
:param club_id: Club ID to get list of members
:type club_id: int
:param page: Number of page
:type page: Optional[int]
:param limit: Number of results limit
:type limit: Optional[int]
:return: Club's member list
:rtype: List[UserInfo]
"""
query_dict = Utils.create_query_dict(page=page, limit=limit)

response = await self._client.request(
self._client.endpoints.club_members(club_id))
self._client.endpoints.club_members(club_id), query=query_dict)

return Utils.validate_response_data(cast(List[Dict[str, Any]],
response),
data_model=UserInfo)

@method_endpoint('/api/clubs/:id/images')
@exceptions_handler(ShikimoriAPIResponseError, fallback=[])
async def images(self, club_id: int):
async def images(self,
club_id: int,
page: Optional[int] = None,
limit: Optional[int] = None):
"""Returns images of club.
:param club_id: Club ID to get images
:type club_id: int
:param page: Number of page
:type page: Optional[int]
:param limit: Number of results limit
:type limit: Optional[int]
:return: Club's image list
:rtype: List[ClubImage]
"""
query_dict = Utils.create_query_dict(page=page, limit=limit)

response = await self._client.request(
self._client.endpoints.club_images(club_id))
self._client.endpoints.club_images(club_id), query=query_dict)

return Utils.validate_response_data(cast(List[Dict[str, Any]],
response),
Expand Down

0 comments on commit 65147dd

Please sign in to comment.