Search in sources :

Example 11 with DataCallBuilder

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;
    }
}
Also used : GAMHSMatch(no.stelar7.api.r4j.pojo.shared.GAMHSMatch)

Example 12 with DataCallBuilder

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();
}
Also used : DataCallBuilder(no.stelar7.api.r4j.basic.calling.DataCallBuilder)

Example 13 with DataCallBuilder

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();
}
Also used : DataCallBuilder(no.stelar7.api.r4j.basic.calling.DataCallBuilder) JsonWriter(com.google.gson.stream.JsonWriter)

Example 14 with DataCallBuilder

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;
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner)

Example 15 with DataCallBuilder

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;
    }
}
Also used : VALMatch(no.stelar7.api.r4j.pojo.val.match.VALMatch)

Aggregations

DataCallBuilder (no.stelar7.api.r4j.basic.calling.DataCallBuilder)11 Optional (java.util.Optional)7 JsonWriter (com.google.gson.stream.JsonWriter)6 Field (java.lang.reflect.Field)4 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)4 Pair (no.stelar7.api.r4j.basic.utils.Pair)4 Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)4 GAMHSMatch (no.stelar7.api.r4j.pojo.shared.GAMHSMatch)4 Pair (no.stelar7.api.l4j8.basic.utils.Pair)3 PlatformData (no.stelar7.api.r4j.pojo.lol.status.PlatformData)3 ChampionMastery (no.stelar7.api.l4j8.pojo.championmastery.ChampionMastery)2 APIResponseException (no.stelar7.api.r4j.basic.exceptions.APIResponseException)2 ChampionRotationInfo (no.stelar7.api.r4j.pojo.lol.champion.ChampionRotationInfo)2 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)2 Match (no.stelar7.api.l4j8.pojo.match.Match)1 MatchTimeline (no.stelar7.api.l4j8.pojo.match.MatchTimeline)1 LanguageStrings (no.stelar7.api.l4j8.pojo.staticdata.language.LanguageStrings)1 Realm (no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)1 ShardStatus (no.stelar7.api.l4j8.pojo.status.ShardStatus)1 LanguageStrings (no.stelar7.api.r4j.pojo.lol.staticdata.language.LanguageStrings)1