Class: Cryptopay::Rates

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/api/rates.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Rates

Returns a new instance of Rates.



8
9
10
# File 'lib/cryptopay/api/rates.rb', line 8

def initialize(connection)
  @connection = connection
end

Instance Method Details

#all(_opts = {}) ⇒ RatesResult

Retrieve all rates This endpoint allows you to retrieve all public rates.

Parameters:

  • opts (Hash)

    the optional parameters

Returns:



16
17
18
19
20
21
22
23
24
25
# File 'lib/cryptopay/api/rates.rb', line 16

def all(_opts = {})
  path = '/api/rates'

  req = Request.new(
    method: :get,
    path: path
  )

  connection.call(req, return_type: RatesResult)
end

#retrieve(base_currency, quote_currency, _opts = {}) ⇒ RateResult

Retrieve a pair rate This endpoint allows you to retrieve a public rate by currency pair.

Parameters:

  • base_currency (String)

    Base currency of pair

  • quote_currency (String)

    Quote currency of pair

  • opts (Hash)

    the optional parameters

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cryptopay/api/rates.rb', line 33

def retrieve(base_currency, quote_currency, _opts = {})
  path = '/api/rates/{base_currency}/{quote_currency}'
  path = path.sub('{base_currency}', CGI.escape(base_currency.to_s))
  path = path.sub('{quote_currency}', CGI.escape(quote_currency.to_s))

  req = Request.new(
    method: :get,
    path: path
  )

  connection.call(req, return_type: RateResult)
end