@param string $path
@param array  $params
@param string $method
@param null   $body
@param array  $headers

@return \Psr\Http\Message\ResponseInterface
1963
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{

		parse_str(parse_url($this->apiURL.$path, PHP_URL_QUERY), $query);

		$query['v'] = $this::API_VERSIONDATE;
		$query['m'] = 'foursquare';

		return parent::request(explode('?', $path)[0], array_merge($params ?? [], $query), $method, $body, $headers);
	}
708656
private function getResponse($method, $path, $body = null, $headers = [])
    {
        $allHeaders = array_merge($this->getAuthorizationHeader(), $headers);
        $uri = $path;

        $request = new Request($method, $uri, $allHeaders, $body);

        return $this->guzzle->send($request);
    }
891582
protected function makeHttpRequest($url, $method, $headers, $body = null) {
    $request_headers = array_merge($headers, self::$api_version_header);

    $result = $this->doHttpRequest($url,
                                   $method,
                                   $request_headers,
                                   $body);

    if ($result === false) {
      return false;
    }

    return [
      'status_code' => $result['status_code'],
      'headers' => $result['headers'],
      'body' => $result['body'],
    ];
  }
762115
public function api($path, array $parameters = array(), $method = 'GET')
    {
        return $this->getRequest()->api($path, $method, $parameters);
    }
318079
private function getResponse($method, $path, $parameters)
    {
        try {
            $response = $this->adapter->request($method, $path, $parameters);
            return $this->getResult($response);
        }
        catch (\Exception $e) {
            return $e->getMessage();
        }
    }
413296
private function request(string $method, string $path, array $query = [], $body = null): string
    {
        // Prepare request:
        $query = build_query($query);
        $body = $this->parseBody($body);
        $path = trim($path, '/');
        $request = new Request(
            $method,
            "{$this->baseUri}/v3/$path/?$query",
            ['Content-Type' => 'application/json'],
            $body
        );

        return (string) $this->query($request)->getBody();
    }
1291085
protected function post($path, array $parameters = array(), $body = array())
    {
        if (count($parameters) > 0) {
            $path .= '?' . http_build_query($parameters);
        }

        $body = json_encode($body);

        $response = $this->client->getHttpClient()->post($path, [], $body);

        return $this->parseResponse($response);
    }
728180
public function requestAsync($method, $url, $body = [], $query = [], $headers = [])
    {
        if (!empty($body)) {
            $body = encode($body);
            $headers['Content-Type'] = 'application/json';
        } else {
            $body = null;
        }

        $headers = array_merge($this->global_headers, $headers);

        return $this->client->requestAsync($method, $url, [
            'query'   => $query,
            'body'    => $body,
            'headers' => $headers,
        ]);
    }
693365
protected function sendRequest($method, $url, array $params = [], array $headers = [])
    {
        $response = $request = $this->getHttpClient()->createRequest()
            ->setUrl($url)
            ->setMethod($method)
            ->setHeaders($headers)
            ->setData($params)
            ->send();
        if (!$response->isOk && $this->debug) {
            throw new Exception ('Http request failed.');
        }
        return $response;
    }
348941
private function logRequestParams($path, $method, $queryParams, $httpBody, $headers)
    {
        if ($this->logger !== null) {
            $message = 'Send request: '.$method.' '.$path;
            if (!empty($queryParams)) {
                $message .= ' with query params: '.json_encode($queryParams);
            }
            if (!empty($httpBody)) {
                $message .= ' with body: '.$httpBody;
            }
            if (!empty($headers)) {
                $message .= ' with headers: '.json_encode($headers);
            }
            $this->logger->info($message);
        }
    }
1016212
protected function _restserver($path, $method = 'GET', $params = array(), $getParams = array()) {
        $this->container = null;
        if ($this->debug) { $start = microtime(true); }
        if (is_array($method) && empty($params)) {
            $params = $method;
            $method = 'GET';
        }
        $getParams['method'] = $method; // method override as we always do a POST
        $uri = $this->getUrl('api', $path);
        $result = $this->_oauthRequest($uri, $params, $getParams);

        if (floatval($this->api_version) >= 2) {
            $container = json_decode($result, true);
            if ($container && array_key_exists('name', $container) && $container['name'] == 'SPP Container') {
                $this->container = $container;
            }
        }

        preg_match("/\.(json|jsonp|html|xml|serialize|php|csv|tgz)$/", $path, $matches);
        if ($matches) {
            switch ($matches[1]) {
                case 'json':
                    $result = json_decode($result, true);
                    break;
                default:
                    if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; }
                    return $result;
                    break;
            }
        } else
            $result = json_decode($result, true);

        // results are returned, errors are thrown
        if (is_array($result) && isset($result['error']) && $result['error']) {
            $e = new VGS_Client_Exception($result, $this->raw);
            switch ($e->getType()) {
                case 'ApiException':
                    break;
                // OAuth 2.0 Draft 00 style
                case 'OAuthException':
                    // OAuth 2.0 Draft 10 style
                case 'invalid_token':
                    $this->setSession(null);
            }
            throw $e;
        }
        if (floatval($this->api_version) >= 2 && $result && is_array($result) && array_key_exists('name', $result) && $result['name'] == 'SPP Container') {
            if (isset($result['sig']) && isset($result['algorithm'])) {
                $result = $this->validateAndDecodeSignedRequest($result['sig'], $result['data'], $result['algorithm']);
            } else {
                $result = $result['data'];
            }
        }
        if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; }
        return $result;
    }
