public function request($path, $method, $rawData = null, $params = [])
    {
        $method  = strtoupper($method);
        $path    = ltrim($path, '/');
        $path    = $path . '.' . $this->format;
        $client  = $this->getHttpClient();
        $method  = strtoupper($method);
        $options = [
            'query' => $params,
            'body' => null,
        ];

        $request = new Request($method, $path);

        if (in_array($method, array('POST', 'PUT'))) {
            if (null === $rawData) {
                throw new BadMethodCallException('You must send raw data in a POST or PUT request');
            }
        }

        if (!empty($rawData)) {
            $options['body'] = Psr7\stream_for($rawData);
        }

        try {
            $response = $client->send($request, $options);
        } catch (RequestException $e) {
            if ($e->hasResponse()) {
                $response = $e->getResponse();
            } else {
                $response = false;
            }
        }

        $this->lastResponse = $response;

        return $response;
    }
public function request($path, $method, $rawData = null, $params = [])
    {
        $method  = strtoupper($method);
        $path    = ltrim($path, '/');
        $path    = $path . '.' . $this->format;
        $client  = $this->getHttpClient();
        $method  = strtoupper($method);
        $options = [
            'query' => $params,
            'body' => null,
        ];

        $request = new Request($method, $path);

        if (in_array($method, array('POST', 'PUT'))) {
            if (null === $rawData) {
                throw new BadMethodCallException('You must send raw data in a POST or PUT request');
            }
        }

        if (!empty($rawData)) {
            $options['body'] = Psr7\stream_for($rawData);
        }

        try {
            $response = $client->send($request, $options);
        } catch (RequestException $e) {
            if ($e->hasResponse()) {
                $response = $e->getResponse();
            } else {
                $response = false;
            }
        }

        $this->lastResponse = $response;

        return $response;
    }
public function request ( $ path , $ method , $ rawData = null , $ params = [ ] ) { $ method = strtoupper ( $ method ) ; $ path = ltrim ( $ path , '/' ) ; $ path = $ path . '.' . $ this -> format ; $ client = $ this -> getHttpClient ( ) ; $ method = strtoupper ( $ method ) ; $ options = [ 'query' => $ params , 'body' => null , ] ; $ request = new Request ( $ method , $ path ) ; if ( in_array ( $ method , array ( 'POST' , 'PUT' ) ) ) { if ( null === $ rawData ) { throw new BadMethodCallException ( 'You must send raw data in a POST or PUT request' ) ; } } if ( ! empty ( $ rawData ) ) { $ options [ 'body' ] = Psr7 \ stream_for ( $ rawData ) ; } try { $ response = $ client -> send ( $ request , $ options ) ; } catch ( RequestException $ e ) { if ( $ e -> hasResponse ( ) ) { $ response = $ e -> getResponse ( ) ; } else { $ response = false ; } } $ this -> lastResponse = $ response ; return $ response ; }
Send the request to Chargify

@param string $path   URL path we are requesting such as: /subscriptions/<subscription_id>/adjustments
@param string $method GET, POST, PUT, DELETE
@param string $rawData
@param array  $params

@return Response|FALSE Response object or FALSE if there was no response (networking error, timeout, etc.)
Send the request to Chargify