class Money::Distributed::Fetcher::RussianCentralBank

Russian Central Bank rates fetcher

Constants

CBR_SERVICE_URL
VERSION

Private Instance Methods

exchange_rates() click to toggle source
# File lib/money/distributed/fetcher/russian_central_bank.rb, line 16
def exchange_rates
  fetch_exchange_rates.each_with_object('RUB' => 1) do |rate, h|
    next unless local_currencies.include? rate[:vch_code]
    h[rate[:vch_code]] =
      BigDecimal.new(rate[:vnom]) / BigDecimal.new(rate[:vcurs])
  end
end
fetch_exchange_rates() click to toggle source
# File lib/money/distributed/fetcher/russian_central_bank.rb, line 24
def fetch_exchange_rates
  client = Savon::Client.new(
    wsdl: CBR_SERVICE_URL, log: false, log_level: :error,
    follow_redirects: true
  )
  response = client.call(
    :get_curs_on_date,
    message: { 'On_date' => Time.now.strftime('%Y-%m-%dT%H:%M:%S') }
  )
  response.body[:get_curs_on_date_response][:get_curs_on_date_result] \
               [:diffgram][:valute_data][:valute_curs_on_date]
end
local_currencies() click to toggle source
# File lib/money/distributed/fetcher/russian_central_bank.rb, line 37
def local_currencies
  @local_currencies ||=
    Money::Currency.table.map { |currency| currency.last[:iso_code] }
end