Class: Danconia::Exchanges::CurrencyLayer
- Defined in:
- lib/danconia/exchanges/currency_layer.rb
Instance Attribute Summary
Attributes inherited from Exchange
Instance Method Summary collapse
- #fetch_rates ⇒ Object
-
#initialize(access_key:, **args) ⇒ CurrencyLayer
constructor
A new instance of CurrencyLayer.
Methods inherited from Exchange
Constructor Details
#initialize(access_key:, **args) ⇒ CurrencyLayer
Returns a new instance of CurrencyLayer.
8 9 10 11 |
# File 'lib/danconia/exchanges/currency_layer.rb', line 8 def initialize access_key:, **args super args @access_key = access_key end |
Instance Method Details
#fetch_rates ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/danconia/exchanges/currency_layer.rb', line 13 def fetch_rates response = JSON.parse Net::HTTP.get URI "http://www.apilayer.net/api/live?access_key=#{@access_key}" if response['success'] response['quotes'] else raise Errors::APIError, response end end |