@param string $uri
@param string $body
@param array  $options

@return HandlerInterfaceException|HandlerInterfaceSuccess
328997
public function patch($uri, $body = null, array $options = [])
    {
        return $this->request(self::REQUEST_METHOD_PATCH, $uri, $body, $options);
    }
908683
public function request($url, $method = 'GET', $options = [])
    {
        $method = strtoupper($method);

        $options = array_merge(self::$defaults, $options);

        Log::debug('Client Request:', compact('url', 'method', 'options'));

        $options['handler'] = $this->getHandler();

        if (property_exists($this, 'baseUri') && !is_null($this->baseUri)) {
            $options['base_uri'] = $this->baseUri;
        }

        $response = $this->getClient()->request($method, $url, $options);

        Log::debug('API response:', [
            'Status' => $response->getStatusCode(),
            'Reason' => $response->getReasonPhrase(),
            'Headers' => $response->getHeaders(),
            'Body' => strval($response->getBody()),
        ]);

        return $response;
    }
79810
public function send($method, $uri, $body = null, array $query = [], array $headers = [], array $options = [])
    {
        $this->validateMethod($method);

        $query = array_merge($this->getDefaultQuery(), $query);
        $headers = array_merge($this->getDefaultHeaders(), $headers);

        $this->lastResponse = $this->client->send($method, $uri, $body, $query, $headers, $options);

        $this->validateResponse($this->lastResponse);

        return $this->lastResponse;
    }
1065871
public function sendRequestAsync($type, $uri, $options = null)
    {
        $request = null;
        switch ($type) {
            case 'GET':
                $request = $this->oauthRequestClient
                    ->getAsync($uri, $options);
                break;
            case 'POST':
                $request = $this->oauthRequestClient
                    ->postAsync($uri, $options);
                break;
            case 'DELETE':
                $request = $this->oauthRequestClient
                    ->deleteAsync($uri, $options);
                break;
            default :
                throw new Exception("The request type you entered is not valid.");
                break;
        }
        return $request->then(
            function (ResponseInterface $response) {
                $contentType = self::checkResponseContentType($response->getHeader('Content-Type'));
                switch ($contentType) {
                    case 'json':
                        return json_decode($response->getBody(), true);
                        break;
                    case 'string':
                        return (string)$response->getBody();
                        break;
                    case 'html':
                        return $response;
                        break;
                    default:
                        // If we don't know the response type but it was a successful request, it's probably okay.
                        if($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
                            return $response;
                        }
                        throw new Exception("The response type not recognized.");
                }
            }
        );
    }
865085
protected function createContext($method, array $options, $body)
	{
		$contextOptions = [
			'ssl'  => ['verify_peer' => $this->sslVerifyPeer],
			'http' => [
				'method'  => $method,
				'timeout' => $this->timeout,
				'header'  => $this->generateHeaders($options, $body),
				'content' => $body
			]
		];

		return stream_context_create($contextOptions);
	}
266284
public function get($uri, array $options = null)
    {
        return $this->request(self::REQUEST_METHOD_GET, $uri, null, $options);
    }
377561
public function perform($action, $table, $body, $options = [])
    {
        $query = $this->createQuery($action, $table, $options)->body($body);

        return $this->createRequest($query);
    }
117473
private function processMethod($method, array $options, array $headers, array $body = [])
    {
        if ($method === 'get') {
            if ($body !== []) {
                throw new \Exception('Issuing a GET request with a body');
            }
            $options[CURLOPT_HTTPGET] = 1;
        } elseif ($method === 'post') {
            $data_string = json_encode($body);

            $options[CURLOPT_POST] = 1;
            $options[CURLOPT_POSTFIELDS] = $data_string;

            array_push($headers, 'Content-Type: application/json');
            array_push($headers, 'Content-Length: ' . strlen($data_string));
        } else {
            throw new \Exception('Unrecognized method ' . strtoupper($method));
        }

        return [$options, $headers];
    }
399714
public function patch($uri, $params = null, $body = null)
    {
        return $this->performRequest("patch", $uri, $params, $body);
    }
311157
public function post($uri, array $headers = [], $body = null)
    {
        return $this->send('POST', $uri, $headers, $body);
    }
939699
public function setBody(RequestInterface $request, $body, $options)
    {
        return RequestHandler::setBody($request, $body, $options);
    }
267105
public function createRequest(string $method, string $uri, array $body = []): RequestInterface
    {
        $request = $this->requestFactory->createRequest($method, $uri)
            ->withHeader('Content-Type', 'application/json')
            ->withHeader('Authorization', 'Token ' . $this->token)
            ->withHeader('X-Secret', $this->secret)
        ;

        if (!empty($body)) {
            $request = $request
                ->withBody($this->streamFactory->createStream(json_encode($body, JSON_UNESCAPED_UNICODE)))
            ;
        }

        return $request;
    }
1312516
public function post($url, $body = [], $headers = [], $options = [])
    {
        return $this->request('POST', $url, $body, $headers, $options);
    }
12976
private function _request($method, $url, array $options) {
		try {
			$response = $this->httpClient->{$method}($url, $options);
		} catch(ClientException $e) {
			$response = $e->getResponse();
		} catch(ConnectException $e) {
			$this->_throwServerError($e);
		} catch (RequestException $e) {
			$this->_throwServerError($e);
		}

		return $response;
	}
277892
public function requestAsync($method, $uri = null, array $options = [])
    {
        $options = $this->setRequestOptions($options);

        $query = parse_url($uri, PHP_URL_QUERY);
        if (!empty($query)) {
            $uri = substr($uri, 0, (strlen($query)+1) * -1);
            parse_str($query, $options['query']);
        }

        return parent::requestAsync($method, $uri, $options);
    }
553761
public function getData($uri, $options = [])
    {
        return json_decode($this->request('GET', $uri, $options)->getBody()->getContents());
    }
1013690
public function get($uri, array $headers = [], $body = null)
    {
        return $this->send(new \GuzzleHttp\Psr7\Request('GET', $uri, $headers, $body));
    }