use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class LORMatchAPI method getMatchRAW.
public GAMHSMatch getMatchRAW(RuneterraShard platform, String gameId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.MATCH_ID_PLACEHOLDER, gameId).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey()).withEndpoint(URLEndpoint.V1_LOR_MATCH).withPlatform(platform);
Map<String, Object> data = new TreeMap<>();
data.put("platform", platform);
data.put("gameid", gameId);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_LOR_MATCH, data);
if (chl.isPresent()) {
return (GAMHSMatch) chl.get();
}
try {
GAMHSMatch match = (GAMHSMatch) builder.build();
data.put("value", match);
DataCall.getCacheProvider().store(URLEndpoint.V1_LOR_MATCH, data);
return match;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class DDragonAPI method getLanguageStrings.
public Map<String, String> getLanguageStrings(String version, String locale) {
DataCallBuilder builder = new DataCallBuilder().withLimiters(false).withProxy(Constants.DDRAGON_PROXY).withEndpoint(URLEndpoint.DDRAGON_LANGUAGE_STRINGS);
builder.withURLParameter(Constants.VERSION_PLACEHOLDER, version == null ? getVersions().get(0) : version);
builder.withURLParameter(Constants.LOCALE_PLACEHOLDER, locale == null ? "en_US" : locale);
Map<String, Object> data = new TreeMap<>();
data.put("version", version);
data.put("locale", locale);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.DDRAGON_LANGUAGE_STRINGS, data);
if (chl.isPresent()) {
return ((LanguageStrings) chl.get()).getData();
}
try {
Object ret = builder.build();
if (ret instanceof Pair) {
return Collections.emptyMap();
}
LanguageStrings list = (LanguageStrings) ret;
data.put("value", list);
DataCall.getCacheProvider().store(URLEndpoint.DDRAGON_LANGUAGE_STRINGS, data);
return list.getData();
} catch (ClassCastException e) {
return Collections.emptyMap();
}
}
Aggregations