Class: SynapsePayRest::CryptoQuote
- Inherits:
-
Object
- Object
- SynapsePayRest::CryptoQuote
- Defined in:
- lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb
Overview
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.
Instance Attribute Summary collapse
-
#btcusd ⇒ Object
readonly
Returns the value of attribute btcusd.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#ethusd ⇒ Object
readonly
Returns the value of attribute ethusd.
-
#usdbtc ⇒ Object
readonly
Returns the value of attribute usdbtc.
-
#usdeth ⇒ Object
readonly
Returns the value of attribute usdeth.
Class Method Summary collapse
-
.from_response(client, response) ⇒ Object
Creates a crypto quote from a response hash.
- .get(client:) ⇒ Object
Instance Method Summary collapse
-
#initialize(**options) ⇒ CryptoQuote
constructor
A new instance of CryptoQuote.
Constructor Details
#initialize(**options) ⇒ CryptoQuote
Do not call directly. Use other class method to instantiate via API action.
Returns a new instance of CryptoQuote.
35 36 37 |
# File 'lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb', line 35 def initialize(**) .each { |key, value| instance_variable_set("@#{key}", value) } end |
Instance Attribute Details
#btcusd ⇒ Object (readonly)
Returns the value of attribute btcusd.
7 8 9 |
# File 'lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb', line 7 def btcusd @btcusd end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb', line 7 def client @client end |
#ethusd ⇒ Object (readonly)
Returns the value of attribute ethusd.
7 8 9 |
# File 'lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb', line 7 def ethusd @ethusd end |
#usdbtc ⇒ Object (readonly)
Returns the value of attribute usdbtc.
7 8 9 |
# File 'lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb', line 7 def usdbtc @usdbtc end |
#usdeth ⇒ Object (readonly)
Returns the value of attribute usdeth.
7 8 9 |
# File 'lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb', line 7 def usdeth @usdeth end |
Class Method Details
.from_response(client, response) ⇒ Object
Shouldn’t need to call this directly.
Creates a crypto quote from a response hash.
14 15 16 17 18 19 20 21 22 23 |
# 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:) ⇒ Object
25 26 27 28 29 |
# 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 |