Search in sources :

Example 6 with Platform

use of no.stelar7.api.l4j8.basic.constants.api.Platform in project L4J8 by stelar7.

the class SummonerAPI 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 Platform server, String summonerName) {
    DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_NAME_PLACEHOLDER, Utils.normalizeSummonerName(summonerName)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_NAME).withPlatform(server);
    Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_NAME, server, "", "", summonerName);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_NAME, summoner, server, "", "", summonerName);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) Optional(java.util.Optional)

Example 7 with Platform

use of no.stelar7.api.l4j8.basic.constants.api.Platform in project L4J8 by stelar7.

the class SummonerAPI 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 Platform server, long accountId) {
    DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.ACCOUNT_ID_PLACEHOLDER, String.valueOf(accountId)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_ACCOUNT).withPlatform(server);
    Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_ACCOUNT, server, accountId);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_ACCOUNT, summoner, server, accountId);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) Optional(java.util.Optional)

Example 8 with Platform

use of no.stelar7.api.l4j8.basic.constants.api.Platform in project L4J8 by stelar7.

the class SummonerAPI method getSummonerById.

/**
 * The response object contains the summoner objects mapped by their user id.
 *
 * @param server     the region to execute against
 * @param summonerId summonerId associated with summoners to retrieve.
 * @return Optional Summoner
 */
public Summoner getSummonerById(final Platform server, long summonerId) {
    DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, String.valueOf(summonerId)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_ID).withPlatform(server);
    Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_ID, server, "", summonerId);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_ID, summoner, server, "", summonerId);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) Optional(java.util.Optional)

Example 9 with Platform

use of no.stelar7.api.l4j8.basic.constants.api.Platform in project L4J8 by stelar7.

the class ImageAPI method buildImageURL.

private String buildImageURL(@Nullable String version, String path, String file, @Nullable Platform rreg) {
    Platform region = rreg;
    if (region == null) {
        region = Platform.EUW1;
    }
    Realm realm = StaticAPI.getInstance().getRealm(region);
    String cdn = realm.getCDN();
    String versionString = version != null ? version : realm.getV();
    String preReplace = cdn + Constants.SEPARATOR + versionString + Constants.SEPARATOR + path + Constants.SEPARATOR + file;
    return preReplace.replace(" ", "%20");
}
Also used : Realm(no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)

Aggregations

Optional (java.util.Optional)4 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)3 Pair (no.stelar7.api.l4j8.basic.utils.Pair)2 Realm (no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)2 Field (java.lang.reflect.Field)1 ChampionMastery (no.stelar7.api.l4j8.pojo.championmastery.ChampionMastery)1 LanguageStrings (no.stelar7.api.l4j8.pojo.staticdata.language.LanguageStrings)1 ShardStatus (no.stelar7.api.l4j8.pojo.status.ShardStatus)1