Log the beginning of a request.

@param string $request
@param string $endpoint
@param string $method
@param string $reference

@return IEvent
768375
public function begin($request, $endpoint, $method, $reference)
    {
        $this->startTimestamp = microtime(true);

        $this->lastEvent = $this->eventFactory->create($request, $endpoint, $method, $reference);

        return $this->adapter->save($this->lastEvent);
    }
62537
private function createRequest($method = 'GET', $endpoint, $body = null, array $params = [], array $headers = [])
    {
        // Add default json headers to the request
        $headers = array_merge($headers, [
            'Accept' => 'application/json',
            'Content-Type' => 'application/json',
        ]);

        // If access token is not set or token has expired, acquire new token
        if (empty($this->accessToken)) {
            $this->acquireAccessToken();
        }

        // If we have a token, sign the request
        if (! empty($this->accessToken)) {
            $headers['Authorization'] = 'Bearer ' . $this->accessToken;
        }

        // Create param string
        if (! empty($params)) {
            $endpoint .= '?' . http_build_query($params);
        }

        // Create the request
        $request = new Request($method, $endpoint, $headers, $body);

        return $request;
    }
1227306
protected function sendRequest($method, $endpoint, $data = null)
    {
        return $this->httpClient->request(
            $method,
            $this->getEndpoint() . $endpoint,
            $this->getHeaders(),
            $data
        );
    }
1301182
public function request($method, $endpoint, array $params = array(), $isVault = false)
    {
        return $this->doRequest($method, $endpoint, $params, $isVault);
    }
1325862
private static function makeEndpointsFromString($endpoint, $methods)
    {
        return collect($methods)->map(function ($method) use ($endpoint) {
            return [$method => $endpoint];
        })->collapse();
    }
400218
private function executeFacebookRequest($method, $endpoint, array $parameters = [], $token = null)
    {
        if (is_callable($this->logCallback)) {
            //used only for debugging:
            call_user_func($this->logCallback, 'Facebook API request', func_get_args());
        }

        if (!$token) {
            $token = $this->appToken;
        }

        switch ($method) {
            case 'GET':
                $response = $this->fb->get($endpoint, $token);
                break;
            case 'POST':
                $response = $this->fb->post($endpoint, $parameters, $token);
                break;
            case 'DELETE':
                $response = $this->fb->delete($endpoint, $parameters, $token);
                break;
            default:
                throw new \Exception("Facebook driver exception, please add support for method: " . $method);
                break;
        }

        if (is_callable($this->logCallback)) {
            call_user_func($this->logCallback, 'Facebook API response', $response->getDecodedBody());
        }

        return $response;
    }
595600
public function fireOnSendingRequest(HttpRequest $request)
    {
        $event = EnumEvent::REQUEST;
        if (isset($this->listeners[$event]) && is_array($this->listeners[$event]))
        {
            foreach($this->listeners[$event] as $l)
            {
                $ret = $l($request);
                if ($ret instanceof HttpRequest){
                    $request = $ret;
                }
            }
        }
        return $request;
    }
749443
public function request(Client $client, $endpoint, $options, $method = 'GET')
    {
        try {
            return $client->request($method, $endpoint, [
                'form_params' => $options,
            ]);
        } catch (ClientException $exception) {
            static::throwException(static::extractOriginalExceptionMessage($exception), $exception);
        }
    }
766877
public static function request($endpoint)
  {
    return (new Request(NULL, NULL, NULL))->host($endpoint)->get()->path('')->accept('application/json');
  }
1007577
public function request($method, $endpoint, array $params = [])
    {
        return new DmmRequest(
            $this->credential,
            $method,
            $endpoint,
            $params
        );
    }
975053
function makeRequest(string $method, string $endpoint, array $options) {
        $request = new \CharlotteDunois\Yasmin\HTTP\APIRequest($this, $method, $endpoint, $options);
        return $this->add($request);
    }
