Class: Revolut::Api::Response::Wallet
- Inherits:
-
Object
- Object
- Revolut::Api::Response::Wallet
- Defined in:
- lib/revolut/api/response/wallet.rb
Instance Attribute Summary collapse
-
#base_currency ⇒ Object
Returns the value of attribute base_currency.
-
#id ⇒ Object
Returns the value of attribute id.
-
#pockets ⇒ Object
Returns the value of attribute pockets.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#state ⇒ Object
Returns the value of attribute state.
-
#total_topup ⇒ Object
Returns the value of attribute total_topup.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #in_state?(state) ⇒ Boolean
-
#initialize(hash = {}) ⇒ Wallet
constructor
A new instance of Wallet.
- #pocket(currency) ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Wallet
Returns a new instance of Wallet.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/revolut/api/response/wallet.rb', line 10 def initialize(hash = {}) self.id = hash.fetch("id", nil) self.ref = hash.fetch("ref", nil) self.state = hash.fetch("state", nil) self.base_currency = hash.fetch("baseCurrency", nil) self.total_topup = hash.fetch("totalTopup", nil) self.total_topup = ::Revolut::Api::Utilities.convert_from_integer_amount(self.base_currency, self.total_topup) if !self.base_currency.to_s.empty? && !self.total_topup.nil? self.pockets = {} hash.fetch("pockets", []).each do |pocket_data| pocket = ::Revolut::Api::Response::Pocket.new(pocket_data) self.pockets[pocket.currency] = pocket end end |
Instance Attribute Details
#base_currency ⇒ Object
Returns the value of attribute base_currency.
6 7 8 |
# File 'lib/revolut/api/response/wallet.rb', line 6 def base_currency @base_currency end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/revolut/api/response/wallet.rb', line 5 def id @id end |
#pockets ⇒ Object
Returns the value of attribute pockets.
8 9 10 |
# File 'lib/revolut/api/response/wallet.rb', line 8 def pockets @pockets end |
#ref ⇒ Object
Returns the value of attribute ref.
5 6 7 |
# File 'lib/revolut/api/response/wallet.rb', line 5 def ref @ref end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/revolut/api/response/wallet.rb', line 5 def state @state end |
#total_topup ⇒ Object
Returns the value of attribute total_topup.
7 8 9 |
# File 'lib/revolut/api/response/wallet.rb', line 7 def total_topup @total_topup end |
Instance Method Details
#active? ⇒ Boolean
27 28 29 |
# File 'lib/revolut/api/response/wallet.rb', line 27 def active? in_state?(:active) end |
#in_state?(state) ⇒ Boolean
31 32 33 |
# File 'lib/revolut/api/response/wallet.rb', line 31 def in_state?(state) self.state.downcase.strip.to_sym.eql?(state) end |
#pocket(currency) ⇒ Object
35 36 37 |
# File 'lib/revolut/api/response/wallet.rb', line 35 def pocket(currency) self.pockets.fetch(currency, nil) end |