Search in sources :

Example 1 with GetInventoryMessage

use of POGOProtos.Networking.Requests.Messages.GetInventoryMessageOuterClass.GetInventoryMessage in project PokeGOAPI-Java by Grover-c13.

the class Inventories method updateInventories.

/**
	 * Updates the inventories with the latest data.
	 *
	 * @param forceUpdate For a full update if true
	 * @return the response to the update message
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
public GetInventoryResponse updateInventories(boolean forceUpdate) throws RequestFailedException {
    if (forceUpdate) {
        lastInventoryUpdate = 0;
        itemBag.reset();
        pokebank.reset();
        candyjar.reset();
        pokedex.reset();
        synchronized (this.lock) {
            incubators.clear();
        }
        hatchery.reset();
    }
    GetInventoryMessage invReqMsg = GetInventoryMessage.newBuilder().setLastTimestampMs(lastInventoryUpdate).build();
    ServerRequest inventoryRequest = new ServerRequest(RequestTypeOuterClass.RequestType.GET_INVENTORY, invReqMsg);
    api.getRequestHandler().sendServerRequests(inventoryRequest);
    GetInventoryResponse response;
    try {
        response = GetInventoryResponse.parseFrom(inventoryRequest.getData());
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
    return response;
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) GetInventoryMessage(POGOProtos.Networking.Requests.Messages.GetInventoryMessageOuterClass.GetInventoryMessage) ServerRequest(com.pokegoapi.main.ServerRequest) GetInventoryResponse(POGOProtos.Networking.Responses.GetInventoryResponseOuterClass.GetInventoryResponse)

Aggregations

GetInventoryMessage (POGOProtos.Networking.Requests.Messages.GetInventoryMessageOuterClass.GetInventoryMessage)1 GetInventoryResponse (POGOProtos.Networking.Responses.GetInventoryResponseOuterClass.GetInventoryResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1