Search in sources :

Example 1 with FortDetailsMessage

use of POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage in project PokeGOAPI-Java by Grover-c13.

the class Pokestop method getDetailsAsync.

/**
	 * Get more detailed information about a pokestop.
	 *
	 * @return FortDetails
	 */
public Observable<FortDetails> getDetailsAsync() {
    FortDetailsMessage reqMsg = FortDetailsMessage.newBuilder().setFortId(getId()).setLatitude(getLatitude()).setLongitude(getLongitude()).build();
    ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.FORT_DETAILS, reqMsg);
    return api.getRequestHandler().sendAsyncServerRequests(serverRequest, true).map(new Func1<ByteString, FortDetails>() {

        @Override
        public FortDetails call(ByteString result) {
            FortDetailsResponseOuterClass.FortDetailsResponse response = null;
            try {
                response = FortDetailsResponseOuterClass.FortDetailsResponse.parseFrom(result);
            } catch (InvalidProtocolBufferException e) {
                throw Exceptions.propagate(e);
            }
            return new FortDetails(response);
        }
    });
}
Also used : FortDetailsMessage(POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest)

Example 2 with FortDetailsMessage

use of POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage in project PokeGOAPI-Java by Grover-c13.

the class Fort method getDetailsAsync.

/**
 * Get more detailed information about a pokestop.
 *
 * @return FortDetails
 */
public Observable<FortDetails> getDetailsAsync() {
    FortDetailsMessage reqMsg = FortDetailsMessage.newBuilder().setFortId(getId()).setLatitude(getLatitude()).setLongitude(getLongitude()).build();
    ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.FORT_DETAILS, reqMsg);
    return api.requestHandler.sendAsyncServerRequests(serverRequest, true).map(new Func1<ByteString, FortDetails>() {

        @Override
        public FortDetails call(ByteString result) {
            FortDetailsResponseOuterClass.FortDetailsResponse response = null;
            try {
                response = FortDetailsResponseOuterClass.FortDetailsResponse.parseFrom(result);
            } catch (InvalidProtocolBufferException e) {
                throw Exceptions.propagate(e);
            }
            return new FortDetails(response);
        }
    });
}
Also used : FortDetailsMessage(POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest)

Aggregations

FortDetailsMessage (POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage)2 ByteString (com.google.protobuf.ByteString)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ServerRequest (com.pokegoapi.main.ServerRequest)2