Search in sources :

Example 1 with ChampionRotationInfo

use of no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo in project L4J8 by stelar7.

the class ChampionBuilder method getFreeToPlayRotation.

public ChampionRotationInfo getFreeToPlayRotation() {
    if (this.platform == LeagueShard.UNKNOWN) {
        return null;
    }
    DataCallBuilder builder = new DataCallBuilder().withEndpoint(URLEndpoint.V3_CHAMPION_ROTATIONS).withPlatform(this.platform);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", this.platform);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V3_CHAMPION_ROTATIONS, data);
    if (chl.isPresent()) {
        return (ChampionRotationInfo) chl.get();
    }
    try {
        ChampionRotationInfo cl = (ChampionRotationInfo) builder.build();
        data.put("value", cl);
        DataCall.getCacheProvider().store(URLEndpoint.V3_CHAMPION_ROTATIONS, data);
        return cl;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : ChampionRotationInfo(no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo)

Example 2 with ChampionRotationInfo

use of no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo in project L4J8 by stelar7.

the class ChampionAPI method getFreeToPlayRotation.

public ChampionRotationInfo getFreeToPlayRotation(LeagueShard server) {
    DataCallBuilder builder = new DataCallBuilder().withEndpoint(URLEndpoint.V3_CHAMPION_ROTATIONS).withPlatform(server);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", server);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V3_CHAMPION_ROTATIONS, data);
    if (chl.isPresent()) {
        return (ChampionRotationInfo) chl.get();
    }
    try {
        ChampionRotationInfo cl = (ChampionRotationInfo) builder.build();
        data.put("value", cl);
        DataCall.getCacheProvider().store(URLEndpoint.V3_CHAMPION_ROTATIONS, data);
        return cl;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : ChampionRotationInfo(no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo)

Aggregations

ChampionRotationInfo (no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo)2