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;
}
}
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;
}
}
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;
}
}
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");
}
Aggregations