Makes an API request.
@param string  $method
@param string  $endpoint
@param array   $options
@return \React\Promise\ExtendedPromiseInterface
975053
function makeRequest(string $method, string $endpoint, array $options) {
        $request = new \CharlotteDunois\Yasmin\HTTP\APIRequest($this, $method, $endpoint, $options);
        return $this->add($request);
    }
191219
protected function createEndPoint($method, $data = array())
    {
        //create array for api key
        $data['api_token'] = $this->apiKey;
        //make API end point
        $endPoint = $this->url  . '/' . $method . '?' . http_build_query($data);
        //set API endpoint
        $this->setOpt(CURLOPT_URL, $endPoint);
        //return this object
        return $this;
    }
332031
protected function request(string $method, string $endpoint, $json = null)
    {
        $uri = $this->buildUri($endpoint);
        $options = $json != null ? ['json' => $json] : [];

        try {
            $response = $this->client->request($method, $uri, $options);
        } catch (ClientException $exception) {
            throw $this->determineException($exception);
        }

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

        return $this->jsonValidator($body) ? json_decode($body, true) : $body;
    }
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);
    }
1138130
private function request($method, $uri, array $options = array())
    {
        $options['auth'] = array($this->accessKey, $this->secretKey);

        return $this->httpClient->request($method, $uri, $options);
    }
411774
protected function request($endpoint, array $parameter = [], $method = 'GET')
    {
        $option = [
            CURLOPT_HTTPHEADER => [
                'key: ' . $this->api_key,
            ],
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_CAINFO => __DIR__ . DIRECTORY_SEPARATOR . 'Certificate' . DIRECTORY_SEPARATOR . 'cacert.pem',
        ];

        if ('POST' === $method) {
            $this->request = Curl::post($this->api_url[$this->account_type] . '/' . $endpoint, $parameter, $option);
        } else {
            $this->request = Curl::get($this->api_url[$this->account_type] . '/' . $endpoint, $parameter, $option);
        }

        $this->response = [
            'code' => false,
            'data' => false,
            'error' => false,
        ];

        if (isset($this->request->body) && isset($this->request->body->rajaongkir)) {
            if (200 === $this->request->body->rajaongkir->status->code) {
                $this->response['code'] = $this->request->body->rajaongkir->status->code;

                if (isset($this->request->body->rajaongkir->results)) {
                    $this->response['data'] = $this->request->body->rajaongkir->results;
                } elseif (isset($this->request->body->rajaongkir->result)) {
                    $this->response['data'] = $this->request->body->rajaongkir->result;
                } else {
                    $this->response['code'] = 400;
                    $this->response['error'] = 'Invalid response. Response tidak ditemukan, harap baca dokumentasi dengan baik.';
                }

                if (isset($this->request->body->rajaongkir->origin_details) && isset($this->request->body->rajaongkir->destination_details)) {
                    $this->response['meta'] = [
                        'origin' => $this->request->body->rajaongkir->origin_details,
                        'destination' => $this->request->body->rajaongkir->destination_details,
                        'weight' => $this->request->body->rajaongkir->query->weight,
                        'courier' => $this->request->body->rajaongkir->query->courier,
                    ];
                }
            } else {
                $this->response['code'] = $this->request->body->rajaongkir->status->code;
                $this->response['error'] = $this->request->body->rajaongkir->status->description;
            }
        } else {
            $this->response['code'] = 400;
            $this->response['error'] = 'Invalid response. Response tidak ditemukan, harap baca dokumentasi dengan baik.';
        }

        return (object) $this->response;
    }
1249794
public function getRequest($method, $url, array $options = [])
    {
        return $this->createRequest($method, $url, null, $options);
    }
179281
protected function sendRequest(
        $method,
        $endpoint,
        array $params = []
    ) {
        $request = $this->request($method, $endpoint, $params);

        return $this->lastResponse = $this->client->sendRequest($request);
    }
1080922
public function request($method, $uri = '', array $options = [])
    {
        //Always prepend the api key.

        if (isset($options['query'])) {
            $options['query']['api_key'] = $this->apiKey;
        } else {
            $options['query'] = ['api_key' => $this->apiKey];
        }

        return $this->guzzleClient->request($method, $uri, $options);
    }
976815
public function makeRequest($method, $endpoint, array $data = [])
    {
        $response = $this->client->request($method, $endpoint, $data);

        return json_decode((string) $response->getBody());
    }
902141
protected function createRequest($endpoint, $method, $data = [], $parameters = [])
    {
        $body    = '';
        $url     = $this->url . $endpoint;
        $hasData = !empty($data);

        // Setup authentication.
        $parameters = $this->authenticate($url, $method, $parameters);

        // Setup method.
        $this->setupMethod($method);

        // Include post fields.
        if ($hasData) {
            $body = \json_encode($data);
            \curl_setopt($this->ch, CURLOPT_POSTFIELDS, $body);
        }

        $this->request = new Request(
            $this->buildUrlQuery($url, $parameters),
            $method,
            $parameters,
            $this->getRequestHeaders($hasData),
            $body
        );

        return $this->getRequest();
    }
13135
public function createRequest($method, $uri, array $headers = [], array $options = [])
    {
        $body = JsonRpc\json_encode($this->addIdToRequest($method, $options));

        return new Request('POST', $uri, $headers, $body === false ? null : $body);
    }
1012947
public function request($endpoint, $method, $data = [], $parameters = [])
    {
        // Initialize cURL.
        $this->ch = \curl_init();

        // Set request args.
        $request = $this->createRequest($endpoint, $method, $data, $parameters);

        // Default cURL settings.
        $this->setDefaultCurlSettings();

        // Get response.
        $response = $this->createResponse();

        // Check for cURL errors.
        if (\curl_errno($this->ch)) {
            throw new HttpClientException('cURL Error: ' . \curl_error($this->ch), 0, $request, $response);
        }

        \curl_close($this->ch);

        return $this->processResponse();
    }
347039
public function performApiRequest($endpoint, $payload)
    {
        $this->setupRequest($payload);
        $this->apiEndpoint = $endpoint;

        return $this->doDropboxApiRequest();
    }
1357752
protected function send($method, $endpointUri, $body = null, array $headers = [])
    {
        $headers = array_merge($headers, self::getDefaultHeaders());
        $endpointUrl = $this->baseUrl . $endpointUri;

        $request = new Request($method, $endpointUrl, $headers, json_encode($body));
        $response = $this->getHttpClient()->sendRequest($request);

        return $this->handleResponse($response);
    }
43645
public function build(string $method, string $path, array $options): RequestInterface
    {
        $body = $options['body'] ?? null;

        $uri = $this->getUri(
            $path,
            $options['host'] ?? null,
            $options['query'] ?? []
        );

        $headers = $this->getHeaders(
            $options['headers'] ?? [],
            $body
        );

        return new Request($method, $uri, $headers, $body);
    }
667809
private function performRequest($method, $url, $options) {

        try {
            switch ($method) {
                case 'GET':
                    return json_decode($this->client->get($url, $options)->getBody(), true);
                case 'POST':
                    return json_decode($this->client->post($url, $options)->getBody(), true);
                case 'PUT':
                    return json_decode($this->client->put($url, $options)->getBody(), true);
                case 'DELETE':
                    return json_decode($this->client->delete($url, $options)->getBody(), true);
                default:
                    return null;
            }
        } catch (RequestException $e) {
            throw ApiException::create($e);
        }
    }