use of POGOProtos.Networking.Requests.Messages.UpgradePokemonMessageOuterClass.UpgradePokemonMessage in project PokeGOAPI-Java by Grover-c13.
the class Pokemon method powerUpAsync.
/**
* Powers up a pokemon with candy and stardust.
* After powering up this pokemon object will reflect the new changes.
*
* @return The result
*/
public Observable<UpgradePokemonResponse.Result> powerUpAsync() {
UpgradePokemonMessage reqMsg = UpgradePokemonMessage.newBuilder().setPokemonId(getId()).build();
ServerRequest serverRequest = new ServerRequest(RequestType.UPGRADE_POKEMON, reqMsg);
return api.getRequestHandler().sendAsyncServerRequests(serverRequest, true).map(new Func1<ByteString, UpgradePokemonResponse.Result>() {
@Override
public UpgradePokemonResponse.Result call(ByteString result) {
UpgradePokemonResponse response;
try {
response = UpgradePokemonResponse.parseFrom(result);
} catch (InvalidProtocolBufferException e) {
throw Exceptions.propagate(e);
}
//set new pokemon details
applyProto(response.getUpgradedPokemon());
return response.getResult();
}
});
}
Aggregations