use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class TimelineBuilder method get.
/**
* Returns the timeline relating to a match.
* Not avaliable for matches older than a year
*
* @return MatchTimeline if avaliable
*/
public MatchTimeline get() {
if (this.id == -1 || this.platform == Platform.UNKNOWN) {
return null;
}
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.MATCH_ID_PLACEHOLDER, String.valueOf(this.id)).withEndpoint(URLEndpoint.V3_TIMELINE).withPlatform(this.platform);
Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_TIMELINE, this.platform, this.id);
if (chl.isPresent()) {
return (MatchTimeline) chl.get();
}
try {
MatchTimeline timeline = (MatchTimeline) builder.build();
DataCall.getCacheProvider().store(URLEndpoint.V3_TIMELINE, timeline, this.platform, this.id);
return timeline;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class SummonerBuilder method get.
/**
* gets a summoner based on the parameters passed to the builder
*
* @return Summoner
*/
public Summoner get() {
DataCallBuilder builder = new DataCallBuilder().withPlatform(this.platform);
URLEndpoint endpoint = null;
if (accId > 0) {
builder.withURLParameter(Constants.ACCOUNT_ID_PLACEHOLDER, String.valueOf(this.accId));
endpoint = URLEndpoint.V3_SUMMONER_BY_ACCOUNT;
}
if (sumId > 0) {
builder.withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, String.valueOf(this.sumId));
endpoint = URLEndpoint.V3_SUMMONER_BY_ID;
}
if (name.length() > 0) {
builder.withURLParameter(Constants.SUMMONER_NAME_PLACEHOLDER, Utils.normalizeSummonerName(this.name));
endpoint = URLEndpoint.V3_SUMMONER_BY_NAME;
}
builder.withEndpoint(endpoint);
Optional chl = DataCall.getCacheProvider().get(endpoint, this.platform, this.accId, this.sumId, this.name);
if (chl.isPresent()) {
return (Summoner) chl.get();
}
Object sob = builder.build();
if (sob instanceof Pair) {
return null;
}
DataCall.getCacheProvider().store(endpoint, sob, this.platform, this.accId, this.sumId, this.name);
return (Summoner) sob;
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class StatusAPI method getShardStatus.
public PlatformData getShardStatus(LeagueShard server) {
DataCallBuilder builder = new DataCallBuilder().withEndpoint(URLEndpoint.V4_STATUS_LOL).withPlatform(server);
Map<String, Object> data = new TreeMap<>();
data.put("platform", server);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V4_STATUS_LOL, data);
if (chl.isPresent()) {
return (PlatformData) chl.get();
}
try {
PlatformData list = (PlatformData) builder.build();
data.put("value", list);
DataCall.getCacheProvider().store(URLEndpoint.V4_STATUS_LOL, data);
return list;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class StatusAPI method getShardStatus.
public PlatformData getShardStatus(ValorantShard server) {
DataCallBuilder builder = new DataCallBuilder().withEndpoint(URLEndpoint.V1_STATUS_VAL).withPlatform(server);
Map<String, Object> data = new TreeMap<>();
data.put("platform", server);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_STATUS_VAL, data);
if (chl.isPresent()) {
return (PlatformData) chl.get();
}
try {
PlatformData list = (PlatformData) builder.build();
data.put("value", list);
DataCall.getCacheProvider().store(URLEndpoint.V1_STATUS_VAL, data);
return list;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class TFTMatchAPI method getMatchRAW.
public GAMHSMatch getMatchRAW(RegionShard 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_TFT_MATCH).withPlatform(platform);
Map<String, Object> data = new TreeMap<>();
data.put("platform", platform);
data.put("gameid", gameId);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_MATCH, data);
if (chl.isPresent()) {
return (GAMHSMatch) chl.get();
}
try {
GAMHSMatch match = (GAMHSMatch) builder.build();
data.put("value", match);
DataCall.getCacheProvider().store(URLEndpoint.V1_TFT_MATCH, data);
return match;
} catch (ClassCastException e) {
return null;
}
}
Aggregations