Class: Exchange::ExternalAPI::XavierMedia
- Defined in:
- lib/exchange/external_api/xavier_media.rb
Overview
The XavierMedia API class, handling communication with the Xavier Media Currency API You can find further information on the Xaviermedia API here: www.xavierforum.com/viewtopic.php?f=5&t=10979&sid=671a685edbfa5dbec219fbc6793d5057
Constant Summary collapse
- API_URL =
The base of the Xaviermedia API URL
"api.finance.xaviermedia.com/api"
- CURRENCIES =
The currencies the Xaviermedia API URL can handle
[:eur, :usd, :jpy, :gbp, :cyp, :czk, :dkk, :eek, :huf, :ltl, :mtl, :pln, :sek, :sit, :skk, :chf, :isk, :nok, :bgn, :hrk, :rol, :ron, :rub, :trl, :aud, :cad, :cny, :hkd, :idr, :krw, :myr, :nzd, :php, :sgd, :thb, :zar]
Instance Attribute Summary
Attributes inherited from Base
#base, #cache, #helper, #rates, #timestamp
Instance Method Summary collapse
-
#update(opts = {}) ⇒ Object
Updates the rates by getting the information from Xaviermedia API for today or a defined historical date The call gets cached for a maximum of 24 hours.
Methods inherited from XML
Methods inherited from Base
#convert, #initialize, #rate, #test_for_rates_and_raise_if_nil, #to_hash!
Constructor Details
This class inherits a constructor from Exchange::ExternalAPI::XML
Instance Method Details
#update(opts = {}) ⇒ Object
Updates the rates by getting the information from Xaviermedia API for today or a defined historical date The call gets cached for a maximum of 24 hours.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/exchange/external_api/xavier_media.rb', line 26 def update opts={} time = helper.assure_time(opts[:at], :default => :now) api_url = api_url(time) Call.new(api_url, api_opts(opts.merge(:at => time, :api => self.class))) do |result| @base = extract_base_currency result @rates = extract_rates result @timestamp = result end end |