use of POGOProtos.Networking.Requests.Messages.FortDeployPokemonMessageOuterClass.FortDeployPokemonMessage in project PokeGOAPI-Java by Grover-c13.
the class Gym method deployPokemon.
/**
* Deploy pokemon
*
* @param pokemon The pokemon to deploy
* @return Result of attempt to deploy pokemon
* @throws RequestFailedException if an exception occurred while sending requests
*/
public FortDeployPokemonResponse.Result deployPokemon(Pokemon pokemon) throws RequestFailedException {
FortDeployPokemonMessage reqMsg = FortDeployPokemonMessage.newBuilder().setFortId(getId()).setPlayerLatitude(api.latitude).setPlayerLongitude(api.longitude).setPokemonId(pokemon.getId()).build();
ServerRequest serverRequest = new ServerRequest(RequestType.FORT_DEPLOY_POKEMON, reqMsg);
api.requestHandler.sendServerRequests(serverRequest, true);
try {
return FortDeployPokemonResponse.parseFrom(serverRequest.getData()).getResult();
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException();
}
}
use of POGOProtos.Networking.Requests.Messages.FortDeployPokemonMessageOuterClass.FortDeployPokemonMessage in project PokeGOAPI-Java by Grover-c13.
the class Gym method deployPokemonAsync.
/**
* Deploy pokemon
*
* @param pokemon The pokemon to deploy
* @return Result of attempt to deploy pokemon
* @throws RequestFailedException if an exception occurred while sending requests
*/
public Observable<FortDeployPokemonResponse.Result> deployPokemonAsync(Pokemon pokemon) throws RequestFailedException {
FortDeployPokemonMessage reqMsg = FortDeployPokemonMessage.newBuilder().setFortId(getId()).setPlayerLatitude(api.latitude).setPlayerLongitude(api.longitude).setPokemonId(pokemon.getId()).build();
ServerRequest asyncServerRequest = new ServerRequest(RequestType.FORT_DEPLOY_POKEMON, reqMsg);
return api.requestHandler.sendAsyncServerRequests(asyncServerRequest).map(new Func1<ByteString, FortDeployPokemonResponse.Result>() {
@Override
public FortDeployPokemonResponse.Result call(ByteString response) {
try {
return FortDeployPokemonResponse.parseFrom(response).getResult();
} catch (InvalidProtocolBufferException e) {
throw Exceptions.propagate(e);
}
}
});
}
Aggregations