You are here

class TestExchanger in Commerce Exchanger 8

Provides the test exchange rates.

Plugin annotation


@CommerceExchangerProvider(
  id = "test",
  label = "Test",
  display_label = "Test",
  historical_rates = TRUE,
  base_currency = "HRK",
  refresh_once = TRUE,
  transform_rates = TRUE,
)

Hierarchy

Expanded class hierarchy of TestExchanger

File

tests/modules/commerce_exchanger_test/src/Plugin/Commerce/ExchangerProvider/TestExchanger.php, line 20

Namespace

Drupal\commerce_exchanger_test\Plugin\Commerce\ExchangerProvider
View source
class TestExchanger extends ExchangerProviderRemoteBase {

  /**
   * {@inheritdoc}
   */
  public function apiUrl() {
    return 'http://example.test';
  }

  /**
   * {@inheritdoc}
   */
  public function getRemoteData($base_currency = NULL) {
    return [
      'EUR' => 0.13,
      'USD' => 0.16,
      'AUD' => 0.22,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExchangerProviderBase::$configFactory protected property Configuration management.
ExchangerProviderBase::$currencies protected property Return formatted array of currencies ['HRK' => 'Croatian Kuna'].
ExchangerProviderBase::$currencyStorage protected property The currency storage.
ExchangerProviderBase::$entityId private property Parent entity if present.
ExchangerProviderBase::$httpClientFactory protected property The HTTP client to fetch the feed data with.
ExchangerProviderBase::$logger protected property The logger.
ExchangerProviderBase::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm
ExchangerProviderBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
ExchangerProviderBase::defaultConfiguration public function
ExchangerProviderBase::getConfigName public function Return config object name where exchange rates are saved. Overrides ExchangerProviderInterface::getConfigName
ExchangerProviderBase::getConfiguration public function
ExchangerProviderBase::getCurrencies protected function Simple key-value array for enabled currencies.
ExchangerProviderBase::getMode public function
ExchangerProviderBase::setConfiguration public function
ExchangerProviderBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
ExchangerProviderBase::supportingModes public function
ExchangerProviderBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
ExchangerProviderBase::__construct public function Constructs a new ExchangeProvider object. Overrides PluginBase::__construct
ExchangerProviderRemoteBase::apiClient public function Generic wrapper around Drupal http client. Overrides ExchangerProviderRemoteInterface::apiClient
ExchangerProviderRemoteBase::buildExchangeRates protected function Process all currencies for rates for other currencies.
ExchangerProviderRemoteBase::crossSyncCalculate protected function Rates calculation for currencies when we use cross sync conversion.
ExchangerProviderRemoteBase::getApiKey public function Remote providers api key. Overrides ExchangerProviderRemoteInterface::getApiKey
ExchangerProviderRemoteBase::getAuthData public function Remote authentication credentials. Overrides ExchangerProviderRemoteInterface::getAuthData
ExchangerProviderRemoteBase::getBaseCurrency public function Either remote provider defined base currency, or use entered. Overrides ExchangerProviderRemoteInterface::getBaseCurrency
ExchangerProviderRemoteBase::getMethod public function Method which supports remote provider. Overrides ExchangerProviderRemoteInterface::getMethod
ExchangerProviderRemoteBase::import public function
ExchangerProviderRemoteBase::importCrossSync protected function Preform cross conversion between currencies to build exchange data rates.
ExchangerProviderRemoteBase::importEnterprise protected function Fetch remote provider by each currency and create dataset.
ExchangerProviderRemoteBase::isEnterprise public function Determine if remote provider supports querying by different base currency. Overrides ExchangerProviderRemoteInterface::isEnterprise
ExchangerProviderRemoteBase::mapExchangeRates protected function Helper function to create array for exchange rates.
ExchangerProviderRemoteBase::processRemoteData protected function Process data with checking structure and preparing data for importing.
ExchangerProviderRemoteBase::recalculateRates protected function Recalculate currencies from exchange rate between two other currencies.
ExchangerProviderRemoteBase::transformRates public function Determine if rates provided by provider needs to be transformed in a required rate ratio based on base currency. Overrides ExchangerProviderRemoteInterface::transformRates
ExchangerProviderRemoteBase::useCrossSync public function Either remote provider defined or use defined choice. Overrides ExchangerProviderRemoteInterface::useCrossSync
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
TestExchanger::apiUrl public function URL from remote provider upon API call should be made. Overrides ExchangerProviderRemoteInterface::apiUrl
TestExchanger::getRemoteData public function Fetch external data. Overrides ExchangerProviderRemoteInterface::getRemoteData