Sha256: e04200411cf9fb87fd57a63bbe8cf6fc4d12098e6e2089fe2e8698b4ea5238d5

Contents?: true

Size: 532 Bytes

Versions: 8

Compression:

Stored size: 532 Bytes

Contents

require 'danconia/errors/api_error'
require 'net/http'
require 'json'

module Danconia
  module Exchanges
    class CurrencyLayer < Exchange
      def initialize access_key:, **args
        super args
        @access_key = access_key
      end

      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
danconia-0.2.9 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.8 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.7 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.6 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.5 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.4 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.3 lib/danconia/exchanges/currency_layer.rb
danconia-0.2.2 lib/danconia/exchanges/currency_layer.rb