lib/money/bank/oanda_currency.rb
##
# Takes the response from Oanda and extract the rates and adds them to
# the rates store.
#
# @param [String] data The hash of rates from Oanda to decode.
Takes the response from Oanda and extract the rates and adds them to
the rates store.
Takes the response from Oanda and extract the rates and adds them to the rates store .
def extract_rates(data)
        rates = JSON.parse(data).fetch('quotes')
        rates.each do |rate|
          from_currency = rate.fetch('base_currency')
          to_currency = rate.fetch('quote_currency')
          next unless @white_list_currencies.include?(to_currency)
          store.add_rate(
            from_currency,
            to_currency,
            BigDecimal(rate.fetch('average_midpoint'))
          )
        end
      rescue StandardError
        raise OandaCurrencyFetchError, 'Error parsing rates or adding rates to store'
      end
def extract_rates ( data ) rates = JSON . parse ( data ) . fetch ( 'quotes' ) rates . each do | rate | from_currency = rate . fetch ( 'base_currency' ) to_currency = rate . fetch ( 'quote_currency' ) next unless @white_list_currencies . include? ( to_currency ) store . add_rate ( from_currency , to_currency , BigDecimal ( rate . fetch ( 'average_midpoint' ) ) ) end rescue StandardError raise OandaCurrencyFetchError , 'Error parsing rates or adding rates to store' end
Takes the response from Oanda and extract the rates and adds them to
the rates store.
Takes the response from Oanda and extract the rates and adds them to the rates store .
data
<not_specific>
<not_specific>
data The hash of rates from Oanda to decode.
data The hash of rates from Oanda to decode .