public function request($options)
    {
        $request = $this->getRequest($options);
        $requestOptions = isset($options['query']) ? ['query' => $options['query']] : [];

        // Try to perform request
        try {
            $response = $this->httpClient->send($request, $requestOptions);
        } catch (GuzzleRequestException $err) {
            $hasResponse = $err->hasResponse();
            if (!$hasResponse) {
                // @todo how do we handle, wrap guzzle err
                throw $err;
            }

            $response = $err->getResponse();
            $code = $response->getStatusCode();

            if ($code >= 500) {
                throw new ServerException($response);
            } elseif ($code >= 400) {
                throw new ClientException($response);
            }
        }

        $contentType = $response->getHeader('Content-Type')[0];
        $isJson = stripos($contentType, 'application/json') !== false;
        $rawBody = (string) $response->getBody();
        $body = $isJson ? json_decode($rawBody, true) : $rawBody;

        return $body;
    }
public function request($options)
    {
        $request = $this->getRequest($options);
        $requestOptions = isset($options['query']) ? ['query' => $options['query']] : [];

        // Try to perform request
        try {
            $response = $this->httpClient->send($request, $requestOptions);
        } catch (GuzzleRequestException $err) {
            $hasResponse = $err->hasResponse();
            if (!$hasResponse) {
                // @todo how do we handle, wrap guzzle err
                throw $err;
            }

            $response = $err->getResponse();
            $code = $response->getStatusCode();

            if ($code >= 500) {
                throw new ServerException($response);
            } elseif ($code >= 400) {
                throw new ClientException($response);
            }
        }

        $contentType = $response->getHeader('Content-Type')[0];
        $isJson = stripos($contentType, 'application/json') !== false;
        $rawBody = (string) $response->getBody();
        $body = $isJson ? json_decode($rawBody, true) : $rawBody;

        return $body;
    }
public function request ( $ options ) { $ request = $ this -> getRequest ( $ options ) ; $ requestOptions = isset ( $ options [ 'query' ] ) ? [ 'query' => $ options [ 'query' ] ] : [ ] ; // Try to perform request try { $ response = $ this -> httpClient -> send ( $ request , $ requestOptions ) ; } catch ( GuzzleRequestException $ err ) { $ hasResponse = $ err -> hasResponse ( ) ; if ( ! $ hasResponse ) { // @todo how do we handle, wrap guzzle err throw $ err ; } $ response = $ err -> getResponse ( ) ; $ code = $ response -> getStatusCode ( ) ; if ( $ code >= 500 ) { throw new ServerException ( $ response ) ; } elseif ( $ code >= 400 ) { throw new ClientException ( $ response ) ; } } $ contentType = $ response -> getHeader ( 'Content-Type' ) [ 0 ] ; $ isJson = stripos ( $ contentType , 'application/json' ) !== false ; $ rawBody = ( string ) $ response -> getBody ( ) ; $ body = $ isJson ? json_decode ( $ rawBody , true ) : $ rawBody ; return $ body ; }
Performs a request against the Sanity API based on the passed options.

@param array $options Array of options for this request.
@return mixed Returns a decoded response, type varies with endpoint.
Performs a request against the Sanity API based on the passed options .