public function makeRequest($method, $url, $body = null, $headers = null, $retryOnLimit = false)
    {
        $channel = curl_init($url);

        $options = $this->createCurlOptions($method, $body, $headers);

        curl_setopt_array($channel, $options);
        $content = curl_exec($channel);

        $response = $this->parseResponse($channel, $content);

        if ($response->statusCode() === self::TOO_MANY_REQUESTS_HTTP_CODE && $retryOnLimit) {
            $responseHeaders = $response->headers(true);
            return $this->retryRequest($responseHeaders, $method, $url, $body, $headers);
        }

        curl_close($channel);

        return $response;
    }
public function makeRequest($method, $url, $body = null, $headers = null, $retryOnLimit = false)
    {
        $channel = curl_init($url);

        $options = $this->createCurlOptions($method, $body, $headers);

        curl_setopt_array($channel, $options);
        $content = curl_exec($channel);

        $response = $this->parseResponse($channel, $content);

        if ($response->statusCode() === self::TOO_MANY_REQUESTS_HTTP_CODE && $retryOnLimit) {
            $responseHeaders = $response->headers(true);
            return $this->retryRequest($responseHeaders, $method, $url, $body, $headers);
        }

        curl_close($channel);

        return $response;
    }
public function makeRequest ( $ method , $ url , $ body = null , $ headers = null , $ retryOnLimit = false ) { $ channel = curl_init ( $ url ) ; $ options = $ this -> createCurlOptions ( $ method , $ body , $ headers ) ; curl_setopt_array ( $ channel , $ options ) ; $ content = curl_exec ( $ channel ) ; $ response = $ this -> parseResponse ( $ channel , $ content ) ; if ( $ response -> statusCode ( ) === self :: TOO_MANY_REQUESTS_HTTP_CODE && $ retryOnLimit ) { $ responseHeaders = $ response -> headers ( true ) ; return $ this -> retryRequest ( $ responseHeaders , $ method , $ url , $ body , $ headers ) ; } curl_close ( $ channel ) ; return $ response ; }
Make the API call and return the response.
This is separated into it's own function, so we can mock it easily for testing.

@param string $method       the HTTP verb
@param string $url          the final url to call
@param array  $body         request body
@param array  $headers      any additional request headers
@param bool   $retryOnLimit should retry if rate limit is reach?

@return Response object
Make the API call and return the response . This is separated into it s own function so we can mock it easily for testing .