Class: Exnify::Client
- Inherits:
-
Object
- Object
- Exnify::Client
- Defined in:
- lib/exnify/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://api.exnify.com"
Instance Method Summary collapse
- #convert(from:, to:, amount:) ⇒ Object
- #currencies ⇒ Object
- #history(from:, to:, start:, end_date:) ⇒ Object
- #history_range(from:, to:, range:) ⇒ Object
-
#initialize(api_key, base_url: DEFAULT_BASE_URL) ⇒ Client
constructor
A new instance of Client.
- #latest(base: nil) ⇒ Object
- #popular ⇒ Object
- #status ⇒ Object
- #symbols ⇒ Object
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 |
#currencies ⇒ Object
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 |
#popular ⇒ Object
34 35 36 |
# File 'lib/exnify/client.rb', line 34 def popular request("/v1/popular") end |
#status ⇒ Object
16 17 18 |
# File 'lib/exnify/client.rb', line 16 def status request("/v1/status") end |
#symbols ⇒ Object
24 25 26 |
# File 'lib/exnify/client.rb', line 24 def symbols currencies end |