Search in sources :

Example 1 with AddFortModifierMessage

use of POGOProtos.Networking.Requests.Messages.AddFortModifierMessageOuterClass.AddFortModifierMessage in project PokeGOAPI-Java by Grover-c13.

the class Pokestop method addModifierAsync.

/**
	 * Adds a modifier to this pokestop. (i.e. add a lure module)
	 *
	 * @param item the modifier to add to this pokestop
	 * @return true if success
	 */
public Observable<Boolean> addModifierAsync(ItemId item) {
    AddFortModifierMessage msg = AddFortModifierMessage.newBuilder().setModifierType(item).setFortId(getId()).setPlayerLatitude(api.getLatitude()).setPlayerLongitude(api.getLongitude()).build();
    ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.ADD_FORT_MODIFIER, msg);
    return api.getRequestHandler().sendAsyncServerRequests(serverRequest).map(new Func1<ByteString, Boolean>() {

        @Override
        public Boolean call(ByteString result) {
            try {
                //sadly the server response does not contain any information to verify if the request was
                // successful
                AddFortModifierResponseOuterClass.AddFortModifierResponse.parseFrom(result);
            } catch (InvalidProtocolBufferException e) {
                throw Exceptions.propagate(e);
            }
            return Boolean.TRUE;
        }
    });
}
Also used : ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) AddFortModifierMessage(POGOProtos.Networking.Requests.Messages.AddFortModifierMessageOuterClass.AddFortModifierMessage) ServerRequest(com.pokegoapi.main.ServerRequest)

Aggregations

AddFortModifierMessage (POGOProtos.Networking.Requests.Messages.AddFortModifierMessageOuterClass.AddFortModifierMessage)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1