Search in sources :

Example 1 with APIResponseException

use of no.stelar7.api.r4j.basic.exceptions.APIResponseException in project L4J8 by stelar7.

the class LCUApi method joinLobby.

/**
 * Joins the lobby with the specified id
 * <p>
 * returns true if lobby exists, and we are able to join
 * @param id the lobbyid
 * @return true if able to join
 */
public static boolean joinLobby(String id) {
    try {
        Pair<String, String> header = LCUConnection.getAuthorizationHeader();
        new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_LOBBY_JOIN).withURLParameter(Constants.ID_PLACEHOLDER, id).withRequestMethod("POST").withHeader(header.getKey(), header.getValue()).build();
        return true;
    } catch (APIResponseException e) {
        return false;
    }
}
Also used : DataCallBuilder(no.stelar7.api.r4j.basic.calling.DataCallBuilder) APIResponseException(no.stelar7.api.r4j.basic.exceptions.APIResponseException)

Example 2 with APIResponseException

use of no.stelar7.api.r4j.basic.exceptions.APIResponseException in project L4J8 by stelar7.

the class LiveClientDataAPI method getGameData.

public static ActiveGameData getGameData() {
    try {
        Object data = new DataCallBuilder().withLimiters(false).withProxy(Constants.CLIENT_PROXY).withEndpoint(URLEndpoint.LIVECLIENT_GAME_DATA).withRequestMethod("GET").build();
        if (data instanceof Pair) {
            return null;
        }
        JsonObject obj = ((JsonElement) data).getAsJsonObject();
        ActiveGameData returnMe = new ActiveGameData(Utils.getGson().fromJson(obj.get("activePlayer"), ActiveGameClientPlayer.class), Utils.getGson().fromJson(obj.get("allPlayers"), new TypeToken<List<ActiveGamePlayer>>() {
        }.getType()), parseEventObjectToList(obj.get("events")), Utils.getGson().fromJson(obj.get("gameData"), ActiveGameState.class));
        return returnMe;
    } catch (APIResponseException e) {
        return null;
    }
}
Also used : DataCallBuilder(no.stelar7.api.r4j.basic.calling.DataCallBuilder) APIResponseException(no.stelar7.api.r4j.basic.exceptions.APIResponseException)

Aggregations

DataCallBuilder (no.stelar7.api.r4j.basic.calling.DataCallBuilder)2 APIResponseException (no.stelar7.api.r4j.basic.exceptions.APIResponseException)2