use of POGOProtos.Networking.Responses.SetFavoritePokemonResponseOuterClass.SetFavoritePokemonResponse in project PokeGOAPI-Java by Grover-c13.
the class Pokemon method setFavoritePokemon.
/**
* Function to mark the pokemon as favorite or not.
*
* @param markFavorite Mark Pokemon as Favorite?
* @return the SetFavoritePokemonResponse.Result
* @throws RequestFailedException if an exception occurred while sending requests
*/
public SetFavoritePokemonResponse.Result setFavoritePokemon(boolean markFavorite) throws RequestFailedException {
SetFavoritePokemonMessage reqMsg = SetFavoritePokemonMessage.newBuilder().setPokemonId(getId()).setIsFavorite(markFavorite).build();
ServerRequest serverRequest = new ServerRequest(RequestType.SET_FAVORITE_POKEMON, reqMsg);
api.getRequestHandler().sendServerRequests(serverRequest, true);
SetFavoritePokemonResponse response;
try {
response = SetFavoritePokemonResponse.parseFrom(serverRequest.getData());
if (response.getResult() == SetFavoritePokemonResponse.Result.SUCCESS) {
favorite = markFavorite ? 1 : 0;
}
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
api.getInventories().getPokebank().removePokemon(this);
return response.getResult();
}
Aggregations