Creates a new Request with the given options

@param  string     $method
@param  array      $tokens
@param  array      $options
@param  DataSource $annotation
@return Request

@SuppressWarnings("PHPMD.StaticAccess")
351563
public function createOne($method, array $tokens, array $options, DataSource $annotation = null) {
        return new Request([
            'method'              => HttpMethod::create($method, $annotation),
            'url'                 => Url::createFromTokens($tokens, $options['host'], $annotation),
            'curlOptions'         => CurlOptions::create(array_merge($options['driverOptions'], HttpHeader::create($options['driverOptions'], $tokens))),
            'query'               => HttpQuery::create($tokens, $options['driverOptions']),
            'payload'             => Payload::create($tokens, $options),
            'expectedStatusCodes' => StatusCode::create($method, $annotation)
        ]);
    }
193802
public static function request($method, $uri = '', array $options = [], $origin = false)
    {
        $options = array_merge(['timeout' => 10, 'verify' => false], $options);

        $response = static::$client->request($method, $uri, $options);

        return $origin ? $response : $response->getBody()->getContents();
    }
1342406
public function send($method, $uri, array $options = [])
    {
        $this->calls[] = array('send', $method, $uri, $options);

        return new Response();
    }
450725
public static function createFromTokens(array $tokens, $apiUrl, DataSource $annotation = null) {
        $id    = Identifier::create($tokens);
        $route = empty($annotation) || $annotation->getRoute() === null ? Table::create($tokens) : $annotation->getRoute();

        return self::create($route, $apiUrl, $id);
    }
960953
public function request($method, $url, $options)
    {
        $request = $this->authClient->getAuthenticatedRequest($method, $url, $this->getAccessToken());

        return $this->httpClient->send($request, $options);
    }
1235684
public function request($method, array $params = [])
    {
        return new Request($this->endpoint, $this->secret, $method, $params);
    }
242918
public static function create(array $options, array $tokens) {
        $headers = empty($options['CURLOPT_HTTPHEADER']) ? [] : $options['CURLOPT_HTTPHEADER'];

        $headers = empty($headers) ? [] : $headers;
        $headers = is_string($headers) ? explode(',', $headers) : $headers;

        $headers = array_merge(
            $headers,
            // Send pagination headers if pagination is not sent as query params
            !isset($options['pagination_as_query']) || !$options['pagination_as_query'] ? PaginationHeaders::create($tokens) : [],
            OrderingHeaders::create($tokens)
        );
        return ['CURLOPT_HTTPHEADER'=>$headers];
    }
1120136
public function get($method, array $params, array $options = array())
    {
        $this->parseOptions($options);

        $params = array_merge($params, $this->apiKeys);

        $response = $this->httpAdapter->getContent(
            sprintf(self::API_ENDPOINT, $this->scheme, $this->outputFormat, $method .'?'. http_build_query($params)),
            $this->headers
        );

        return $this->responseHandler($response);
    }
531991
public function request($method, $url, $token, array $options = [])
    {
        $request = $this->getAuthenticatedRequest(
            $method, $url, $token, $options
        );

        return $this->getResponse($request);
    }
720754
protected static function _staticRequest($method, $url, $params, $options)
    {
        $opts = \Stripe\Util\RequestOptions::parse($options);
        $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
        $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
        list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
        $opts->discardNonPersistentHeaders();
        return [$response, $opts];
    }
516581
public static function useExisting(string $tokenString, array $options): Token
    {
        $token = new self($options);
        $token->token = $tokenString;

        return $token;
    }
476915
public function rawRequest($method, $uri, $options)
    {
        try {
            $response = $this->connection->request($method, $uri, $options);
            if ($response->getHeader('Content-Type')[0] == 'text/html') {
                throw new DirectAdminException(sprintf('DirectAdmin API returned text/html to %s %s containing "%s"', $method, $uri, strip_tags($response->getBody()->getContents())));
            }
            $body = $response->getBody()->getContents();
            return Conversion::responseToArray($body);
        } catch (TransferException $exception) {
            // Rethrow anything that causes a network issue
            throw new DirectAdminException(sprintf('%s request to %s failed', $method, $uri), 0, $exception);
        }
    }
1357776
public function requestAsync($method, $url, $options)
    {
        $request = $this->authClient->getAuthenticatedRequest($method, $url, $this->getAccessToken());

        return $this->httpClient->sendAsync($request, $options);
    }
182792
protected function executeOAuth2($method, $ressource, array $params = array())
	{
		$this->headers['authorization'] = sprintf('Authorization: Bearer %s', $this->getAccessToken());
		// We don't need auth since we are using an access token
		$this->enableAuth = false;
		try
		{
			$result = $this->execute($method, $ressource, $params);
			$this->enableAuth = true;
			return $result;
		}
		catch(Exception $e)
		{
			$this->enableAuth = true;
			throw $e;
		}
	}
168208
public function da_request(string $method, string $uri = '', array $options = []): array
    {
        $this->lastRequest = microtime(true);
        
        try {
            $response = $this->request($method, $uri, $options);
        }
        catch(\Exception $e) {
            
            if($e instanceof RequestException) {
                throw new DirectAdminRequestException(sprintf('DirectAdmin %s %s request failed.', $method, $uri));
            }
            
            if($e instanceof TransferException) {
                throw new DirectAdminTransferException(sprintf('DirectAdmin %s %s transfer failed.', $method, $uri));
            }
        }
        
        if($response->getHeader('Content-Type')[0] === 'text/html') {
            throw new DirectAdminBadContentException(sprintf('DirectAdmin %s %s returned text/html.', $method, $uri));
        }

        $body = $response->getBody()->getContents();

        return $this->responseToArray($body);
    }
591590
public function executeRequest($method, $url, $token, $body = null)
    {
        $options = [];
        if ($body) {
            $options['body'] = json_encode($body);
            $options['headers']['Content-Type'] = 'application/json';
        }

        $request = $this->getAuthenticatedRequest($method, $this->apiDomain.'/'.$this->version.$url, $token, $options);

        return $this->getParsedResponse($request);
    }
1330799
public function request($method, $uri = null, array $options = [], $asJson = true)
    {
        $response = parent::request($method, $uri, $options);

        if ($response->getStatusCode() !== 200) {
            ErrorHandler::handleErrorResponse($response);
        }

        if ($asJson) {
            return json_decode($response->getBody(), true);
        }

        return $response->getBody()->getContents();
    }