Skip to content

Commit

Permalink
feat: enhance fetch_agents method to include is_playable_character pa…
Browse files Browse the repository at this point in the history
…rameter
  • Loading branch information
staciax committed Jan 9, 2025
1 parent 6708b14 commit a156155
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions valorant/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,16 @@ async def fetch_agent(self, uuid: str, /, *, language: LanguageOption | None = N
agent = Response[Agent].model_validate(data)
return agent.data

async def fetch_agents(self, *, language: LanguageOption | None = None) -> list[Agent]:
data = await self.http.get_agents(language=language or self.language)
async def fetch_agents(
self,
*,
language: LanguageOption | None = None,
is_playable_character: bool | None = None,
) -> list[Agent]:
data = await self.http.get_agents(
language=language or self.language,
is_playable_character=is_playable_character,
)
agents = Response[list[Agent]].model_validate(data)
return agents.data

Expand Down
11 changes: 9 additions & 2 deletions valorant/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ def clear(self) -> None:

# valorant-api.com

def get_agents(self, *, language: str | None = None, is_playable_character: bool = True) -> Response[Any]:
params = {'isPlayableCharacter': str(is_playable_character)}
def get_agents(
self,
*,
language: str | None = None,
is_playable_character: bool | None = None,
) -> Response[Any]:
params = {}
if language is not None:
params['language'] = language
if is_playable_character is not None:
params['isPlayableCharacter'] = str(is_playable_character)
return self.request(Route('GET', '/agents'), params=params)

def get_agent(self, uuid: str, *, language: str | None = None) -> Response[Any]:
Expand Down

0 comments on commit a156155

Please sign in to comment.