Class: Revolut::Api::Response::Transaction
- Inherits:
-
Object
- Object
- Revolut::Api::Response::Transaction
- Defined in:
- lib/revolut/api/response/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#balance ⇒ Object
Returns the value of attribute balance.
-
#card ⇒ Object
Returns the value of attribute card.
-
#completed_date ⇒ Object
Returns the value of attribute completed_date.
-
#counterpart ⇒ Object
Returns the value of attribute counterpart.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#fee ⇒ Object
Returns the value of attribute fee.
-
#id ⇒ Object
Returns the value of attribute id.
-
#leg_id ⇒ Object
Returns the value of attribute leg_id.
-
#merchant ⇒ Object
Returns the value of attribute merchant.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#started_date ⇒ Object
Returns the value of attribute started_date.
-
#state ⇒ Object
Returns the value of attribute state.
-
#type ⇒ Object
Returns the value of attribute type.
-
#updated_date ⇒ Object
Returns the value of attribute updated_date.
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #in_state?(state) ⇒ Boolean
-
#initialize(hash = {}) ⇒ Transaction
constructor
A new instance of Transaction.
- #pending? ⇒ Boolean
Constructor Details
#initialize(hash = {}) ⇒ Transaction
Returns a new instance of Transaction.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/revolut/api/response/transaction.rb', line 12 def initialize(hash = {}) self.id = hash.fetch("id", nil) self.leg_id = hash.fetch("legId", nil) self.type = hash.fetch("type", nil) self.state = hash.fetch("state", nil) self.started_date = hash.fetch("startedDate", nil) self.started_date = ::Revolut::Api::Utilities.epoch_to_utc(self.started_date) unless self.started_date.nil? self.updated_date = hash.fetch("updatedDate", nil) self.updated_date = ::Revolut::Api::Utilities.epoch_to_utc(self.updated_date) unless self.updated_date.nil? self.completed_date = hash.fetch("completedDate", nil) self.completed_date = ::Revolut::Api::Utilities.epoch_to_utc(self.completed_date) unless self.completed_date.nil? self.currency = hash.fetch("currency", nil) self.amount = hash.fetch("amount", nil) self.amount = ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.amount) if !self.currency.to_s.empty? && !self.amount.nil? self.fee = hash.fetch("fee", nil) self.fee = ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.fee) if !self.currency.to_s.empty? && !self.fee.nil? self.balance = hash.fetch("balance", nil) self.balance = ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.balance) if !self.currency.to_s.empty? && !self.balance.nil? self.description = hash.fetch("description", nil) self.rate = hash.fetch("rate", nil) self.direction = hash.fetch("direction", nil) self.counterpart = {} self.counterpart[:currency] = hash.fetch("counterpart", {}).fetch("currency", nil) self.counterpart[:amount] = hash.fetch("counterpart", {}).fetch("amount", nil) self.counterpart[:amount] = ::Revolut::Api::Utilities.convert_from_integer_amount(self.counterpart[:currency], self.counterpart[:amount]) if !self.counterpart[:currency].to_s.empty? && !self.counterpart[:amount].nil? merchant_data = hash.fetch("merchant", {}) self.merchant = ::Revolut::Api::Response::Merchant.new(merchant_data) if !merchant_data.empty? self.card = {} self.card[:last_four] = hash.fetch("card", {}).fetch("lastFour", nil) end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
8 9 10 |
# File 'lib/revolut/api/response/transaction.rb', line 8 def amount @amount end |
#balance ⇒ Object
Returns the value of attribute balance.
8 9 10 |
# File 'lib/revolut/api/response/transaction.rb', line 8 def balance @balance end |
#card ⇒ Object
Returns the value of attribute card.
10 11 12 |
# File 'lib/revolut/api/response/transaction.rb', line 10 def card @card end |
#completed_date ⇒ Object
Returns the value of attribute completed_date.
7 8 9 |
# File 'lib/revolut/api/response/transaction.rb', line 7 def completed_date @completed_date end |
#counterpart ⇒ Object
Returns the value of attribute counterpart.
9 10 11 |
# File 'lib/revolut/api/response/transaction.rb', line 9 def counterpart @counterpart end |
#currency ⇒ Object
Returns the value of attribute currency.
8 9 10 |
# File 'lib/revolut/api/response/transaction.rb', line 8 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/revolut/api/response/transaction.rb', line 8 def description @description end |
#direction ⇒ Object
Returns the value of attribute direction.
9 10 11 |
# File 'lib/revolut/api/response/transaction.rb', line 9 def direction @direction end |
#fee ⇒ Object
Returns the value of attribute fee.
8 9 10 |
# File 'lib/revolut/api/response/transaction.rb', line 8 def fee @fee end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/revolut/api/response/transaction.rb', line 5 def id @id end |
#leg_id ⇒ Object
Returns the value of attribute leg_id.
5 6 7 |
# File 'lib/revolut/api/response/transaction.rb', line 5 def leg_id @leg_id end |
#merchant ⇒ Object
Returns the value of attribute merchant.
10 11 12 |
# File 'lib/revolut/api/response/transaction.rb', line 10 def merchant @merchant end |
#rate ⇒ Object
Returns the value of attribute rate.
8 9 10 |
# File 'lib/revolut/api/response/transaction.rb', line 8 def rate @rate end |
#started_date ⇒ Object
Returns the value of attribute started_date.
7 8 9 |
# File 'lib/revolut/api/response/transaction.rb', line 7 def started_date @started_date end |
#state ⇒ Object
Returns the value of attribute state.
6 7 8 |
# File 'lib/revolut/api/response/transaction.rb', line 6 def state @state end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/revolut/api/response/transaction.rb', line 6 def type @type end |
#updated_date ⇒ Object
Returns the value of attribute updated_date.
7 8 9 |
# File 'lib/revolut/api/response/transaction.rb', line 7 def updated_date @updated_date end |
Instance Method Details
#completed? ⇒ Boolean
52 53 54 |
# File 'lib/revolut/api/response/transaction.rb', line 52 def completed? in_state?(:completed) end |
#in_state?(state) ⇒ Boolean
60 61 62 |
# File 'lib/revolut/api/response/transaction.rb', line 60 def in_state?(state) self.state.downcase.strip.to_sym.eql?(state) end |
#pending? ⇒ Boolean
56 57 58 |
# File 'lib/revolut/api/response/transaction.rb', line 56 def pending? in_state?(:pending) end |