You are here

public function ExchangerProviderRemoteBase::apiClient in Commerce Exchanger 8

Generic wrapper around Drupal http client.

Parameters

array $options: Additional request options.

Return value

mixed Return response, or error.

Overrides ExchangerProviderRemoteInterface::apiClient

4 calls to ExchangerProviderRemoteBase::apiClient()
CurrencylayerExchanger::getRemoteData in src/Plugin/Commerce/ExchangerProvider/CurrencylayerExchanger.php
Fetch external data.
EuropeanCentralBankExchanger::getRemoteData in src/Plugin/Commerce/ExchangerProvider/EuropeanCentralBankExchanger.php
Fetch external data.
FixerExchanger::getRemoteData in src/Plugin/Commerce/ExchangerProvider/FixerExchanger.php
Fetch external data.
TransferWiseExchanger::getRemoteData in src/Plugin/Commerce/ExchangerProvider/TransferWiseExchanger.php
Fetch external data.

File

src/Plugin/Commerce/ExchangerProvider/ExchangerProviderRemoteBase.php, line 65

Class

ExchangerProviderRemoteBase
Base class for Commerce exchanger provider plugins.

Namespace

Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider

Code

public function apiClient(array $options) {
  $data = [];

  // Prepare for client.
  $client = $this->httpClientFactory
    ->fromOptions();
  try {
    $response = $client
      ->request($this
      ->getMethod(), $this
      ->apiUrl(), $options);

    // Expected result.
    $data = $response
      ->getBody()
      ->getContents();
  } catch (GuzzleException $e) {
    $this->logger
      ->error($e
      ->getMessage());
  }
  return $data;
}