Registers that new API call has been made.

@param string $api_key
@param string $region
@param string $endpoint
@param string $method_header
336083
public function registerMethodLimits( string $api_key, string $region, string $endpoint, string $method_header )
	{
		$limits = self::parseLimitHeaders($method_header);
		$this->initMethod($api_key, $region, $endpoint, $limits);
	}
1349993
def api_call(self, method, **params):
        
        coro = self._api_call(method, **params)
        # Explicitly ensure that API call is executed
        return asyncio.ensure_future(coro)
410130
protected function api($endpoint, $options, $method = 'GET')
    {
        if (empty($this->token)) {
            throw CouldNotSendNotification::facebookPageTokenNotProvided('You must provide your Facebook Page token to make any API requests.');
        }

        $url = "https://graph.facebook.com/v2.7/{$endpoint}?access_token={$this->token}";

        try {
            return $this->httpClient()->request($method, $url, $options);
        } catch (ClientException $exception) {
            throw CouldNotSendNotification::facebookRespondedWithAnError($exception);
        } catch (Exception $exception) {
            throw CouldNotSendNotification::couldNotCommunicateWithFacebook($exception);
        }
    }
686848
protected function sendRequest($method, $endpoint, $params = [], $accessToken = null)
    {
        $client = $this->getNewHttpClient($method, $params, $accessToken);
        $response = $client->request($method, $endpoint);
        $responseBody = $response->getBody()->getContents();

        return $this->getReturnJson() ? $responseBody : json_decode($responseBody, true);
    }
1227306
protected function sendRequest($method, $endpoint, $data = null)
    {
        return $this->httpClient->request(
            $method,
            $this->getEndpoint() . $endpoint,
            $this->getHeaders(),
            $data
        );
    }
1152283
public void setApiKey(String apiKey) {
        if (this.jsonHttpClient != null) {
            this.jsonHttpClient.setApiKey(apiKey);
        }
        if (this.restApiClient != null) {
            this.restApiClient.setApiKey(apiKey);
        }
        if (this.swaggerApiClient != null) {
            ApiKeyAuth genieKey = (ApiKeyAuth) this.swaggerApiClient.getAuthentication("GenieKey");
            genieKey.setApiKeyPrefix("GenieKey");
            genieKey.setApiKey(apiKey);
        }
    }
1333493
public function canCall( string $api_key, string $region, string $resource, string $endpoint): bool
	{
		$appLimits = $this->getAppLimits($api_key, $region);
		if (is_array($appLimits) && $resource != LeagueAPI::RESOURCE_STATICDATA)
		{
			foreach ($appLimits as $timeInterval => $limits)
			{
				//  Check all saved intervals for this region
				if ($limits['used'] >= $limits['limit'] && $limits['expires'] > time())
					return false;
			}
		}

		$methodLimits = $this->getMethodLimits($api_key, $region, $endpoint);
		if (is_array($methodLimits))
		{
			foreach ($methodLimits as $timeInterval => $limits)
			{
				//  Check all saved intervals for this endpoint
				if ($limits['used'] >= $limits['limit'] && $limits['expires'] > time())
					return false;
			}
		}

		return true;
	}
