Class: Cryptopay::Exchange
- Inherits:
-
Object
- Object
- Cryptopay::Exchange
- Defined in:
- lib/cryptopay/models/exchange.rb
Overview
Exchange details
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Exchange
Builds the object from hash.
Instance Method Summary collapse
-
#fee ⇒ Object
Exchange fee.
-
#fee_currency ⇒ Object
Exchange fee currency.
-
#initialize(attributes = {}) ⇒ Exchange
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#pair ⇒ Object
Currency pair.
-
#rate ⇒ Object
Exchange rate.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Exchange
Initializes the object
37 38 39 |
# File 'lib/cryptopay/models/exchange.rb', line 37 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Exchange
Builds the object from hash
30 31 32 33 |
# File 'lib/cryptopay/models/exchange.rb', line 30 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#fee ⇒ Object
Exchange fee
52 53 54 |
# File 'lib/cryptopay/models/exchange.rb', line 52 def fee @attributes[:fee] end |
#fee_currency ⇒ Object
Exchange fee currency
57 58 59 |
# File 'lib/cryptopay/models/exchange.rb', line 57 def fee_currency @attributes[:fee_currency] end |
#inspect ⇒ Object
85 86 87 |
# File 'lib/cryptopay/models/exchange.rb', line 85 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
63 64 65 66 67 68 69 70 71 |
# File 'lib/cryptopay/models/exchange.rb', line 63 def invalid_properties properties = [] properties.push('invalid value for "pair", pair cannot be nil.') if pair.nil? properties.push('invalid value for "rate", rate cannot be nil.') if rate.nil? properties end |
#pair ⇒ Object
Currency pair
42 43 44 |
# File 'lib/cryptopay/models/exchange.rb', line 42 def pair @attributes[:pair] end |
#rate ⇒ Object
Exchange rate
47 48 49 |
# File 'lib/cryptopay/models/exchange.rb', line 47 def rate @attributes[:rate] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
81 82 83 |
# File 'lib/cryptopay/models/exchange.rb', line 81 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
75 76 77 |
# File 'lib/cryptopay/models/exchange.rb', line 75 def valid? invalid_properties.empty? end |