Search in sources :

Example 1 with GetPlayerProfileMessage

use of POGOProtos.Networking.Requests.Messages.GetPlayerProfileMessageOuterClass.GetPlayerProfileMessage in project PokeGOAPI-Java by Grover-c13.

the class PlayerProfile method getProfile.

/**
	 * Performs a GET_PLAYER_PROFILE request.
	 *
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
public void getProfile() throws RequestFailedException {
    GetPlayerProfileMessage profileMessage = GetPlayerProfileMessage.newBuilder().setPlayerName("").build();
    ServerRequest profileRequest = new ServerRequest(RequestType.GET_PLAYER_PROFILE, profileMessage);
    api.getRequestHandler().sendServerRequests(profileRequest, true);
    try {
        GetPlayerProfileResponse response = GetPlayerProfileResponse.parseFrom(profileRequest.getData());
        if (response.getResult() == GetPlayerProfileResponse.Result.SUCCESS) {
            medals.clear();
            List<PlayerBadge> badges = response.getBadgesList();
            for (PlayerBadge badge : badges) {
                medals.put(badge.getBadgeType(), new Medal(badge));
            }
            this.startTime = response.getStartTime();
        }
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : GetPlayerProfileMessage(POGOProtos.Networking.Requests.Messages.GetPlayerProfileMessageOuterClass.GetPlayerProfileMessage) RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest) GetPlayerProfileResponse(POGOProtos.Networking.Responses.GetPlayerProfileResponseOuterClass.GetPlayerProfileResponse) PlayerBadge(POGOProtos.Data.PlayerBadgeOuterClass.PlayerBadge)

Aggregations

PlayerBadge (POGOProtos.Data.PlayerBadgeOuterClass.PlayerBadge)1 GetPlayerProfileMessage (POGOProtos.Networking.Requests.Messages.GetPlayerProfileMessageOuterClass.GetPlayerProfileMessage)1 GetPlayerProfileResponse (POGOProtos.Networking.Responses.GetPlayerProfileResponseOuterClass.GetPlayerProfileResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1