Skip to content
Permalink
Browse files

use coindesk instead of bitcoinaverage for currency conversion

  • Loading branch information
alexandrz committed Mar 9, 2020
1 parent 42add99 commit de3b6d790c44fb600f5528585efa50380422e1be
Showing with 3 additions and 3 deletions.
  1. +3 −3 app/helpers/application_helper.rb
@@ -151,11 +151,11 @@ def rate(currency, satoshies)
end

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

0 comments on commit de3b6d7

Please sign in to comment.
You can’t perform that action at this time.