Skip to content

Commit

Permalink
Add new parameters to matchlist
Browse files Browse the repository at this point in the history
  • Loading branch information
stelar7 committed May 15, 2022
1 parent f830176 commit e84258d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
22 changes: 18 additions & 4 deletions src/main/java/no/stelar7/api/r4j/impl/tft/TFTMatchAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,32 @@ private TFTMatchAPI()
// Hide public constructor
}

public List<String> getMatchList(RegionShard server, String PUUID, int count)
public List<String> getMatchList(RegionShard server, String PUUID, Integer start, Integer count, Long startTime, Long endTime)
{
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.PUUID_ID_PLACEHOLDER, PUUID)
.withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey())
.withEndpoint(URLEndpoint.V1_TFT_MATCHLIST)
.withQueryParameter(Constants.START_PLACEHOLDER_DATA, String.valueOf(start))
.withQueryParameter(Constants.COUNT_PLACEHOLDER_DATA, String.valueOf(count))
.withPlatform(server);

if (startTime != null)
{
builder.withQueryParameter(Constants.STARTTIME_PLACEHOLDER_DATA, String.valueOf(startTime));
}

if (endTime != null)
{
builder.withQueryParameter(Constants.ENDTIME_PLACEHOLDER_DATA, String.valueOf(endTime));
}

Map<String, Object> data = new TreeMap<>();
data.put("platform", server);
data.put("puuid", PUUID);
data.put("start", start);
data.put("count", count);
data.put("starttime", startTime);
data.put("endtime", endTime);

Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_MATCHLIST, data);
if (chl.isPresent())
Expand Down Expand Up @@ -62,12 +76,12 @@ public List<String> getMatchList(RegionShard server, String PUUID, int count)
*
* @param server the platform the account is on
* @param puuid the account to check
* @param count the amount of games to fetch
* @param count the amount of games to fetch
* @return {@code MatchIterator}
*/
public MatchIterator getMatchIterator(RegionShard server, String puuid, int count)
public MatchIterator getMatchIterator(RegionShard server, String puuid, Integer start, Integer count, Long startTime, Long endTime)
{
return new MatchIterator(getMatchList(server, puuid, count));
return new MatchIterator(getMatchList(server, puuid, start, count, startTime, endTime));
}

public TFTMatch getMatch(RegionShard platform, String gameId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public MatchListBuilder getLeagueGames()
*/
public List<String> getTFTGames()
{
return TFTMatchAPI.getInstance().getMatchList(platform.toRegionShard(), puuid, 20);
return TFTMatchAPI.getInstance().getMatchList(platform.toRegionShard(), puuid, 0, 20, null, null);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/no/stelar7/api/r4j/tests/tft/TestTFTMatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TestTFTMatch
@Test
public void testFetchList()
{
List<String> stelar7 = api.getMatchList(RegionShard.EUROPE, Summoner.byName(LeagueShard.EUW1, "stelar7").getPUUID(), 20);
List<String> stelar7 = api.getMatchList(RegionShard.EUROPE, Summoner.byName(LeagueShard.EUW1, "stelar7").getPUUID(), 0, 20, null, null);
System.out.println();
}

Expand All @@ -42,7 +42,7 @@ public void testFetchMatchRAW()
public void testMatchIterator()
{
RiotAccount acc = l4j8.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "Yisus", "yisus");
MatchIterator stelar7 = api.getMatchIterator(RegionShard.EUROPE, acc.getPUUID(), 20);
MatchIterator stelar7 = api.getMatchIterator(RegionShard.EUROPE, acc.getPUUID(), 0, 20, null, null);
for (GAMHSMatch m : stelar7)
{
System.out.println(m.asTFTMatch());
Expand Down

0 comments on commit e84258d

Please sign in to comment.