private function parseResponse(ResponseInterface $response)
    {
        if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
            throw new ClientErrorException($response);
        }

        if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
            throw new ServerErrorException($response);
        }

        $response->getBody()->rewind();

        $result = json_decode($response->getBody()->getContents());

        if ($result === null) {
            throw InvalidResponseException::failedToDecodeResponse($response, json_last_error_msg());
        }

        return $result;
    }
private function parseResponse(ResponseInterface $response)
    {
        if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
            throw new ClientErrorException($response);
        }

        if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
            throw new ServerErrorException($response);
        }

        $response->getBody()->rewind();

        $result = json_decode($response->getBody()->getContents());

        if ($result === null) {
            throw InvalidResponseException::failedToDecodeResponse($response, json_last_error_msg());
        }

        return $result;
    }
private function parseResponse ( ResponseInterface $ response ) { if ( $ response -> getStatusCode ( ) >= 400 && $ response -> getStatusCode ( ) < 500 ) { throw new ClientErrorException ( $ response ) ; } if ( $ response -> getStatusCode ( ) >= 500 && $ response -> getStatusCode ( ) < 600 ) { throw new ServerErrorException ( $ response ) ; } $ response -> getBody ( ) -> rewind ( ) ; $ result = json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; if ( $ result === null ) { throw InvalidResponseException :: failedToDecodeResponse ( $ response , json_last_error_msg ( ) ) ; } return $ result ; }
Parse a response.

@param ResponseInterface $response The response to parse.

@throws ClientErrorException Thrown when a 4xx response status is returned.
@throws ServerErrorException Thrown when a 5xx response status is returned.
@throws InvalidResponseException Thrown when an invalid response body is encountered.

@return mixed
Parse a response .