1250184
protected function _do_request($method, $path, $headers = NULL, $body= NULL, $file_handle= NULL) {/*{{{*/
        $uri = "/{$this->_bucketname}{$path}";
        $ch = curl_init("http://{$this->endpoint}{$uri}");

        $_headers = array('Expect:');
        if (!is_null($headers) && is_array($headers)){
            foreach($headers as $k => $v) {
                array_push($_headers, "{$k}: {$v}");
            }
        }

        $length = 0;
		$date = gmdate('D, d M Y H:i:s \G\M\T');

        if (!is_null($body)) {
            if(is_resource($body)){
                fseek($body, 0, SEEK_END);
                $length = ftell($body);
                fseek($body, 0);

                array_push($_headers, "Content-Length: {$length}");
                curl_setopt($ch, CURLOPT_INFILE, $body);
                curl_setopt($ch, CURLOPT_INFILESIZE, $length);
            } else {
                $length = @strlen($body);
                array_push($_headers, "Content-Length: {$length}");
                curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
            }
        } else {
            array_push($_headers, "Content-Length: {$length}");
        }

        array_push($_headers, "Authorization: {$this->sign($method, $uri, $date, $length)}");
        array_push($_headers, "Date: {$date}");

        curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers);
        curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);

        if ($method == 'PUT' || $method == 'POST') {
			curl_setopt($ch, CURLOPT_POST, 1);
        } else {
			curl_setopt($ch, CURLOPT_POST, 0);
        }

        if ($method == 'GET' && is_resource($file_handle)) {
            curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_setopt($ch, CURLOPT_FILE, $file_handle);
        }

        if ($method == 'HEAD') {
            curl_setopt($ch, CURLOPT_NOBODY, true);
        }

        $response = curl_exec($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);


        if ($http_code == 0) throw new UpYunException('Connection Failed', $http_code);

        curl_close($ch);

        $header_string = '';
        $body = '';

        if ($method == 'GET' && is_resource($file_handle)) {
            $header_string = '';
            $body = $response;
        } else {
            list($header_string, $body) = explode("\r\n\r\n", $response, 2);
        }
        $this->setXRequestId($header_string);
        if ($http_code == 200) {
            if ($method == 'GET' && is_null($file_handle)) {
                return $body;
            } else {
                $data = $this->_getHeadersData($header_string);
                return count($data) > 0 ? $data : true;
            }
        } else {
            $message = $this->_getErrorMessage($header_string);
            if (is_null($message) && $method == 'GET' && is_resource($file_handle)) {
                $message = 'File Not Found';
            }
            switch($http_code) {
                case 401:
                    throw new UpYunAuthorizationException($message);
                    break;
                case 403:
                    throw new UpYunForbiddenException($message);
                    break;
                case 404:
                    throw new UpYunNotFoundException($message);
                    break;
                case 406:
                    throw new UpYunNotAcceptableException($message);
                    break;
                case 503:
                    throw new UpYunServiceUnavailable($message);
                    break;
                default:
                    throw new UpYunException($message, $http_code);
            }
        }
    }
639841
public function request($method, $url, $params = null, $version = null, $headers = null)
    {
        $params = $params ?: [];
        $headers = $headers ?: [];
        if ($this->accessToken && $this->tokenType === 'Bearer') {
            $headers['Authorization'] = 'Bearer ' . $this->accessToken;
        }

        $payloadType = strcasecmp($method, 'get') === 0 ? 'query' : 'json';
        $client = $this->httpClient();

        if (!$this->noVersion) {
            $url = Sumup::getApiVersion() . '/' . $url;
        }

        try {
            $response = $client->request($method, $url, [
                $payloadType => $params,
                'headers' => $headers,
                'http_errors' => false
            ]);
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            throw new Error\ApiRequestorError($e->getMessage());
        }

        return new ApiResponse($response);
    }
1252433
protected function performRequest($method, $path, array $params)
	{
		/* Combine given parameters with persistent parameters and convert to string values. */
		$params = array_map('strval', $params + $this->persistent_params);

		$params = $this->signRequest($path, $params, $this->getAppSecret());
		$result = $this->doRequest($method, $path, $params);

		$this->logRequest($method, $path, $params, $result);

        /* See if there were cURL errors */
        if (empty($result["body"])) {
            throw new Mollie_Exception($result["message"], $result["code"]);
        }
        $object = $this->convertResponseBodyToObject($result['body'], $result['content_type']);

        if ($object instanceof Mollie_Response) {
            $this->checkResultErrors($object);
        }

        return $object;
    }
117200
private function send($path, $method, array $parameters = [], array $headers = [], $body = null)
    {
        $request = $this->createRequest($path, $method, $parameters, $headers, $body);

        $event = new RequestEvent($request);
        $this->eventDispatcher->dispatch(GoogleMoviesClientEvents::REQUEST, $event);

        $this->lastResponse = $event->getResponse();

        if ($this->lastResponse instanceof Response) {
            return (string) $this->lastResponse->getBody();
        }

        return [];
    }
991958
protected function postRaw($path, $body, $requestHeaders = array())
    {
        $response = $this->client->getHttpClient()->post(
            $path,
            $body,
            $requestHeaders
        );

        return ResponseMediator::getContent($response);
    }
470451
public function request($url, $method = 'GET', $headers = [], $body = null, $options = [])
    {
        if (false === is_array($options)) {
            $options = [];
        }

        $request = $this->getGuzzleClient()->createRequest($method, $url, $options);

        $request->addHeaders($headers);
        $request->setBody($body);

        $response = $this->getGuzzleClient()->send($request);

        return [
            'code'    => $response->getStatusCode(),
            'headers' => $response->getHeaders(),
            'body'    => (string)$response->getBody(),
        ];
    }