Registers that new API call has been made.

@param string $api_key
@param string $region
@param string $endpoint
@param string $app_header
@param string $method_header
511970
public function registerCall( string $api_key, string $region, string $endpoint, string $app_header = null, string $method_header = null )
	{
		if ($app_header)
		{
			$limits = self::parseLimitHeaders($app_header);
			foreach ($limits as $interval => $used)
				$this->setAppUsed($api_key, $region, $interval, $used);
		}

		if ($method_header)
		{
			$limits = self::parseLimitHeaders($method_header);
			foreach ($limits as $interval => $used)
				$this->setMethodUsed($api_key, $region, $endpoint, $interval, $used);
		}
	}
390832
public void resolveRequestEndpoint(Request<?> request, String regionString) {
        if (regionString != null) {
            final Region r = RegionUtils.getRegion(regionString);

            if (r == null) {
                throw new SdkClientException("Not able to determine region" +
                        " for " + regionString + ".Please upgrade to a newer " +
                        "version of the SDK");
            }

            endpointBuilder.withRegion(r);
        }
        final URI endpoint = endpointBuilder.getServiceEndpoint();
        if (shouldUseVirtualAddressing(endpoint)) {
            request.setEndpoint(convertToVirtualHostEndpoint(endpoint, bucketName));
            request.setResourcePath(SdkHttpUtils.urlEncode(getHostStyleResourcePath(), true));
        } else {
            request.setEndpoint(endpoint);
            if (bucketName != null) {
                request.setResourcePath(SdkHttpUtils.urlEncode(getPathStyleResourcePath(), true));
            }
        }
    }
344951
public function execute($method, $apiCall, array $parameters = array(), $headers = array())
    {
        // Check if the access token needs to be added
        if ($this->access_token != null) {
            $headers = array_merge($headers, array(
                "Authorization: Bearer " . $this->access_token,
            ));
        }

        // Force cURL to not send Expect header to workaround bug with Akamai CDN not handling
        // this type of requests correctly
        $headers = array_merge($headers, array(
            "Expect:",
        ));

        // Setup CURL
        $ch = $this->curlbuilder->create();

        // Set default options
        $ch->setOptions(array(
            CURLOPT_URL             => $apiCall,
            CURLOPT_HTTPHEADER      => $headers,
            CURLOPT_CONNECTTIMEOUT  => 20,
            CURLOPT_TIMEOUT         => 90,
            CURLOPT_RETURNTRANSFER  => true,
            CURLOPT_SSL_VERIFYPEER  => false,
            CURLOPT_SSL_VERIFYHOST  => false,
            CURLOPT_HEADER          => false,
            CURLINFO_HEADER_OUT     => true
        ));

        switch ($method) {
            case 'POST':
                $ch->setOptions(array(
                    CURLOPT_CUSTOMREQUEST   => "POST",
                    CURLOPT_POST            => count($parameters),
                    CURLOPT_POSTFIELDS      => $parameters
                ));

                if (!class_exists('\CURLFile') && defined('CURLOPT_SAFE_UPLOAD')) {
                    $ch->setOption(CURLOPT_SAFE_UPLOAD, false);
                }
                elseif (class_exists('\CURLFile') && defined('CURLOPT_SAFE_UPLOAD')) {
                    $ch->setOption(CURLOPT_SAFE_UPLOAD, true);
                }

                break;
            case 'DELETE':
                $ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE");
                break;
            case 'PATCH':
                $ch->setOptions(array(
                    CURLOPT_CUSTOMREQUEST   => "PATCH",
                    CURLOPT_POST            => count($parameters),
                    CURLOPT_POSTFIELDS      => $parameters
                ));
                break;
            default:
                $ch->setOption(CURLOPT_CUSTOMREQUEST, "GET");
                break;
        }

        // Execute request and catch response
        $response_data = $ch->execute();

        if ($response_data === false && !$ch->hasErrors()) {
            throw new CurlException("Error: Curl request failed");
        }
        else if($ch->hasErrors()) {
            throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber());
        }

        // Initiate the response
        $response = new Response($response_data, $ch);

        // Check the response code
        if ($response->getResponseCode() >= 400) {
            throw new PinterestException('Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->getMessage(), $response->getResponseCode());
        }

        // Get headers from last request
        $this->headers = $ch->getHeaders();

        // Close curl resource
        $ch->close();

        // Return the response
        return $response;
    }
510059
public static function create($statuscode,$remote_app_id, $last_response){

        $aLogs = ApiLogQuery::create()->findByRemoteAppId($remote_app_id);
        foreach($aLogs as $oLog){
            $oLog->delete();
        }

        $oApiLog = new ApiLog();
        $oApiLog->setRemoteAppId($remote_app_id);
        $oApiLog->setStatuscode($statuscode);
        $oApiLog->setLastResponse($last_response);
        $dt = new \DateTime();
        $oApiLog->setDtCall($dt);
        $oApiLog->save();
    }
