Search in sources :

Example 1 with GymGetInfoMessage

use of POGOProtos.Networking.Requests.Messages.GymGetInfoMessageOuterClass.GymGetInfoMessage in project PokeGOAPI-Java by Grover-c13.

the class Gym method details.

private GymGetInfoResponse details() throws RequestFailedException {
    List<TutorialState> tutorialStates = api.playerProfile.getTutorialState().getTutorialStates();
    if (!tutorialStates.contains(TutorialState.GYM_TUTORIAL)) {
        api.playerProfile.visitGymComplete();
    }
    if (details == null) {
        GymGetInfoMessage reqMsg = GymGetInfoMessage.newBuilder().setGymId(this.getId()).setGymLatDegrees(this.getLatitude()).setGymLngDegrees(this.getLongitude()).setPlayerLatDegrees(api.latitude).setPlayerLngDegrees(api.longitude).build();
        ServerRequest serverRequest = new ServerRequest(RequestType.GYM_GET_INFO, reqMsg);
        api.requestHandler.sendServerRequests(serverRequest, true);
        try {
            details = GymGetInfoResponse.parseFrom(serverRequest.getData());
        } catch (InvalidProtocolBufferException e) {
            throw new RequestFailedException();
        }
    }
    return details;
}
Also used : GymGetInfoMessage(POGOProtos.Networking.Requests.Messages.GymGetInfoMessageOuterClass.GymGetInfoMessage) RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest) TutorialState(POGOProtos.Enums.TutorialStateOuterClass.TutorialState)

Aggregations

TutorialState (POGOProtos.Enums.TutorialStateOuterClass.TutorialState)1 GymGetInfoMessage (POGOProtos.Networking.Requests.Messages.GymGetInfoMessageOuterClass.GymGetInfoMessage)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1