Retrieves exchange rates from https://free.currencyconverterapi.com

@param Currency $currency

@throws GuzzleException
@throws CurrencyConverterApiException
165315
private function retrieveExchangeRateFor(Currency $currency): void
    {
        $conversion = sprintf('%s_%s', $this->baseCurrency->getCode(), $currency->getCode());

        $response = $this->client->request('GET', self::EXCHANGE_RATE_API_URL . '/api/v6/convert', [
            'query' => ['q' => $conversion]
        ]);

        $data = json_decode($response->getBody(), true);

        if (! array_key_exists($conversion, $data['results'])) {
            throw CurrencyConverterApiException::currencyNotFound($currency->getCode());
        }

        $this->exchangeRates[$currency->getCode()] = (float) $data['results'][$conversion]['val'];
    }
966886
protected function getEndpoint(Currency $referenceCurrency, Currency $currency)
    {
        $q = sprintf(
            'select * from yahoo.finance.xchange where pair in ("%s%s")',
            $referenceCurrency->getCode(),
            $currency->getCode()
        );

        $queryString = http_build_query(array(
            'q'      => $q,
            'format' => 'json',
            'env'    => 'store://datatables.org/alltableswithkeys',
        ));

        return 'https://query.yahooapis.com/v1/public/yql?'.$queryString;
    }
408293
public function getFormattedBasePriceForCurrency($currency = 'EUR')
    {
        $price = $this->getBasePriceForCurrency($currency);
        if ($price) {
            return $this->getFormattedPrice($price->getPrice(), $currency, $this->locale);
        }

        return '';
    }
1159919
public function getCurrency($currency = null): ?array
    {
        $currency = $currency ? mb_strtoupper($currency) : null;

        return $this->get("currency.{$currency}") ?: (current($this->get('currency', [])) ?: null);
    }
928590
public function getCurrency()
    {
        // @todo
        $result = array (
            Meta::Currency => $this->source->currency_code,
            Meta::CurrencyRate => (float) $this->source->conversion_rate,
            Meta::CurrencyDoConvert => true,
        );
        return $result;
    }
934800
private function getCurrencyCode($currency)
    {
        $list = self::getCurrencyList();

        if (isset($list[$currency])) {
            return $list[$currency]['code'];
        }

        throw new \RuntimeException('Invalid exception provided');
    }
227196
public function getBasePriceForCurrency($currency = 'EUR')
    {
        $prices = $this->entity->getPrices();
        if ($prices) {
            foreach ($prices as $price) {
                if ($price->getCurrency()->getCode() == $currency && $price->getMinimumQuantity() == 0) {
                    return new ProductPrice($price, $this->locale);
                }
            }
        }

        return null;
    }
26173
public function convertBaseRateToCurrency(string $currency) : Rates
    {
        if (!empty($this->rates)) {
            if ($this->base !== $currency) {
                if (!empty($this->rates[$currency])) {
                    $usdrate = $this->rates[$currency];
                    foreach ($this->rates as $key => $rate) {
                        $newrates[$key] = $rate * (1 / $usdrate);
                    }
                }
            }
        }
        if (!empty($newrates)) {
            $this->rates = $newrates;
            $this->base = $currency;
        }

        return $this;
    }
731060
private Currency getCurrency(String currencyCode) {
        try {
            return Currency.getInstance(currencyCode);
        } catch (Exception e) {
            return null;
        }
    }
1199244
public function getSpecialPriceForCurrency($currency = 'EUR')
    {
        $specialPrices = $this->entity->getSpecialPrices();
        if ($specialPrices) {
            foreach ($specialPrices as $specialPriceEntity) {
                if ($specialPriceEntity->getCurrency()->getCode() == $currency) {
                    $startDate = $specialPriceEntity->getStartDate();
                    $endDate = $specialPriceEntity->getEndDate();
                    $now = new \DateTime();
                    if (($now >= $startDate && $now <= $endDate) ||
                        ($now >= $startDate && empty($endDate)) ||
                        (empty($startDate) && empty($endDate))
                    ) {
                        return $specialPriceEntity;
                    }
                }
            }
        }

        return null;
    }
91038
public function toCurrencyWords($currency, $decimal, $fraction = null)
    {
        $return = '';
        $currency = strtoupper($currency);

        if (!array_key_exists($currency, self::$currencyNames)) {
            throw new NumberToWordsException(
                sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))
            );
        }

        $currencyNames = self::$currencyNames[$currency];

        if ($decimal != '' && $decimal != 0) {
            $return = trim($this->toWords($decimal));
            $lev = ($decimal == 1) ? 0 : 1;

            if ($lev > 0) {
                if (count($currencyNames[0]) > 1) {
                    $return .= $this->wordSeparator . $currencyNames[0][$lev];
                } else {
                    $return .= $this->wordSeparator . $currencyNames[0][0];
                }
            } else {
                $return .= $this->wordSeparator . $currencyNames[0][0];
            }

            if (null !== $fraction) {
                $return .= $this->wordSeparator . 'og';
            }
        }

        if (null !== $fraction) {
            $return .= $this->wordSeparator . trim($this->toWords($fraction));
            $lev = ($fraction == 1) ? 0 : 1;

            if ($lev > 0) {
                if (count($currencyNames[1]) > 1) {
                    $return .= $this->wordSeparator . $currencyNames[1][$lev];
                } else {
                    $return .= $this->wordSeparator . $currencyNames[1][0];
                }
            } else {
                $return .= $this->wordSeparator . $currencyNames[1][0];
            }
        }

        return $return;
    }
986136
public function currency($currency = null) {
        $currency = $currency == null ? $this->currency : $currency;
        return $this->getWord($this->number) . ' ' . $currency;
    }
998798
public function getCurrency($iso)
    {
        if ($this->currencies === null && $this->config('include_currency', false)) {
            $this->currencies = include(__DIR__ . '/Support/Currencies.php');
        }

        return Arr::get($this->currencies, $iso);
    }
77563
public static function getCurrencySymbol($currency) {
    return (array_key_exists($currency, Connect2PayCurrencyHelper::$currencies)) ? Connect2PayCurrencyHelper::$currencies[$currency]["symbol"] : null;
  }
445166
public static function useCurrency(string $currency, ?string $symbol = null): void
    {
        static::$currency = $currency;
        static::useCurrencySymbol($symbol ?: static::guessCurrencySymbol($currency));
    }
232300
public static function checkCurrency($country, $currency)
    {
        switch($country) {
        case KlarnaCountry::AT:
        case KlarnaCountry::DE:
        case KlarnaCountry::NL:
        case KlarnaCountry::FI:
            return ($currency === KlarnaCurrency::EUR);
        case KlarnaCountry::DK:
            return ($currency === KlarnaCurrency::DKK);
        case KlarnaCountry::NO:
            return ($currency === KlarnaCurrency::NOK);
        case KlarnaCountry::SE:
            return ($currency === KlarnaCurrency::SEK);
        default:
            //Country not yet supported by Klarna.
            return false;
        }
    }
791916
public function destroy(Currency $currency)
    {
        $deleted = $this->repository->delete($currency);

        return response()->json([
            'error' => !$deleted,
        ]);
    }