Class: CcyConvertor::OpenExchangeRate

Inherits:
RateProvider show all
Defined in:
lib/ccy_convertor/rate_providers/open_exchange_rate.rb

Instance Attribute Summary

Attributes included from RateCache

#cache_duration

Class Method Summary collapse

Methods inherited from RateProvider

api_key_nil?, convert, rate_from_rate_matrix, rate_matrix_response, rate_provider_name, rate_response, response_hash

Methods included from RateCache

#cache, #cache_duration_nil?, #cache_key

Methods included from ProcessAndValidateOption

#validate_amount!, #validate_currency_codes!, #validate_currency_support!, #validate_options!, #validate_presence_of_hash_keys!

Class Method Details

.rate_matrixObject



8
9
10
11
12
13
14
# File 'lib/ccy_convertor/rate_providers/open_exchange_rate.rb', line 8

def rate_matrix
  rate_matrix_response = rate_matrix_response()
  if rate_matrix_response['error']
    raise CcyConvertor::ResponseInvalid, rate_matrix_response['description']
  end
  rate_matrix_response['rates']
end

.rest_url_for_rate_matrix(base_ccy = nil) ⇒ Object



4
5
6
# File 'lib/ccy_convertor/rate_providers/open_exchange_rate.rb', line 4

def rest_url_for_rate_matrix(base_ccy = nil)
  "https://openexchangerates.org/api/latest.json?app_id=#{api_key}"
end