@param $path
@param array $parameters
@param array $requestHeaders

@throws Exception

@return array|string
559618
protected function post($path, array $parameters = [], $requestHeaders = [])
    {
        $path = $this->preparePath($path);

        $body = null;
        if (!empty($parameters)) {
            $body = $this->streamFactory->createStream(QueryStringBuilder::build($parameters));
            $requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
        }

        try {
            $response = $this->client->getHttpClient()->post($path, $requestHeaders, $body);
        } catch (HttpException $e) {
            (new ApiExceptionHandler($e))->handle();
        }

        return ResponseFormatter::getContent($response);
    }
2434
public static function get($url, $headers = [], $parameters = null)
    {
        return Request::create('default')->get($url, $headers, $parameters);
    }
1313895
public function get($path, array $options = array())
    {
        $client = $this->createGuzzleClient($this->consumerKey, $this->consumerSecret);

        $options['auth'] = 'oauth';

        try {
            return json_decode($client->get('/1.1'.$path, $options)->getBody(), true);
        } catch (GuzzleRequestException $e) {
            $message = $e->getMessage();

            if ($e->hasResponse()) {
                $responseData = json_decode($e->getResponse()->getBody(), true);

                $messageParts = array();

                foreach ($responseData['errors'] as $error) {
                    $messageParts[] = $error['message'];
                }

                $message = implode($messageParts, "\n");
            }

            throw new RequestException($message);
        }
    }
1328613
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{

		$request = $this->requestFactory
			->createRequest($method ?? 'GET', Psr7\merge_query($this->apiURL.$path, $params ?? []));

		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
			$request = $request->withAddedHeader($header, $value);
		}

		if(is_array($body) && $request->hasHeader('content-type')){
			$contentType = strtolower($request->getHeaderLine('content-type'));

			// @todo: content type support
			if($contentType === 'application/x-www-form-urlencoded'){
				$body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
			}
			elseif($contentType === 'application/json'){
				$body = $this->streamFactory->createStream(json_encode($body));
			}

		}

		if($body instanceof StreamInterface){
			$request = $request
				->withBody($body)
				->withHeader('Content-length', $body->getSize())
			;
		}

		return $this->sendRequest($request);
	}
868946
protected function executeRequest(array $httpHeaders, $requestUrl, $httpMethod, $payload)
    {
        $result = [];

        $ch = curl_init($requestUrl);
        curl_setopt_array($ch, [
            CURLOPT_HTTPHEADER => $httpHeaders,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => 0,
        ]);

        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);

        // Only send payload data for methods that need it.
        if ($payload instanceof Payload) {
            // Send payload data as a JSON string
            curl_setopt($ch, CURLOPT_POSTFIELDS, $payload->getPayloadJSON());
        }

        // Set response data
        $result['response'] = curl_exec($ch);
        // Set response code
        $result['http_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        // Check if any related Curl error occurred.
        if (curl_error($ch)) {
            throw new RequestException(curl_error($ch));
        }

        // Close the session
        curl_close($ch);

        return $result;
    }
762115
public function api($path, array $parameters = array(), $method = 'GET')
    {
        return $this->getRequest()->api($path, $method, $parameters);
    }
549840
protected function httpGet(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface
    {
        if (count($parameters) > 0) {
            $path .= '?'.http_build_query($parameters);
        }

        try {
            $response = $this->httpClient->sendRequest(
                $this->requestBuilder->create('GET', $path, $requestHeaders)
            );
        } catch (Psr18\NetworkExceptionInterface $e) {
            throw HttpServerException::networkError($e);
        }

        return $response;
    }
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);
    }
811502
protected function getAsResponse($path, array $parameters = array(), $requestHeaders = array())
    {
        $path = $this->preparePath($path, $parameters);

        return $this->client->getHttpClient()->get($path, $requestHeaders);
    }
772656
public function createRequest($httpMethod, $path, $body = null, array $headers = array(), array $options = array())
    {
        $version = (isset($options['api_version']) ? "/".$options['api_version'] : "");

        $path    = $version.$path;

        return $this->client->createRequest($httpMethod, $path, $headers, $body, $options);
    }
876147
private function get($path, $params = null, $headers = null)
    {
        return $this->run($path, array('method' => 'get', 'params' => $params, 'headers' => $headers));
    }
815057
public function delete($path, array $parameters = [], array $requestHeaders = [])
    {
        $response = $this->getHttpClient()->delete($path, $requestHeaders, $this->createJsonBody($parameters));

        return ResponseMediator::getContent($response);
    }
469961
public function request($path, $body, $httpMethod = 'GET', array $headers = [], array $options = [])
	{
		$request = $this->createRequest($httpMethod, $path, $body, $headers);

		try {
			$response = $this->client->send($request, $options);
		} catch (\LogicException $e) {
			throw new \ErrorException($e->getMessage(), $e->getCode(), $e);
		} catch (\RuntimeException $e) {
			throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
		}

		$this->lastRequest  = $request;
		$this->lastResponse = $response;

		return $response;
	}
148504
private function sendRequest($httpMethod, array $varArgs, $requestPath = '/')
    {
        $defaultArgs = array(
            'config' => array(),
            'body' => null,
            'headers' => array(),
            'params' => array(),
        );

        $args = array_merge($defaultArgs, $varArgs);
        if (empty($args['config'])) {
            $config = $this->config;
        } else {
            $config = array_merge(
                array(),
                $this->config,
                $args['config']
            );
        }
        if (!isset($args['headers'][HttpHeaders::CONTENT_TYPE])) {
            $args['headers'][HttpHeaders::CONTENT_TYPE] = HttpContentTypes::JSON;
        }
        $path = $this->prefix . $requestPath;
        $response = $this->httpClient->sendRequest(
            $config,
            $httpMethod,
            $path,
            $args['body'],
            $args['headers'],
            $args['params'],
            $this->signer
        );

        $result = $this->parseJsonResult($response['body']);
        $result->metadata = $this->convertHttpHeadersToMetadata($response['headers']);
        return $result;
    }
1290443
public function get($path, array $parameters)
    {
        try {
    	    $response = $this->client->request('GET', $path, [
    	        'query' => $parameters
    	    ]);

            return $this->toArray($response);
    	}
    	catch (ClientException $e) {
    	    return $this->toArray($e->getResponse());
    	}
    }
1254586
protected function post($path, array $parameters = array(), $requestHeaders = array())
    {
        return $this->postRaw(
            $path,
            $this->createParametersBody($parameters),
            $requestHeaders
        );
    }
762691
public function head($path, array $parameters = [], array $requestHeaders = []): ResponseInterface
    {
        if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) {
            unset($parameters['ref']);
        }
        $response = $this->getHttpClient()->head($path . '?' . http_build_query($parameters), $requestHeaders);

        return $response;
    }