use of no.stelar7.api.r4j.pojo.val.ranked.Leaderboard in project L4J8 by stelar7.
the class VALRankedAPI method getLeaderboard.
public Leaderboard getLeaderboard(ValorantShard platform, String actId, int startIndex, int size) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.ACT_ID_PLACEHOLDER, actId).withQueryParameter(Constants.STARTINDEX_PLACEHOLDER_DATA, String.valueOf(startIndex)).withQueryParameter(Constants.SIZE_PLACEHOLDER_DATA, String.valueOf(size)).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getVALAPIKey()).withEndpoint(URLEndpoint.V1_VAL_LEADERBOARD_BY_ACT).withPlatform(platform);
Map<String, Object> data = new TreeMap<>();
data.put("platform", platform);
data.put("actId", actId);
data.put("startIndex", startIndex);
data.put("size", size);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_VAL_LEADERBOARD_BY_ACT, data);
if (chl.isPresent()) {
return (Leaderboard) chl.get();
}
try {
Leaderboard match = (Leaderboard) builder.build();
data.put("value", match);
DataCall.getCacheProvider().store(URLEndpoint.V1_VAL_LEADERBOARD_BY_ACT, data);
return match;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.pojo.val.ranked.Leaderboard in project L4J8 by stelar7.
the class TestVALRanked method getLeaderboard.
@Test
public void getLeaderboard() {
R4J api = new R4J(SecretFile.CREDS);
VALRankedAPI ranked = api.getVALAPI().getRankedAPI();
Leaderboard leaderboard = ranked.getLeaderboard(ValorantShard.EU, Season.EPISODE_2_ACT_1.getActId(), 0, 200);
System.out.println(leaderboard);
}
Aggregations