SIMNet/simnet/client/wish/starrail.py

47 lines
1.7 KiB
Python
Raw Normal View History

2023-05-04 11:35:01 +00:00
from functools import partial
2023-05-01 12:50:48 +00:00
from typing import Optional, List
from simnet.client.wish.base import BaseWishClient
from simnet.models.starrail.wish import StarRailWish
from simnet.utils.enum_ import Game
2023-05-04 11:35:01 +00:00
from simnet.utils.paginator import WishPaginator
2023-05-01 12:50:48 +00:00
class WishClient(BaseWishClient):
"""The WishClient class for making requests towards the Wish API."""
async def wish_history(
self,
2023-05-04 11:35:01 +00:00
banner_type: int,
2023-05-01 12:50:48 +00:00
limit: Optional[int] = None,
lang: Optional[str] = None,
authkey: Optional[str] = None,
end_id: int = 0,
) -> List[StarRailWish]:
"""
Get the wish history for a list of banner types.
Args:
2023-05-04 11:35:01 +00:00
banner_type (int, optional): The banner types to get the wish history for.
2023-05-01 12:50:48 +00:00
limit (Optional[int] , optional): The maximum number of wishes to retrieve.
If not provided, all available wishes will be returned.
lang (Optional[str], optional): The language code to use for the request.
If not provided, the class default will be used.
authkey (Optional[str], optional): The authorization key for making the request.
end_id (int, optional): The ending ID of the last wish to retrieve.
Returns:
List[StarRailWish]: A list of StarRailWish objects representing the retrieved wishes.
"""
2023-05-04 11:35:01 +00:00
paginator = WishPaginator(
end_id,
partial(
self.get_wish_page,
banner_type=banner_type,
game=Game.STARRAIL,
authkey=authkey,
),
2023-05-01 12:50:48 +00:00
)
2023-05-04 11:35:01 +00:00
items = await paginator.get(limit)
wish = [StarRailWish(**i) for i in items]
2023-05-01 12:50:48 +00:00
return wish