mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-16 03:55:28 +00:00
🎨 Update get_record_card
This commit is contained in:
parent
842ad515cd
commit
1a8053ea6b
@ -1,4 +1,5 @@
|
||||
from typing import Optional, Any, List
|
||||
|
||||
from simnet.client.base import BaseClient
|
||||
from simnet.client.routes import RECORD_URL
|
||||
from simnet.errors import DataNotPublic
|
||||
@ -99,11 +100,11 @@ class BaseChronicleClient(BaseClient):
|
||||
*,
|
||||
lang: Optional[str] = None,
|
||||
) -> List[RecordCard]:
|
||||
"""Get a user's record cards.
|
||||
"""Get a player record cards.
|
||||
|
||||
Args:
|
||||
account_id: Optional[int], the user's account ID, defaults to None
|
||||
lang: Optional[str], the language version of the request, defaults to None
|
||||
account_id: (int, optional), the user's account ID, defaults to None
|
||||
lang: (str, optional), the language version of the request, defaults to None
|
||||
|
||||
Returns:
|
||||
A list of RecordCard objects.
|
||||
|
@ -11,6 +11,7 @@ from simnet.models.genshin.chronicle.stats import (
|
||||
GenshinUserStats,
|
||||
FullGenshinUserStats,
|
||||
)
|
||||
from simnet.models.lab.record import RecordCard
|
||||
from simnet.utils.enum_ import Game
|
||||
from simnet.utils.player import recognize_genshin_server, recognize_region
|
||||
|
||||
@ -229,3 +230,31 @@ class GenshinBattleChronicleClient(BaseChronicleClient):
|
||||
Dict: The requested get_genshin_activities.
|
||||
"""
|
||||
return await self._request_genshin_record("activities", player_id, lang=lang)
|
||||
|
||||
async def get_record_card(
|
||||
self,
|
||||
account_id: Optional[int] = None,
|
||||
*,
|
||||
lang: Optional[str] = None,
|
||||
) -> Optional[RecordCard]:
|
||||
"""Get a genshin player record cards.
|
||||
|
||||
Args:
|
||||
account_id: Optional[int], the user's account ID, defaults to None
|
||||
lang: Optional[str], the language version of the request, defaults to None
|
||||
|
||||
Returns:
|
||||
Genshin player record cards.
|
||||
|
||||
Returns:
|
||||
Optional[RecordCard]: RecordCard objects.
|
||||
"""
|
||||
account_id = account_id or self.account_id
|
||||
|
||||
record_cards = await self.get_record_cards(account_id, lang=lang)
|
||||
|
||||
for record_card in record_cards:
|
||||
if record_card.game == Game.GENSHIN:
|
||||
return record_card
|
||||
|
||||
return None
|
||||
|
@ -3,6 +3,7 @@ from typing import Optional, Mapping, Dict, Any
|
||||
|
||||
from simnet.client.components.chronicle.base import BaseChronicleClient
|
||||
from simnet.errors import BadRequest, DataNotPublic
|
||||
from simnet.models.lab.record import RecordCard
|
||||
from simnet.models.starrail.chronicle.characters import StarShipDetailCharacters
|
||||
from simnet.models.starrail.chronicle.notes import StarRailNote
|
||||
from simnet.models.starrail.chronicle.stats import StarRailUserStats
|
||||
@ -142,3 +143,31 @@ class StarRailBattleChronicleClient(BaseChronicleClient):
|
||||
payload = {"need_wiki": "true"}
|
||||
data = await self._request_starrail_record("avatar/info", player_id, lang=lang, payload=payload)
|
||||
return StarShipDetailCharacters(**data)
|
||||
|
||||
async def get_record_card(
|
||||
self,
|
||||
account_id: Optional[int] = None,
|
||||
*,
|
||||
lang: Optional[str] = None,
|
||||
) -> Optional[RecordCard]:
|
||||
"""Get a starrail player record cards.
|
||||
|
||||
Args:
|
||||
account_id: Optional[int], the user's account ID, defaults to None
|
||||
lang: Optional[str], the language version of the request, defaults to None
|
||||
|
||||
Returns:
|
||||
Starrail user record cards.
|
||||
|
||||
Returns:
|
||||
Optional[RecordCard]: RecordCard objects.
|
||||
"""
|
||||
account_id = account_id or self.account_id
|
||||
|
||||
record_cards = await self.get_record_cards(account_id, lang=lang)
|
||||
|
||||
for record_card in record_cards:
|
||||
if record_card.game == Game.STARRAIL:
|
||||
return record_card
|
||||
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user