Skip to content

Commit

Permalink
fixed open exchange rate url and date format
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoSalerno committed Oct 16, 2015
1 parent c318a93 commit ac4929d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/money/bank/open_exchange_rates_loader.rb
Expand Up @@ -7,8 +7,8 @@
class Money
module Bank
module OpenExchangeRatesLoader
HIST_URL = 'http://openexchangerates.org/historical/'
OER_URL = 'http://openexchangerates.org/latest.json'
HIST_URL = 'http://openexchangerates.org/api/historical/'
OER_URL = 'http://openexchangerates.org/api/latest.json'

# Tries to load data from OpenExchangeRates for the given rate.
# Won't do anything if there's no data available for that date
Expand All @@ -17,8 +17,7 @@ def load_data(date)
rates_source = if date == Date.today
OER_URL.dup
else
# Should we use strftime, does to_s have better performance ? Or is it localized accross systems ?
HIST_URL + date.to_s + '.json'
HIST_URL + date.strftime('%Y-%m-%d') + '.json'
end
rates_source << "?app_id=#{ENV['OPENEXCHANGERATES_APP_ID']}" if ENV['OPENEXCHANGERATES_APP_ID']
doc = Yajl::Parser.parse(open(rates_source).read)
Expand Down

1 comment on commit ac4929d

@atwam
Copy link

@atwam atwam commented on ac4929d Nov 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I haven't been maintaining this a lot.
Thanks for your PR, will merge.

Please sign in to comment.