528729
public function sendRequest($method, $endPoint, $data = '')
    {
        $data = json_encode($data);

        $headers = [
            'Authorization: Bearer ' . $this->ionicAPIToken,
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data),
        ];

        $curlHandler = curl_init();

        curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
        curl_setopt($curlHandler, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer);
        curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curlHandler, CURLOPT_HEADER, false);

        switch ($method) {
            case self::METHOD_POST:
                curl_setopt($curlHandler, CURLOPT_POST, true);
                break;

            case self::METHOD_GET:
            case self::METHOD_DELETE:
            case self::METHOD_PATCH:
                curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
                break;
        }

        if (!empty($data)) {
            curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $data);
        }

        curl_setopt($curlHandler, CURLINFO_HEADER_OUT, true);
        curl_setopt($curlHandler, CURLOPT_URL, self::$ionicBaseURL . $endPoint);

        $response = curl_exec($curlHandler);

        $statusCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);

        curl_close($curlHandler);

        $response = json_decode($response);

        if (!$this->isSuccessResponse($statusCode)) {
            $this->throwRequestException($statusCode, $response);
        }

        // Return response.
        return $response;
    }
1187411
protected function request($method, $endpoint, $options = [])
    {
        return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
    }
1166721
protected function request(
        $method,
        $endpoint,
        array $params = []
    ) {
        return new TelegramRequest(
            $this->getAccessToken(),
            $method,
            $endpoint,
            $params,
            $this->isAsyncRequest(),
            $this->getTimeOut(),
            $this->getConnectTimeOut()
        );
    }
756345
protected function getEndpoint($method)
    {
        $endpoint = "simulate";
        $queryString = array();
        $text = $this->getArgument("text");
        if (!is_null($text)) {
            $queryString['text'] = $text;
            $this->delArgument("text");
        }

        $templateId = $this->getArgument("template_id");
        if (!is_null($templateId)) {
            $queryString['template_id'] = $templateId;
            $this->delArgument("template_id");
        }

        $variables = $this->getArgument("variables");
        if (!is_null($variables)) {
            $queryString['variables'] = json_encode($variables);
            $this->delArgument("variables");
        }

        $country = $this->getArgument("country");
        if (is_null($country)) {
            throw new \InvalidArgumentException("Country cant be null");
        }
        $queryString['country'] = $country;
        $this->delArgument("country");

        $queryString = http_build_query($queryString);
        return "$endpoint?$queryString";
    }
863832
public function callEndpoint($endpoint, array $endpointParameters = [], $body = null, $method = HttpMethod::REQUEST_GET)
    {
        // Set the endpoint
        $this->setEndpoint($endpoint);
        // Set the parameters
        $this->setEndpointParameters($endpointParameters);
        // Set the body
        $this->setBody($body);
        // Set the HTTP method
        $this->setHttpMethod($method);
        // Call the endpoint
        $this->call();
        // return the result
        return $this->getResult();
    }
612715
protected function getEndpoint($method)
    {
        $endpoint = "campaigns";
        $campaignId = $this->getArgument("id");
        if (!is_null($campaignId)) {
            $endpoint .= "/$campaignId";
            $this->delArgument("id");
            $this->delArgument("type");
        }
        $contacts = $this->getArgument("contacts");
        if (!is_null($contacts)) {
            $endpoint .= "/contacts";
            $this->delArgument("contacts");
        }
        $file = $this->getArgument("file");
        if (!is_null($file)) {
            $args = $this->getArguments();
            unset($args['file']);
            $args = array(
                'settings' => json_encode($args)
            );
            $endpoint = $endpoint . '?' . http_build_query($args);
        }
        $contact = $this->getArgument("contact");
        if (!is_null($contact)) {
            $endpoint .= "/contacts/$contact";
            $this->delArgument("contact");
        }
        $queryString = array();
        $page = $this->getArgument("page");
        if (!is_null($page)) {
            $queryString['page'] = $page;
            $this->delArgument("page");
        }
        if (!empty($queryString)) {
            $queryString = http_build_query($queryString);
            return "$endpoint?$queryString";
        }
        return $endpoint;
    }