Class: InvestecOpenApi::Models::Transaction

Inherits:
Base
  • Object
show all
Defined in:
lib/investec_open_api/models/transaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

convert_param_value_to_date, convert_param_value_to_money, rewrite_param_key

Constructor Details

#initialize(params) ⇒ Transaction

Returns a new instance of Transaction.



27
28
29
30
# File 'lib/investec_open_api/models/transaction.rb', line 27

def initialize(params)
  super
  set_id
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def 
  @account_id
end

#action_dateObject (readonly)

Returns the value of attribute action_date.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def action_date
  @action_date
end

#amountObject (readonly)

Returns the value of attribute amount.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def amount
  @amount
end

#card_numberObject (readonly)

Returns the value of attribute card_number.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def card_number
  @card_number
end

#dateObject (readonly)

Returns the value of attribute date.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def id
  @id
end

#posted_orderObject (readonly)

Returns the value of attribute posted_order.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def posted_order
  @posted_order
end

#posting_dateObject (readonly)

Returns the value of attribute posting_date.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def posting_date
  @posting_date
end

#running_balanceObject (readonly)

Returns the value of attribute running_balance.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def running_balance
  @running_balance
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def status
  @status
end

#transaction_typeObject (readonly)

Returns the value of attribute transaction_type.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def transaction_type
  @transaction_type
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def type
  @type
end

#uuidObject (readonly)

Unique identifier Composite key generated by Investec using the following formula: account_id.slice(0, 5) + posting_date.gsub(/-/, “”) + posted_order.to_s.rjust(7, “0”) This will only be populated for posted transaction on Private Bank Accounts. This is not a backend banking generated ID and will change if any of the properties making it up changes.



25
26
27
# File 'lib/investec_open_api/models/transaction.rb', line 25

def uuid
  @uuid
end

#value_dateObject (readonly)

Returns the value of attribute value_date.



5
6
7
# File 'lib/investec_open_api/models/transaction.rb', line 5

def value_date
  @value_date
end

Class Method Details

.from_api(params, currency = "ZAR") ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/investec_open_api/models/transaction.rb', line 42

def self.from_api(params, currency = "ZAR")
  params["currency"] = currency
  should_make_amount_negative = params['type'] == 'DEBIT'
  convert_param_value_to_money(params, "amount", "currency", should_make_amount_negative)
  convert_param_value_to_money(params, "runningBalance")
  rewrite_param_key(params, "transactionDate", "date")
  convert_param_value_to_date(params, "date")
  convert_param_value_to_date(params, "postingDate")
  convert_param_value_to_date(params, "valueDate")
  convert_param_value_to_date(params, "actionDate")
  new params
end

Instance Method Details

#set_idObject

Investec exposes a uuid for uniqueness so this is no longer needed (non-pending transactions). It is kept here for legacy purposes. It is also useful for pending transactions.



34
35
36
37
38
39
40
# File 'lib/investec_open_api/models/transaction.rb', line 34

def set_id
  @id = [
    amount.to_i,
    description,
    date.to_s
  ].map(&:to_s).join('-')
end