public function handleRequest(string $method, string $uri = '', array $options = [], array $parameters = [])
    {
        // Are we going a GET or a POST?
        if (!empty($parameters)) {
            if ($method === 'GET') {
                // Send as get params
                $options['query'] = $parameters;
            }
            if ($method === 'POST' || $method === 'PATCH' || $method === 'DELETE') {
                // Otherwise send JSON in the body
                $options['json'] = (object)$parameters;
            }
        }

        // Let's go
        try {
            $response = $this->client->request($method, $uri, $options);

            // All good
            return json_decode($response->getBody(), true);
        } catch (RequestException $exception) {
            $message = $exception->getMessage();

            throw new ApiException($message, $exception->getCode(), $exception);
        }
    }
public function handleRequest(string $method, string $uri = '', array $options = [], array $parameters = [])
    {
        // Are we going a GET or a POST?
        if (!empty($parameters)) {
            if ($method === 'GET') {
                // Send as get params
                $options['query'] = $parameters;
            }
            if ($method === 'POST' || $method === 'PATCH' || $method === 'DELETE') {
                // Otherwise send JSON in the body
                $options['json'] = (object)$parameters;
            }
        }

        // Let's go
        try {
            $response = $this->client->request($method, $uri, $options);

            // All good
            return json_decode($response->getBody(), true);
        } catch (RequestException $exception) {
            $message = $exception->getMessage();

            throw new ApiException($message, $exception->getCode(), $exception);
        }
    }
public function handleRequest ( string $ method , string $ uri = '' , array $ options = [ ] , array $ parameters = [ ] ) { // Are we going a GET or a POST? if ( ! empty ( $ parameters ) ) { if ( $ method === 'GET' ) { // Send as get params $ options [ 'query' ] = $ parameters ; } if ( $ method === 'POST' || $ method === 'PATCH' || $ method === 'DELETE' ) { // Otherwise send JSON in the body $ options [ 'json' ] = ( object ) $ parameters ; } } // Let's go try { $ response = $ this -> client -> request ( $ method , $ uri , $ options ) ; // All good return json_decode ( $ response -> getBody ( ) , true ) ; } catch ( RequestException $ exception ) { $ message = $ exception -> getMessage ( ) ; throw new ApiException ( $ message , $ exception -> getCode ( ) , $ exception ) ; } }
Makes a request using Guzzle

@param string $method The HTTP request method (GET/POST/etc)
@param string $uri The resource
@param array $options Request options
@param array $parameters Request parameters

@see RequestHandler::request()

@return array
@throws ApiException
Makes a request using Guzzle