1051599
private function doApiCall($url, $method, $access_token = null, $parameters = [], $contentType = 'text/xml')
    {
        $request = [];
        $headers = [];

        $request[CURLOPT_TIMEOUT]       = (int) $this->http_timeout;
        $request[CURLOPT_USERAGENT]     = str_replace('%VERSION%', Client::VERSION, $this->http_user_agent);
        $request[CURLOPT_CUSTOMREQUEST] = $method;

        if (isset($parameters['Ocp-Apim-Subscription-Key'])) {
            $headers[] = "Ocp-Apim-Subscription-Key: ".$parameters['Ocp-Apim-Subscription-Key'];
            $headers[] = "Content-Length: 0";
            unset($parameters['Ocp-Apim-Subscription-Key']);
        }

        if (! empty($parameters)) {
            if ($method === 'GET') {
                $url = Tools::httpBuildUrl($url, ["query" => http_build_query($parameters)], Tools::HTTP_URL_JOIN_QUERY);
            } else {
                if (is_array($parameters)) {
                    $request[CURLOPT_POSTFIELDS] = http_build_query($parameters);
                } else {
                    if (is_string($parameters)) {
                        $request[CURLOPT_POSTFIELDS] = $parameters;
                    }
                }
            }
        }

        $request[CURLOPT_URL] = $url;

        if (! is_null($contentType)) {
            $headers[] = "Content-Type: $contentType";
        }

        if (! is_null($access_token)) {
            $headers[] = 'Authorization: Bearer '.$access_token;
        }

        if (! empty($this->http_proxy_host)) {
            $request[CURLOPT_PROXY] = $this->http_proxy_host;

            if (! empty($this->http_proxy_port)) {
                $request[CURLOPT_PROXYPORT] = $this->http_proxy_port;
            }

            if (! empty($this->http_proxy_type)) {
                $request[CURLOPT_PROXYTYPE] = $this->http_proxy_type;
            }

            if (! empty($this->http_proxy_auth)) {
                $request[CURLOPT_PROXYAUTH] = $this->http_proxy_auth;
            }

            if (! empty($this->http_proxy_user)) {
                $request[CURLOPT_PROXYUSERPWD] = $this->http_proxy_user.':'.$this->http_proxy_pass;
            }
        }

        $request[CURLOPT_HTTPHEADER] = $headers;

        $this->logger->info(__CLASS__, 'api', sprintf('%s %s', $method, $url));

        $start = microtime(true);
        @list($result, $status_code, $error, $errno) = $this->execCurl($request);
        $end = microtime(true);

        $duration = (int) round(($end - $start) * 1000);

        if ($errno === 0) {
            $return = [
                'http_code' => $status_code,
                'http_body' => $result,
                'duration'  => $duration,
            ];

            if ($status_code >= 400) {
                $this->logger->error(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
            } else {
                if ($status_code >= 300) {
                    $this->logger->warning(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
                } else {
                    $this->logger->info(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms', $status_code, strlen($result), $duration));
                }
            }
        } else {
            $return = [
                'error_msg' => $error,
                'error_num' => $errno,
                'duration'  => $duration,
            ];

            $this->logger->error(__CLASS__, 'api', sprintf('cURL error #%s : %s', $errno, $error));
        }

        return $return;
    }
708018
private function prepareRequest($method, $deviceToken, $endPoint)
    {
        $tokenId = md5($deviceToken);
        return $this->sendRequest(
            $method,
            str_replace(':token_id', $tokenId, $endPoint)
        );
    }
946381
function RegisterEndpoint(method, path, _desc, _callback) {
    if(!_.isString(path)) {
      throw new Error("Invalid path for " + path + " (" + method + ")");
    }
    var desc = (typeof _desc === 'string' ? _desc : null),
      callback = (typeof _desc === 'function' ? _desc : (typeof _callback === 'function' ? _callback : null));
    var name = method + ":" + path.replace(/\//g, '.');
    if(name.charAt(0) === '.') name = name.substr(1);
    if(typeof this.__endpoints[name] !== 'undefined') {
      throw new Error("Previously registered endpoint " + path + " in namespace "+ this.__namespace + "(" + method + ")");
    }
    ENDPOINT_COUNTER++;
    var endpointChain = new RouteChain(name, path, method, SERVER);
    endpointChain.__namespace = this.__namespace;
    if(desc) endpointChain['desc'] = desc;
    if(callback) endpointChain.then(callback);
    this.__endpoints[name] = endpointChain;
    /* We allow route chaining of utility functions. After a route endpoint has been created,
     * we can attach additional data / utility functions to it. */
    return endpointChain;
  }
469100
private function runSingleRequest($request_method, $parameters) {

        try {

            $registered_method = $this->checkRequestSustainability($request_method);

            $selected_signature = $this->checkRequestConsistence($registered_method, $parameters);

            if ( is_array($parameters) ) $parameters = self::matchParameters($parameters, $registered_method, $selected_signature);

            $this->parameters->setParameters($parameters);

            $callback = $registered_method->getCallback();

            $attributes = $registered_method->getArguments();

            array_unshift($attributes, $this->parameters);

        } catch (RpcException $re) {

            throw $re;

        }

        set_error_handler(

            function($severity, $message, $file, $line) {

                $this->logger->error($message, array(
                    "FILE" => $file,
                    "LINE" => $line
                ));

                throw new RpcException('Internal error', -32603);

            }

        );

        try {

            // $return = call_user_func($callback, $this->parameters);
            $return = call_user_func_array($callback, $attributes);

        } catch (RpcException $re) {

            restore_error_handler();

            throw $re;

        } catch (Exception $e) {

            restore_error_handler();

            $this->logger->error($e->getMessage(), array(
                "FILE" => $e->getFile(),
                "LINE" => $e->getLine()
            ));

            throw new RpcException('Internal error', -32603);

        }

        restore_error_handler();

        return $return;

    }
456676
protected function makeRequest($endpoint = null, $method, $params)
    {
        $endpoint = $endpoint ?: $this->getEndpoint();

        // Prepend relationship, if one exists.
        if (static::getParentID()) {
            $params = array_merge([
                static::getParentID()
            ], $params);
        }

        $results = call_user_func_array([static::$client->$endpoint(), $method], $params);

        // Set errors from server...if any
        $this->messageBag = static::$client->errors();

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

        try {
            $this->lastResponse = $this->client->request($method, $uri, $options);
        } catch (GuzzleException $e) {
            throw new ApiException($e->getMessage(), $e->getCode());
        }

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

        return $this->lastResponse;
    }
1126308
public ApiResponse<GetAnyLocationsResponse> getAnyLocationsWithHttpInfo(String region) throws ApiException {
        com.squareup.okhttp.Call call = getAnyLocationsValidateBeforeCall(region, null, null);
        Type localVarReturnType = new TypeToken<GetAnyLocationsResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
466846
private void post(final String endpoint, final Class responseClass, final KickflipCallback cb) {
        post(endpoint, null, responseClass, cb);
    }
115147
public RefreshResponse refresh(String region) throws ApiException {
        ApiResponse<RefreshResponse> resp = refreshWithHttpInfo(region);
        return resp.getData();
    }
833447
public function call(string $method, string $endpoint, array $data = []): array
    {
        $method = strtolower($method);
        if (!in_array($method, ['get', 'put', 'post', 'delete', 'patch'])) {
            throw new MailchimpException('Invalid API call method: ' . $method);
        }
        if (in_array($method, ['get', 'delete'])) {
            $url = $this->baseurl . $endpoint;
            $url .= $data ? '?' . http_build_query($data) : '';
            $response = Requests::$method($url, $this->headers(), $this->options());
        } else {
            $response = Requests::$method(
                $this->baseurl . $endpoint,
                $this->headers(),
                json_encode($data),
                $this->options()
            );
        }
        $this->responseCode = intval($response->status_code);
        if ($this->responseCode >= 400) {
            $this->apiError($response);
        }
        return json_decode($response->body, true) ?? [];
    }