Class: FreeCurrencyAPI::API

Inherits:
Object
  • Object
show all
Defined in:
lib/freecurrencyAPI/API.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ API

Returns a new instance of API.



7
8
9
10
11
12
13
# File 'lib/freecurrencyAPI/API.rb', line 7

def initialize api_key
    @conn = Faraday.new "https://api.freecurrencyapi.com/v1/" do |c|
    c.response :json
    c.adapter :net_http
    c.headers = {apikey: "#{api_key}"}
    end
end

Instance Method Details

#available_currenciesObject



19
20
21
# File 'lib/freecurrencyAPI/API.rb', line 19

def available_currencies
    do_request "currencies"
end

#latest_exchange_ratesObject



15
16
17
# File 'lib/freecurrencyAPI/API.rb', line 15

def latest_exchange_rates
    do_request "latest"
end