use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class TimelineBuilder method getTimelineRAW.
public GAMHSMatch getTimelineRAW() {
if (this.id.isEmpty() || this.platform == RegionShard.UNKNOWN) {
return null;
}
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.MATCH_ID_PLACEHOLDER, this.id).withEndpoint(URLEndpoint.V5_TIMELINE).withPlatform(this.platform);
Map<String, Object> data = new TreeMap<>();
data.put("platform", platform);
data.put("matchId", this.id);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V5_TIMELINE, data);
if (chl.isPresent()) {
return (GAMHSMatch) chl.get();
}
try {
GAMHSMatch timeline = (GAMHSMatch) builder.build();
data.put("value", timeline);
DataCall.getCacheProvider().store(URLEndpoint.V5_TIMELINE, data);
return timeline;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class LCUApi method restart.
/**
* Restarts the client after waitTimeout seconds
* @param waitTimeout the time to wait in seconds
*/
public static void restart(int waitTimeout) {
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_RESTART).withHeader(header.getKey(), header.getValue()).withQueryParameter("delaySeconds", String.valueOf(waitTimeout)).withRequestMethod("POST").build();
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class LCUApi method inviteSummoner.
/**
* Invites the summoner to your game
* @param name the name
*/
public static void inviteSummoner(String name) {
StringWriter sw = new StringWriter();
try {
JsonWriter jw = new JsonWriter(sw);
JsonObject obj = getSummoner(name);
jw.beginArray().beginObject().name("toSummonerId").value(obj.get("summonerId").getAsString()).name("toSummonerName").value(obj.get("internalName").getAsString()).endObject().endArray();
} catch (IOException e) {
e.printStackTrace();
}
String postData = sw.toString();
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
JsonArray obj = (JsonArray) new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_LOBBY_INVITE).withRequestMethod("POST").withHeader(header.getKey(), header.getValue()).withPostData(postData).build();
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class TFTSummonerAPI 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 LeagueShard server, String summonerId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, summonerId).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey()).withEndpoint(URLEndpoint.V1_TFT_SUMMONER_BY_ID).withPlatform(server);
Map<String, Object> data = new TreeMap<>();
data.put("platform", server);
data.put("id", summonerId);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_SUMMONER_BY_ID, 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_ID, data);
return summoner;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.basic.calling.DataCallBuilder in project L4J8 by stelar7.
the class VALMatchAPI method getMatch.
public VALMatch getMatch(ValorantShard platform, String gameId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.MATCH_ID_PLACEHOLDER, gameId).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getVALAPIKey()).withEndpoint(URLEndpoint.V1_VAL_MATCH_BY_ID).withPlatform(platform);
Map<String, Object> data = new TreeMap<>();
data.put("platform", platform);
data.put("gameid", gameId);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_VAL_MATCH_BY_ID, data);
if (chl.isPresent()) {
return (VALMatch) chl.get();
}
try {
VALMatch match = (VALMatch) builder.build();
data.put("value", match);
DataCall.getCacheProvider().store(URLEndpoint.V1_VAL_MATCH_BY_ID, data);
return match;
} catch (ClassCastException e) {
return null;
}
}
Aggregations