1017040
def _register_client(self, client, region_name):
        
        for item in client.meta.method_to_api_mapping:
            method = getattr(client, item)
            wrapped_method = functools.partial(self._wrap_client, region_name, method)
            setattr(client, item, wrapped_method)
975053
function makeRequest(string $method, string $endpoint, array $options) {
        $request = new \CharlotteDunois\Yasmin\HTTP\APIRequest($this, $method, $endpoint, $options);
        return $this->add($request);
    }
1306826
static public void register (EndPoint endPoint) {
		Kryo kryo = endPoint.getKryo();
		kryo.register(Login.class);
		kryo.register(RegistrationRequired.class);
		kryo.register(Register.class);
		kryo.register(AddCharacter.class);
		kryo.register(UpdateCharacter.class);
		kryo.register(RemoveCharacter.class);
		kryo.register(Character.class);
		kryo.register(MoveCharacter.class);
	}
724400
protected function makeCall( string $overrideRegion = null, string $method = self::METHOD_GET ): PromiseInterface
	{
		if ($overrideRegion)
			$this->setTemporaryRegion($overrideRegion);

		$this->used_method = $method;
		$this->used_key    = self::SET_KEY;

		$requestHeaders = [];
		$requestPromise = null;
		$url = $this->_getCallUrl($requestHeaders);
		$requestHash = md5($url);

		if (!$requestPromise && $this->getSetting(self::SET_USE_DUMMY_DATA, false))
		{
			// DummyData are supposed to be used
			try
			{
				// try loading the data
				$this->_loadDummyData($responseHeaders, $responseBody, $responseCode);
				$this->processCallResult($responseHeaders, $responseBody, $responseCode);
				$requestPromise = new FulfilledPromise($this->getResult());
			}
			catch (RequestException $ex)
			{
				// loading failed, check whether an actual request should be made
				if ($this->getSetting(self::SET_SAVE_DUMMY_DATA, false) == false)
					// saving is not allowed, dummydata does not exist
					throw $ex;
			}
		}

		if (!$requestPromise && $this->getSetting(self::SET_CACHE_CALLS) && $this->ccc && $this->ccc->isCallCached($requestHash))
		{
			// calls are cached and this request is saved in cache
			$this->processCallResult([], $this->ccc->loadCallData($requestHash), 200);
			$requestPromise = new FulfilledPromise($this->getResult());
		}

		if (!$requestPromise)
		{
			// calls are not cached or this request is not cached
			// perform call to Riot API
			$guzzle = $this->guzzle;
			if ($this->next_async_request)
				$guzzle = $this->next_async_request->client;

			$this->_beforeCall($url, $requestHash);

			$options[RequestOptions::VERIFY] = $this->getSetting(self::SET_VERIFY_SSL);
			$options[RequestOptions::HEADERS] = $requestHeaders;
			if ($this->post_data)
				$options[RequestOptions::BODY] = $this->post_data;

			// Create HTTP request
			$requestPromise = $guzzle->requestAsync(
				$method,
				$url,
				$options
			);

			$dummyData_file = $this->_getDummyDataFileName();
			$requestPromise = $requestPromise->then(function(ResponseInterface $response) use ($url, $requestHash, $dummyData_file) {
				$this->processCallResult($response->getHeaders(), $response->getBody(), $response->getStatusCode());
				$this->_afterCall($url, $requestHash, $dummyData_file);
				return $this->getResult();
			});
		}

		// If request fails, try to process it and raise exceptions
		$requestPromise = $requestPromise->otherwise(function($ex) {
			/** @var \Exception $ex */

			if ($ex instanceof GuzzleHttpExceptions\RequestException)
			{
				$responseHeaders = [];
				$responseBody    = null;
				$responseCode    = $ex->getCode();

				if ($response = $ex->getResponse())
				{
					$responseHeaders = $response->getHeaders();
					$responseBody    = $response->getBody();
				}

				$this->processCallResult($responseHeaders, $responseBody, $responseCode);
				throw new RequestException("LeagueAPI: Request error occured - {$ex->getMessage()}", $ex->getCode(), $ex);
			}
			elseif ($ex instanceof GuzzleHttpExceptions\ServerException)
			{
				throw new ServerException("LeagueAPI: Server error occured {$ex->getMessage()}", $ex->getCode(), $ex);
			}

			throw new RequestException("LeagueAPI: Request could not be sent - {$ex->getMessage()}", $ex->getCode(), $ex);
		});

		if ($this->next_async_request)
			return $requestPromise;

		if ($overrideRegion)
			$this->unsetTemporaryRegion();

		$this->query_data = [];
		$this->post_data  = null;

		return $requestPromise;
	}
