Search in sources :

Example 1 with Leaderboard

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;
    }
}
Also used : Leaderboard(no.stelar7.api.r4j.pojo.val.ranked.Leaderboard)

Example 2 with Leaderboard

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);
}
Also used : Leaderboard(no.stelar7.api.r4j.pojo.val.ranked.Leaderboard) VALRankedAPI(no.stelar7.api.r4j.impl.val.VALRankedAPI) R4J(no.stelar7.api.r4j.impl.R4J) Test(org.junit.jupiter.api.Test)

Aggregations

Leaderboard (no.stelar7.api.r4j.pojo.val.ranked.Leaderboard)2 R4J (no.stelar7.api.r4j.impl.R4J)1 VALRankedAPI (no.stelar7.api.r4j.impl.val.VALRankedAPI)1 Test (org.junit.jupiter.api.Test)1