Make a request to medium's api.

@param string $method
@param string $endpoint
@param array $data

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

        return json_decode((string) $response->getBody());
    }
787389
protected function request($path, $method, array $data = array()) {
		$request = new Request();
		$response = new Response();
		$transport = $this->getTransport();

		$request->setMethod($method);
		$request->setResource($this->buildPath($path));
		$request->setHost(self::URI);
		$request->addHeader('Authorization: Basic ' . base64_encode($this->getAuthCredentials()));
		$request->addHeader('User-Agent: ' . $this->getUserAgent());

		if (count($data)) {
			$request->addHeader('Content-Type: application/json');
			$request->setContent(json_encode($data));
		}

		$transport->send($request, $response);

		return json_decode($response->getContent());
	}
1354459
protected function _doRequest($method, $url, $data, $options)
    {
        $request = $this->_createRequest(
            $method,
            $url,
            $data,
            $options
        );

        return $this->send($request, $options);
    }
1337562
protected function get($endpoint, $params = [], $accessToken = null)
    {
        return $this->sendRequest(self::GET_METHOD, $endpoint, $params, $accessToken);
    }
1187411
protected function request($method, $endpoint, $options = [])
    {
        return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
    }
425214
public function post($endpoint, $data, $options = [])
    {
        if (!is_array($data)) {
            $options['body'] = $data;
        } else {
            $options['form_params'] = $data;
        }

        return $this->request('post', $endpoint, $options);
    }
744971
protected function getEndpoint($method)
    {
        $endpoint = 'inspect';
        $number = $this->getArgument("number");
        if (!is_null($number)) {
            $endpoint .= "/$number";
            $this->delArgument("number");
        }
        return $endpoint;
    }
418212
private function request($method, $endpoint, $params, $body)
    {
        $setParams = $params && in_array($method, ["GET", "POST", "DELETE"]);
        $setBody = $body && in_array($method, ["POST", "PUT", "DELETE"]);

        $method = strtoupper($method);
        $url = $this->basePath . $endpoint . ($setParams ? "?" . $this->encodeParams($params) : "");

        $options = array();
        $options[CURLOPT_URL] = $url;
        $options[CURLOPT_HTTPHEADER] = $this->headers;
        $options[CURLOPT_RETURNTRANSFER] = true;
        $options[CURLOPT_CUSTOMREQUEST] = $method;
        $options[CURLOPT_POSTFIELDS] = $setBody ? json_encode($body) : null;
        $options[CURLOPT_CONNECTTIMEOUT] = $this->getConnectionOption("connectTimeout");
        $options[CURLOPT_TIMEOUT_MS] = $this->getConnectionOption("timeout");

        $curl = curl_init();

        if (isset($this->logger)) {
            $context = [ "options" => $options ];
            $this->logger->info("[ApiClient][Request] Curl request;", $context);
        }

        curl_setopt_array($curl, $options);

        $result = curl_exec($curl);
        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $error = curl_error($curl);

        curl_close($curl);

        if (isset($this->logger)) {
            $context = [ "result" => $result, "statusCode" => $statusCode, "error" => $error ];
            $this->logger->info("[ApiClient][Request] Curl response;", $context);
        }

        if ($result === false) {
            throw new ClientException($error);
        }
        elseif ($statusCode >= 400) {
            $error = json_decode($result);
            throw new ClientException($error, $statusCode);
        }

        return json_decode($result);
    }
1152312
public function request($method, $path, array $data = [])
    {
        try {
            $response = $this->httpClient->request($method, $path, $data);

            return json_decode($response->getBody()->getContents(), true);
        } catch (GuzzleException $e) {
            throw ClientException::newException($e, $method, $path, $data);
        }
    }
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;
    }
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();
    }
179281
protected function sendRequest(
        $method,
        $endpoint,
        array $params = []
    ) {
        $request = $this->request($method, $endpoint, $params);

        return $this->lastResponse = $this->client->sendRequest($request);
    }
973157
public function call($resource, $method, $data = array())
    {
        $resource = $this->api_url.'/'.$resource;
        $response = $this->getRequest(array(
            'url' => $resource,
            'method' => $method,
            'data' => $data, 
        ))->send();
        
        $result = null;
        if (strlen($response)) {
            $result = $response->{'parse'.$this->_response_format}();
            return $result;
        }

        return false;
    }
532900
protected function getEndpoint($method)
    {
        $endpoint = "credit_cards";
        $cardId = $this->getArgument("id");
        if (!is_null($cardId)) {
            $endpoint .= "/$cardId";
            $this->delArgument("id");
        }
        return $endpoint;
    }
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;
    }
538907
public function request($method, $endpoint, array $parameters = null)
    {
        $url = $this->config->getEndpoint() . $endpoint;

        // Client should always send OAuth2 tokens in its headers
        $headers = array('Authorization' => 'Bearer ' . $this->config->getAccessToken());

        return $this->client->request($method, $url, $parameters, $headers);
    }
786338
public function post($endpoint, array $data = [])
    {
        $body = json_encode($data);
        $request = $this->createRequest('POST', $endpoint, $body, ['Content-Type' => 'application/json']);
        return $this->sendRequest($request);
    }