public function getResponse( $type = self::RESPONSE_TYPE_JSON ) {
        // Check if response is set
        if ( $this->response === null ) {
            return null;
        }

        try {
            // Get the stream from the response getBody() method returns a stream instead of a string.
            $stream = $this->response->getBody();

            // Get the body from the stream.
            $body = $stream->getContents();

            if ( empty( $body ) ) {
                return null;
            }

            switch ( $type ) {
                default:
                case self::RESPONSE_TYPE_JSON:
                    return $this->getResponseJSON( $body );
                    break;
                case self::RESPONSE_TYPE_XML:
                    return (string) $body;
                    break;
                case self::RESPONSE_TYPE_HTML:
                    return (string) $body;
                    break;
                case self::RESPONSE_TYPE_TEXT:
                    return (string) $body;
                    break;
                case self::RESPONSE_ORIGINAL:
                    return $this->response;
                    break;
            }
        }
        catch ( BadResponseException $exception ) {
            return null;
        }
        catch ( \Exception $exception ) {
            return null;
        }
    }