private function curlRequest($requestUrl, $method, $path, $params, $limit, $offset)
    {
        $curl = curl_init();

        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_USERAGENT, $this->getUserAgent());
        curl_setopt($curl, CURLOPT_HTTPHEADER, $this->getHeaders($path));
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);

        $headers = [];
        curl_setopt($curl, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$headers) {
            if (stripos($header, 'X-Plenty') === false) {
                return strlen($header);
            }

            $name = substr($header, 0, strpos($header, ':'));
            $value = substr($header, strpos($header, ':') + 1);

            $headers[$name] = (int) trim($value);

            return strlen($header);
        });

        if (null !== $limit) {
            $params['itemsPerPage'] = (int) $limit;
        }

        if (null !== $offset) {
            $params['page'] = $this->getPage($limit, $offset);
        }

        $method = strtoupper($method);
        if ($method === 'POST') {
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params, JSON_PRETTY_PRINT));
        } elseif ($method === 'GET') {
            $requestUrl = $requestUrl . '?' . http_build_query($params);
        }

        curl_setopt($curl, CURLOPT_URL, $requestUrl);

        $response = curl_exec($curl);
        $info = curl_getinfo($curl);
        $errno = curl_errno($curl);

        if ($errno !== CURLE_OK) {
            throw new RuntimeException('curl client error:' . $errno);
        }

        $this->handeRateLimits($headers);

        if ($info['http_code'] === 401) {
            throw new LoginExpiredException();
        }

        if ($info['http_code'] === 200) {
            $json = json_decode($response, true);

            if (json_last_error() !== JSON_ERROR_NONE) {
                throw InvalidResponseException::fromParams(
                    $method,
                    $path,
                    $params
                );
            }

            return $json;
        }

        throw new RuntimeException('client error');
    }
private function curlRequest($requestUrl, $method, $path, $params, $limit, $offset)
    {
        $curl = curl_init();

        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_USERAGENT, $this->getUserAgent());
        curl_setopt($curl, CURLOPT_HTTPHEADER, $this->getHeaders($path));
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);

        $headers = [];
        curl_setopt($curl, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$headers) {
            if (stripos($header, 'X-Plenty') === false) {
                return strlen($header);
            }

            $name = substr($header, 0, strpos($header, ':'));
            $value = substr($header, strpos($header, ':') + 1);

            $headers[$name] = (int) trim($value);

            return strlen($header);
        });

        if (null !== $limit) {
            $params['itemsPerPage'] = (int) $limit;
        }

        if (null !== $offset) {
            $params['page'] = $this->getPage($limit, $offset);
        }

        $method = strtoupper($method);
        if ($method === 'POST') {
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params, JSON_PRETTY_PRINT));
        } elseif ($method === 'GET') {
            $requestUrl = $requestUrl . '?' . http_build_query($params);
        }

        curl_setopt($curl, CURLOPT_URL, $requestUrl);

        $response = curl_exec($curl);
        $info = curl_getinfo($curl);
        $errno = curl_errno($curl);

        if ($errno !== CURLE_OK) {
            throw new RuntimeException('curl client error:' . $errno);
        }

        $this->handeRateLimits($headers);

        if ($info['http_code'] === 401) {
            throw new LoginExpiredException();
        }

        if ($info['http_code'] === 200) {
            $json = json_decode($response, true);

            if (json_last_error() !== JSON_ERROR_NONE) {
                throw InvalidResponseException::fromParams(
                    $method,
                    $path,
                    $params
                );
            }

            return $json;
        }

        throw new RuntimeException('client error');
    }
@param string $requestUrl
@param string $method
@param string $path
@param array  $params
@param int    $limit
@param int    $offset

@return array