Skip to content

Commit d9a85ab

Browse files
authored
Merge pull request #384 from tip4commit/hotfix/currency-conversion
use coindesk instead of bitcoinaverage for currency conversion
2 parents 5bd1ff0 + de3b6d7 commit d9a85ab

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

app/helpers/application_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def rate(currency, satoshies)
151151
end
152152

153153
def get_rate(currency)
154-
Rails.cache.fetch('###' + currency, expires_in: 24.hours) do
155-
uri = URI('https://apiv2.bitcoinaverage.com/indices/global/ticker/BTC' + currency)
154+
Rails.cache.fetch('###' + currency, expires_in: 1.hours) do
155+
uri = URI('https://api.coindesk.com/v1/bpi/currentprice/' + currency + '.json')
156156
response = Net::HTTP.get_response(uri)
157157
hash = JSON.parse(response.body)
158-
hash['averages']['day'].to_f
158+
hash['bpi'][currency]['rate_float'].to_f
159159
end
160160
end
161161

0 commit comments

Comments
 (0)