class SynapsePayRest::CryptoQuote

Represents a public key record and holds methods for getting crypto quote from API calls. This is built on top of the SynapsePayRest::Client class and is intended to make it easier to use the API without knowing payload formats or knowledge of REST.

Attributes

btcusd[R]
client[R]
ethusd[R]
usdbtc[R]
usdeth[R]

Public Class Methods

from_response(client, response) click to toggle source

Creates a crypto quote from a response hash.

@note Shouldn't need to call this directly.

# File lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb, line 14
def from_response(client, response)
  args = {
    client:                    client,
    btcusd:        response['BTCUSD'],
    ethusd:        response['ETHUSD'],
    usdbtc:        response['USDBTC'],
    usdeth:        response['USDETH']
  }
  self.new(args)
end
get(client:) click to toggle source
# File lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb, line 25
def get(client:)
  raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
  response = client.crypto_quotes.get()
  self.from_response(client, response)
end
new(**options) click to toggle source

@note Do not call directly. Use other class method

to instantiate via API action.
# File lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb, line 35
def initialize(**options)
  options.each { |key, value| instance_variable_set("@#{key}", value) }
end