1235479
function callApi(endpoint, schema) {
  const fullUrl = (endpoint.indexOf(API_ROOT) === -1) ? API_ROOT + endpoint : endpoint;

  return fetch(fullUrl)
    .then(response =>
      response.json().then(json => ({ json, response }))
    ).then(({ json, response }) => {
      if (json.error) {
        throw new Error(json.error);
      }
      if (!response.ok) {
        throw new Error(json && json.message || response.statusText || response.status + ' http error');
      }

      const camelizedJson = camelizeKeys(json);
      const nextPageUrl = getNextPageUrl(response);

      return Object.assign({},
        normalize(camelizedJson, schema),
        { nextPageUrl }
      );
    })
    .then(
      response => ({response})
    );
}
775721
def call(path, http_method: :get, body: {}, header: {})
      # add bearer token to header
      header[:authorization] = "Bearer #{access_token}"
      return ShakeTheCounter::API.call(path, http_method: http_method, body: body, header: header)
    end
832408
function APIRequest(method, url) {
	var data, callback, opts, req, headers = messageHeaders(this);
	callback = ( typeof(arguments[2]) === 'function' ? arguments[2] : (data = arguments[2], arguments[3]) );

	if (isNode) {
		opts = URL.parse(url);
		opts.method = method;
		opts.headers = headers;

		req = requesters[opts.protocol.slice(0, -1)].request(opts, function(res) {
			var chunks = [];
			res.on('data', function(c) { chunks[chunks.length] = c; });
			res.once('end', function() {
				chunks = Buffer.concat(chunks);
				Zlib.gunzip(chunks, function(err, uc) {
					if (!err) uc = uc.toString();
					try { res.body = JSON.parse(uc || chunks); } catch(e) {}
					return callback(null, res);
				});
			});
		});
		if (type(data) === 'object' || method.toLowerCase() === 'get') req.setHeader("Content-Type", "application/json; charset=utf-8");
		if (data instanceof Multipart) req.setHeader("Content-Type", "multipart/form-data; boundary=" + data.boundary);
		if (data) req.write( data.result || JSON.stringify(data), data.result ? 'binary' : 'utf-8' );
		req.end();

		return req.once('error', function(e) { return callback(e.message); });
	}

	req = new XMLHttpRequest();
	req.open(method.toUpperCase(), url, true);
	for (var key in headers) {
		req.setRequestHeader(key, headers[key]);
	}
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			req.statusCode = req.status;
			req.statusMessage = req.statusText;
			try {req.body = JSON.parse(req.responseText);} catch (e) { return handleErrCB(e, callback); }
			callback(null, req);
		}
	};
	if (type(data) === 'object' || method.toLowerCase() === 'get') req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
	if (data instanceof Multipart) req.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + data.boundary);
	if (data) return req.send( data.result ? data.result : JSON.stringify(data) );
	req.send(null);
}
295322
public void putreq_vheader(String endmark)
    throws SoccomException
    {
    if (endmark.length()!=4)
        throw new SoccomException(SoccomException.ENDM_LENGTH);
    byte msgbytes[] = SoccomMessage.
        makeMessageSpecial("ENDM" + endmark, null);
    logline("SEND: " + new String(msgbytes));
    copy_msgid(_msgid, msgbytes);
    try {
        _out.write(msgbytes);
    } catch (IOException e) {
        throw new SoccomException(SoccomException.REQUEST);
    }
    }
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();
    }
1015634
function(apiKey){

    // Default parent scope does not have parent.
    this.parentScope = null;

    // Setup apiKey of the current Scope if it is a String.
    if(Utils.isString(apiKey)){
      this.apiKey = apiKey;
    }else{
      throw new TypeError('Scope constructor should be called with API Key.');
    }

    this.$init = EVT.api({
      url: '/access',
      authorization: this.apiKey
    });
  }
634827
public function api($endpoint, array $params = [], $method = Method::GET)
    {
        $headers = $this->getApiHeaders();
        $options = $this->prepareOptions($params, $method);
        Method::isMethodSupported($method);
        if ($this->isUsingTokenParam()) {
            $params['oauth2_access_token'] = $this->accessToken->getToken();
        } else {
            $headers['Authorization'] = 'Bearer ' . $this->accessToken->getToken();
        }
        $guzzle = new GuzzleClient([
            'base_uri' => $this->getApiRoot(),
            'headers' => $headers,
        ]);
        if (!empty($params) && Method::GET === $method) {
            $endpoint .= '?' . build_query($params);
        }
        try {
            $response = $guzzle->request($method, $endpoint, $options);
        } catch (RequestException $requestException) {
            throw Exception::fromRequestException($requestException);
        }
        return self::responseToArray($response);
    }
654862
private void callHandleMethod(Method method, Object instance, ApiZone apiZone,
            Object userAgent) {
        ReflectMethodUtil.invokeHandleMethod(method, instance, context, apiZone, userAgent);
    }
969325
protected function _getEndpoint($method, $method_template)
    {
        if (substr($method, 0, 5) == 'oauth') {
            $url = self::$_endpoint_oauth . $method;
        } else {
            $url = self::$_endpoint . $method . '.json';
        }
        return $url;
    }