use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class VALContentAPI method getContent.
public Content getContent(ValorantShard server, Optional<String> locale) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.REGION_PLACEHOLDER, server.name()).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getVALAPIKey()).withEndpoint(URLEndpoint.V1_VAL_CONTENT).withPlatform(server);
locale.ifPresent(s -> builder.withQueryParameter(Constants.LOCALE_PLACEHOLDER_DATA, s));
Map<String, Object> data = new TreeMap<>();
data.put("platform", server);
data.put("locale", locale.orElse("null"));
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_VAL_CONTENT, data);
if (chl.isPresent()) {
return (Content) chl.get();
}
try {
Object ret = builder.build();
Content cont = (Content) ret;
data.put("value", cont);
DataCall.getCacheProvider().store(URLEndpoint.V1_VAL_CONTENT, data);
return cont;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class VALRankedAPI method getLeaderboard.
public Leaderboard getLeaderboard(ValorantShard platform, String actId, int startIndex, int size) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.ACT_ID_PLACEHOLDER, actId).withQueryParameter(Constants.STARTINDEX_PLACEHOLDER_DATA, String.valueOf(startIndex)).withQueryParameter(Constants.SIZE_PLACEHOLDER_DATA, String.valueOf(size)).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getVALAPIKey()).withEndpoint(URLEndpoint.V1_VAL_LEADERBOARD_BY_ACT).withPlatform(platform);
Map<String, Object> data = new TreeMap<>();
data.put("platform", platform);
data.put("actId", actId);
data.put("startIndex", startIndex);
data.put("size", size);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_VAL_LEADERBOARD_BY_ACT, data);
if (chl.isPresent()) {
return (Leaderboard) chl.get();
}
try {
Leaderboard match = (Leaderboard) builder.build();
data.put("value", match);
DataCall.getCacheProvider().store(URLEndpoint.V1_VAL_LEADERBOARD_BY_ACT, data);
return match;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder 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;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder 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;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder 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;
}
}
Aggregations