Search in sources :

Example 6 with LeagueShard

use of no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard in project L4J8 by stelar7.

the class StatusAPI method getShardStatus.

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

Example 7 with LeagueShard

use of no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard in project L4J8 by stelar7.

the class TFTSummonerAPI method getSummonerByPUUID.

/**
 * The response object contains the summoner objects mapped by their username.
 *
 * @param server the region to execute against
 * @param PUUID  puuid associated with summoner to retrieve.
 * @return Optional Summoner
 */
public Summoner getSummonerByPUUID(final LeagueShard server, String PUUID) {
    DataCallBuilder builder = new DataCallBuilder().withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey()).withURLParameter(Constants.PUUID_ID_PLACEHOLDER, PUUID).withEndpoint(URLEndpoint.V1_TFT_SUMMONER_BY_PUUID).withPlatform(server);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", server);
    data.put("puuid", PUUID);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_SUMMONER_BY_PUUID, data);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        data.put("value", summoner);
        DataCall.getCacheProvider().store(URLEndpoint.V1_TFT_SUMMONER_BY_PUUID, data);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner)

Example 8 with LeagueShard

use of no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard in project L4J8 by stelar7.

the class TFTSummonerAPI method getSummonerByAccount.

/**
 * The response object contains the summoner objects mapped by their username.
 *
 * @param server    the region to execute against
 * @param accountId accountId associated with summoner to retrieve.
 * @return Optional Summoner
 */
public Summoner getSummonerByAccount(final LeagueShard server, String accountId) {
    DataCallBuilder builder = new DataCallBuilder().withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey()).withURLParameter(Constants.ACCOUNT_ID_PLACEHOLDER, accountId).withEndpoint(URLEndpoint.V1_TFT_SUMMONER_BY_ACCOUNT).withPlatform(server);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", server);
    data.put("accountid", accountId);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_SUMMONER_BY_ACCOUNT, data);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        data.put("value", summoner);
        DataCall.getCacheProvider().store(URLEndpoint.V1_TFT_SUMMONER_BY_ACCOUNT, data);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner)

Example 9 with LeagueShard

use of no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard in project L4J8 by stelar7.

the class TFTSummonerAPI method getSummonerByName.

/**
 * The response object contains the summoner objects mapped by their username.
 *
 * @param server       the region to execute against
 * @param summonerName summoner name  associated with summoner to retrieve.
 * @return Optional Summoner
 */
public Summoner getSummonerByName(final LeagueShard server, String summonerName) {
    DataCallBuilder builder = new DataCallBuilder().withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey()).withURLParameter(Constants.SUMMONER_NAME_PLACEHOLDER, Utils.normalizeString(summonerName)).withEndpoint(URLEndpoint.V1_TFT_SUMMONER_BY_NAME).withPlatform(server);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", server);
    data.put("name", summonerName);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_SUMMONER_BY_NAME, data);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        data.put("value", summoner);
        DataCall.getCacheProvider().store(URLEndpoint.V1_TFT_SUMMONER_BY_NAME, data);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner)

Example 10 with LeagueShard

use of no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard in project L4J8 by stelar7.

the class DDragonAPI method getRealm.

public Realm getRealm(LeagueShard region) {
    DataCallBuilder builder = new DataCallBuilder().withLimiters(false).withProxy(Constants.DDRAGON_PROXY).withURLParameter(Constants.REGION_PLACEHOLDER, region.getRealmValue()).withEndpoint(URLEndpoint.DDRAGON_REALMS);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", region);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.DDRAGON_REALMS, data);
    if (chl.isPresent()) {
        return (Realm) chl.get();
    }
    try {
        Realm list = (Realm) builder.build();
        data.put("value", list);
        DataCall.getCacheProvider().store(URLEndpoint.DDRAGON_REALMS, data);
        return list;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Realm(no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm)

Aggregations

Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)5 LeagueShard (no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard)2 Field (java.lang.reflect.Field)1 Pair (no.stelar7.api.r4j.basic.utils.Pair)1 R4J (no.stelar7.api.r4j.impl.R4J)1 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)1 ChampionRotationInfo (no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo)1 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)1 StaticChampion (no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion)1 Realm (no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm)1 PlatformData (no.stelar7.api.r4j.pojo.lol.status.PlatformData)1 Test (org.junit.jupiter.api.Test)1