Search in sources :

Example 1 with UseItemXpBoostResponse

use of POGOProtos.Networking.Responses.UseItemXpBoostResponseOuterClass.UseItemXpBoostResponse in project PokeGOAPI-Java by Grover-c13.

the class ItemBag method useLuckyEgg.

/**
 * use a lucky egg
 *
 * @return the xp boost response
 * @throws RequestFailedException if an exception occurred while sending requests
 */
public UseItemXpBoostResponse useLuckyEgg() throws RequestFailedException {
    UseItemXpBoostMessage xpMsg = UseItemXpBoostMessage.newBuilder().setItemId(ItemId.ITEM_LUCKY_EGG).build();
    ServerRequest req = new ServerRequest(RequestType.USE_ITEM_XP_BOOST, xpMsg);
    api.requestHandler.sendServerRequests(req, true);
    try {
        UseItemXpBoostResponse response = UseItemXpBoostResponse.parseFrom(req.getData());
        Log.i("Main", "Use incense result: " + response.getResult());
        return response;
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) UseItemXpBoostResponse(POGOProtos.Networking.Responses.UseItemXpBoostResponseOuterClass.UseItemXpBoostResponse) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest) UseItemXpBoostMessage(POGOProtos.Networking.Requests.Messages.UseItemXpBoostMessageOuterClass.UseItemXpBoostMessage)

Aggregations

UseItemXpBoostMessage (POGOProtos.Networking.Requests.Messages.UseItemXpBoostMessageOuterClass.UseItemXpBoostMessage)1 UseItemXpBoostResponse (POGOProtos.Networking.Responses.UseItemXpBoostResponseOuterClass.UseItemXpBoostResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1