Search in sources :

Example 46 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner 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 47 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner 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 48 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner 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)

Aggregations

Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)33 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)19 SpectatorBuilder (no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)15 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)13 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)9 R4J (no.stelar7.api.r4j.impl.R4J)7 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)5 Optional (java.util.Optional)4 ChampionMasteryBuilder (no.stelar7.api.r4j.impl.lol.builders.championmastery.ChampionMasteryBuilder)4 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)4 java.util (java.util)3 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)3 L4J8 (no.stelar7.api.l4j8.impl.L4J8)3 MatchListBuilder (no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)3 JsonWriter (com.google.gson.stream.JsonWriter)2 java.awt (java.awt)2 AffineTransform (java.awt.geom.AffineTransform)2 java.awt.image (java.awt.image)2 java.io (java.io)2 URL (java.net.URL)2