Skip to content

Commit

Permalink
fix: add missing startTime and endTime parameters to TFT MatchApi
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjerk authored and pseudonym117 committed May 16, 2023
1 parent ae27cf4 commit 8fe94b6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
28 changes: 25 additions & 3 deletions src/riotwatcher/_apis/team_fight_tactics/MatchApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from ..helpers import remap_region_to_platform
from .urls import MatchApiUrls

from typing import Optional


class MatchApi(NamedEndpoint):
"""
Expand All @@ -19,7 +21,15 @@ def __init__(self, base_api: BaseApi):
super().__init__(base_api, self.__class__.__name__)

@remap_region_to_platform(1)
def by_puuid(self, region: str, puuid: str, count: int = 20, start: int = 0):
def by_puuid(
self,
region: str,
puuid: str,
count: int = 20,
start: int = 0,
start_time: Optional[int] = None,
end_time: Optional[int] = None,
):
"""
Get a list of match ids by PUUID.
Expand All @@ -28,16 +38,28 @@ def by_puuid(self, region: str, puuid: str, count: int = 20, start: int = 0):
:param int count: Defaults to 20. Valid values: 0 to 100. Number of
match ids to return.
:param int start: Defaults to 0. Start index.
:param int start_time: Epoch timestamp in seconds.
:param int end_time: Epoch timestamp in seconds.
:returns: List[string]
"""
args = {
"count": count,
"start": start,
}

if start_time:
args["startTime"] = start_time

if end_time:
args["endTime"] = end_time

return self._request_endpoint(
self.by_puuid.__name__,
region,
MatchApiUrls.by_puuid,
puuid=puuid,
start=start,
count=count,
**args,
)

@remap_region_to_platform(1)
Expand Down
12 changes: 10 additions & 2 deletions tests/_apis/team_fight_tactics/test_MatchApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@ def test_by_puuid_takes_args(self, mock_match_api):
region = "afas"
puuid = "15462-54321"
start, count = 50, 100
start_time, end_time = 1683990000, 1683991032

ret = mock_match_api.api.by_puuid(region, puuid, count, start)
ret = mock_match_api.api.by_puuid(
region,
puuid,
count,
start,
start_time,
end_time,
)

mock_match_api.base_api.raw_request.assert_called_once_with(
MatchApi.__name__,
mock_match_api.api.by_puuid.__name__,
region,
f"https://{region}.api.riotgames.com/tft/match/v1/matches/by-puuid/{puuid}/ids",
{"count": count, "start": start},
{"count": count, "start": start, "startTime": start_time, "endTime": end_time},
)

assert ret is mock_match_api.expected_return
Expand Down

0 comments on commit 8fe94b6

Please sign in to comment.