Class: Revolut::Api::Response::Quote
- Inherits:
-
Object
- Object
- Revolut::Api::Response::Quote
- Defined in:
- lib/revolut/api/response/quote.rb
Instance Attribute Summary collapse
-
#epoch ⇒ Object
Returns the value of attribute epoch.
-
#fee ⇒ Object
Returns the value of attribute fee.
-
#from ⇒ Object
Returns the value of attribute from.
-
#markup ⇒ Object
Returns the value of attribute markup.
-
#message ⇒ Object
Returns the value of attribute message.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#success ⇒ Object
Returns the value of attribute success.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Quote
constructor
A new instance of Quote.
- #set_amount_hash(key, hash) ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Quote
Returns a new instance of Quote.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/revolut/api/response/quote.rb', line 10 def initialize(hash = {}) if hash.has_key?("message") self. = hash.fetch("message") self.success = false else self.from = {} self.to = {} self.fee = {} set_amount_hash("from", hash) set_amount_hash("to", hash) set_amount_hash("fee", hash) self.rate = hash.fetch("rate", nil) self.markup = hash.fetch("markup", nil) self.epoch = hash.fetch("timestamp", nil) self. = ::Revolut::Api::Utilities.epoch_to_utc(self.epoch) self.success = true end end |
Instance Attribute Details
#epoch ⇒ Object
Returns the value of attribute epoch.
7 8 9 |
# File 'lib/revolut/api/response/quote.rb', line 7 def epoch @epoch end |
#fee ⇒ Object
Returns the value of attribute fee.
6 7 8 |
# File 'lib/revolut/api/response/quote.rb', line 6 def fee @fee end |
#from ⇒ Object
Returns the value of attribute from.
5 6 7 |
# File 'lib/revolut/api/response/quote.rb', line 5 def from @from end |
#markup ⇒ Object
Returns the value of attribute markup.
6 7 8 |
# File 'lib/revolut/api/response/quote.rb', line 6 def markup @markup end |
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/revolut/api/response/quote.rb', line 8 def end |
#rate ⇒ Object
Returns the value of attribute rate.
6 7 8 |
# File 'lib/revolut/api/response/quote.rb', line 6 def rate @rate end |
#success ⇒ Object
Returns the value of attribute success.
8 9 10 |
# File 'lib/revolut/api/response/quote.rb', line 8 def success @success end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/revolut/api/response/quote.rb', line 7 def end |
#to ⇒ Object
Returns the value of attribute to.
5 6 7 |
# File 'lib/revolut/api/response/quote.rb', line 5 def to @to end |
Instance Method Details
#set_amount_hash(key, hash) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/revolut/api/response/quote.rb', line 34 def set_amount_hash(key, hash) if hash.has_key?(key) sub_item = hash.fetch(key, {}) if sub_item.is_a?(Hash) self.send(key)[:currency] = sub_item.fetch("currency", nil) self.send(key)[:base_amount] = sub_item.fetch("amount", nil) self.send(key)[:amount] = ::Revolut::Api::Utilities.convert_from_integer_amount(self.send(key)[:currency], self.send(key)[:base_amount]) if !self.send(key)[:currency].to_s.empty? && !self.send(key)[:base_amount].nil? elsif sub_item.is_a?(String) self.send("#{key}=", sub_item) end end end |