Class: SixSaferpay::Transaction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, status:, id:, capture_id: nil, date:, amount:, order_id: nil, acquirer_name: nil, acquirer_reference: nil, six_transaction_reference:, approval_code: nil, direct_debit: nil, invoice: nil) ⇒ Transaction

Returns a new instance of Transaction.



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
# File 'lib/six_saferpay/models/transaction.rb', line 20

def initialize(type:,
               status:,
               id:,
               capture_id: nil,
               date:,
               amount:,
               order_id: nil,
               acquirer_name: nil,
               acquirer_reference: nil,
               six_transaction_reference:,
               approval_code: nil,
               direct_debit: nil,
               invoice: nil
              )
  @type = type
  @status = status
  @id = id
  @capture_id = capture_id
  @date = date
  @amount = SixSaferpay::Amount.new(**amount.to_h)
  @order_id = order_id
  @acquirer_name = acquirer_name
  @acquirer_reference = acquirer_reference
  @six_transaction_reference = six_transaction_reference
  @approval_code = approval_code
  @direct_debit = SixSaferpay::DirectDebit.new(**direct_debit.to_h) if direct_debit
  @invoice = SixSaferpay::Invoice.new(**invoice.to_h) if invoice
end

Instance Attribute Details

#acquirer_nameObject

Returns the value of attribute acquirer_name.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def acquirer_name
  @acquirer_name
end

#acquirer_referenceObject

Returns the value of attribute acquirer_reference.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def acquirer_reference
  @acquirer_reference
end

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def amount
  @amount
end

#approval_codeObject

Returns the value of attribute approval_code.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def approval_code
  @approval_code
end

#capture_idObject

Returns the value of attribute capture_id.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def capture_id
  @capture_id
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def date
  @date
end

#direct_debitObject

Returns the value of attribute direct_debit.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def direct_debit
  @direct_debit
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def id
  @id
end

#invoiceObject

Returns the value of attribute invoice.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def invoice
  @invoice
end

#order_idObject

Returns the value of attribute order_id.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def order_id
  @order_id
end

#six_transaction_referenceObject

Returns the value of attribute six_transaction_reference.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def six_transaction_reference
  @six_transaction_reference
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def status
  @status
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/six_saferpay/models/transaction.rb', line 4

def type
  @type
end

Instance Method Details

#to_hashObject Also known as: to_h



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/six_saferpay/models/transaction.rb', line 49

def to_hash
  hash = Hash.new
  hash.merge!(type: @type)
  hash.merge!(status: @status)
  hash.merge!(id: @id)
  hash.merge!(capture_id: @capture_id) if @capture_id
  hash.merge!(date: @date)
  hash.merge!(amount: @amount.to_h)
  hash.merge!(order_id: @order_id) if @order_id
  hash.merge!(acquirer_name: @acquirer_name) if @acquirer_name
  hash.merge!(acquirer_reference: @acquirer_reference) if @acquirer_reference
  hash.merge!(six_transaction_reference: @six_transaction_reference)
  hash.merge!(approval_code: @approval_code) if @approval_code
  hash.merge!(direct_debit: @direct_debit.to_h) if @direct_debit
  hash.merge!(invoice: @invoice.to_h) if @invoice
  hash
end