You are here

protected function ExchangerProviderRemoteBase::processRemoteData in Commerce Exchanger 8

Process data with checking structure and preparing data for importing.

Parameters

string|null $base_currency: The base currency or null if none.

Return value

\Drupal\commerce_exchanger\ExchangerProviderRates The ExchangeRates.

2 calls to ExchangerProviderRemoteBase::processRemoteData()
ExchangerProviderRemoteBase::importCrossSync in src/Plugin/Commerce/ExchangerProvider/ExchangerProviderRemoteBase.php
Preform cross conversion between currencies to build exchange data rates.
ExchangerProviderRemoteBase::importEnterprise in src/Plugin/Commerce/ExchangerProvider/ExchangerProviderRemoteBase.php
Fetch remote provider by each currency and create dataset.

File

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

Class

ExchangerProviderRemoteBase
Base class for Commerce exchanger provider plugins.

Namespace

Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider

Code

protected function processRemoteData(string $base_currency = NULL) {
  $remote_data = $this
    ->getRemoteData($base_currency);

  // Validate and build structure.
  if (!isset($remote_data['base'], $remote_data['rates'])) {
    $exchange_rates['rates'] = $remote_data ?? [];
    $exchange_rates['base'] = $base_currency ?? $this
      ->getBaseCurrency();
  }
  else {
    $exchange_rates = $remote_data;
  }

  // Pass enabled currencies to automatically filter data.
  $exchange_rates['currencies'] = $this
    ->getCurrencies();
  $exchange_rates['transform'] = $this
    ->transformRates();
  return new ExchangerProviderRates($exchange_rates);
}