Adds an APIRequest to the queue.
@param \CharlotteDunois\Yasmin\HTTP\APIRequest  $apirequest
@return \React\Promise\ExtendedPromiseInterface
546800
function add(\CharlotteDunois\Yasmin\HTTP\APIRequest $apirequest) {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) use ($apirequest) {
            $apirequest->deferred = new \React\Promise\Deferred();
            $apirequest->deferred->promise()->done($resolve, $reject);
            
            $endpoint = $this->getRatelimitEndpoint($apirequest);
            if(!empty($endpoint)) {
                $this->client->emit('debug', 'Adding request "'.$apirequest->getEndpoint().'" to ratelimit bucket');
                $bucket = $this->getRatelimitBucket($endpoint);
                
                $bucket->push($apirequest);
                $this->queue[] = $bucket;
            } else {
                $this->client->emit('debug', 'Adding request "'.$apirequest->getEndpoint().'" to global queue');
                $this->queue[] = $apirequest;
            }
            
            $this->processFuture();
        }));
    }
910565
protected function createRequest(IndexQueryRequest $getRequest)
    {
        $args    = $this->createRequestArgs($getRequest);
        $path    = $this->buildPath($getRequest->type, $getRequest->bucket, $getRequest->index, $args);
        $httpReq = $this->client->createRequest('GET', $path);

        return $httpReq;
    }
588148
public function sendAsyncRequest(RequestInterface $request)
    {
        try {
            return new Promise\HttpFulfilledPromise($this->sendRequest($request));
        } catch (Exception $e) {
            return new Promise\HttpRejectedPromise($e);
        }
    }
974126
public function addBatchRequest(ClientRequestInterface $request)
    {
        if ($request instanceof ContextAwareInterface) {
            $request->setContextIfNull($this->getConfig()->getContext());
        }
        $this->batchRequests[] = $request;
        return $this;
    }
896828
public function post($apiQuery, $options = array())
    {
        if (!RequestApi::isPost($apiQuery)) {
            throw new \InvalidArgumentException('Unsupported API query for POST method: ' . $apiQuery);
        }

        $request = $this->getApi()->post($apiQuery, null, $options);

        $this->prepareRequest($request, $options);

        $response = $request->send();

        return $this->processResponse($response);
    }
1176658
public static function createFromApiResult($apiResult, BaseResource $resource)
    {
        foreach ($apiResult as $property => $value) {
            $resource->{$property} = $value;
        }

        return $resource;
    }
163040
function(apiId) {
        return new Promise(function(resolve, reject) {
            APIG.deleteRestApi({
                restApiId: apiId
            }, function(err) {
                if (err) {
                    if (err.code === 404 || err.code === 'NotFoundException') {
                        // API didn't exist to begin with
                        return resolve(apiId);
                    }

                    return reject(err);
                }

                resolve(apiId);
            });
        });
    }
323342
public function dispatch($query): PromiseInterface
    {
        $deferred = new Deferred();

        $actionEventEmitter = $this->events;

        $actionEvent = $actionEventEmitter->getNewActionEvent(
            self::EVENT_DISPATCH,
            $this,
            [
                self::EVENT_PARAM_MESSAGE => $query,
                self::EVENT_PARAM_DEFERRED => $deferred,
                self::EVENT_PARAM_PROMISE => $deferred->promise(),
            ]
        );

        try {
            $actionEventEmitter->dispatch($actionEvent);

            if (! $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLED)) {
                throw new RuntimeException(\sprintf('Query %s was not handled', $this->getMessageName($query)));
            }
        } catch (\Throwable $exception) {
            $actionEvent->setParam(self::EVENT_PARAM_EXCEPTION, $exception);
        } finally {
            $actionEvent->stopPropagation(false);
            $this->triggerFinalize($actionEvent);
        }

        return $actionEvent->getParam(self::EVENT_PARAM_PROMISE);
    }
1110510
public static function create($baseUrl, self $apiClient = null)
    {
        return $apiClient === null ? new self(new Client(), $baseUrl) : $apiClient;
    }
507562
public function authenticate($apiKey, $apiSecret)
    {
        $this->auth[0] = $apiKey;
        $this->auth[1] = $apiSecret;

        return $this;
    }
931681
private function apiRequest($options)
    {
        $params = new \DerivativeRequest(
            $this->getRequest(),
            $options
        );
        $api = new \ApiMain($params);
        $api->execute();

        return $api->getResult()->getResultData();
    }
1195451
public static function mock(array $stack = []): ApiClient
    {
        $mock = new MockHandler($stack);

        $handler = HandlerStack::create($mock);

        $client = new Client(['handler' => $handler, 'verify' => false]);

        app()->instance('ej:sdk:guzzle', $client);

        return resolve(__CLASS__);
    }
639168
public function getClientWithCOID(IRI $apiCoid) {
        $apiCoidString = (string)$apiCoid;
        if (!isset($this->apiClients[$apiCoidString])) {
            $this->apiClients[$apiCoidString] = self::createClient(
                $this->objectRetriever->getObject($apiCoid),
                $this->namespace);
        }

        return $this->apiClients[$apiCoidString];
    }
1296329
public static function make($apiKey = null, $registerDefaultCallback = true)
    {
        $config = new Config($apiKey ?: getenv('AFTERBUG_API_KEY'));

        $client = new static($config, static::makeGuzzle($config));

        if ($registerDefaultCallback) {
            $client->registerDefaultCallbacks();
        }

        return $client;
    }
770446
public function setApiKey($apikey)
    {
        if (isset($this->emailPassword)) {
            throw new \Exception(
                "EmailPassword already set."
            );
		}
		$this->apikey = $apikey . ':';
		return $this;
    }
669300
public function doRequest(HttpRequestInterface $request)
    {
        $responseClass = $this->responseClass;

        /** @var HttpResponseInterface $responseObject */
        $responseObject = new $responseClass();

        return $responseObject->build($request);
    }
658278
protected function sendRequest(ApiRequestInterface $request)
    {
        $clientOptions = [];

        //add mock to client config
        if ($this->isModeMock()) {
            if ($request->getMock()) {
                $mockHandler = new MockHandler($request->getMock());
                $clientOptions['handler'] = $mockHandler;
            } else {
                throw new ApiException('The service can\'t be mocked, should create a valid mock for this service.');
            }
        }

        return $this->buildClient($clientOptions)->send($request, $request->getOptions()->getAll());
    }