Class: Exnify::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/exnify/client.rb

Constant Summary collapse

DEFAULT_BASE_URL =
"https://api.exnify.com"

Instance Method Summary collapse

Constructor Details

#initialize(api_key, base_url: DEFAULT_BASE_URL) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/exnify/client.rb', line 11

def initialize(api_key, base_url: DEFAULT_BASE_URL)
  @api_key = api_key
  @base_url = base_url.to_s.chomp("/")
end

Instance Method Details

#convert(from:, to:, amount:) ⇒ Object



38
39
40
# File 'lib/exnify/client.rb', line 38

def convert(from:, to:, amount:)
  request("/v1/convert", { from: from, to: to, amount: amount })
end

#currenciesObject



20
21
22
# File 'lib/exnify/client.rb', line 20

def currencies
  request("/v1/currencies")
end

#history(from:, to:, start:, end_date:) ⇒ Object



42
43
44
# File 'lib/exnify/client.rb', line 42

def history(from:, to:, start:, end_date:)
  request("/v1/history", { from: from, to: to, start: start, end: end_date })
end

#history_range(from:, to:, range:) ⇒ Object



46
47
48
# File 'lib/exnify/client.rb', line 46

def history_range(from:, to:, range:)
  request("/v1/history/range", { from: from, to: to, range: range })
end

#latest(base: nil) ⇒ Object



28
29
30
31
32
# File 'lib/exnify/client.rb', line 28

def latest(base: nil)
  params = {}
  params[:base] = base if base
  request("/v1/latest", params)
end


34
35
36
# File 'lib/exnify/client.rb', line 34

def popular
  request("/v1/popular")
end

#statusObject



16
17
18
# File 'lib/exnify/client.rb', line 16

def status
  request("/v1/status")
end

#symbolsObject



24
25
26
# File 'lib/exnify/client.rb', line 24

def symbols
  currencies
end