Class: PaymentsApi::Payment

Inherits:
BaseModel show all
Defined in:
lib/payments_api/models/payment.rb

Overview

Payment Information Object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(quote_id = nil, originator = nil, beneficiary = nil, beneficiary_bank_account = nil, details = nil, id = nil, originator_bank_account = nil, intermediary_bank_account = nil, status = nil) ⇒ Payment

Returns a new instance of Payment.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/payments_api/models/payment.rb', line 72

def initialize(quote_id = nil,
               originator = nil,
               beneficiary = nil,
                = nil,
               details = nil,
               id = nil,
                = nil,
                = nil,
               status = nil)
  @id = id
  @quote_id = quote_id
  @originator = originator
  @originator_bank_account = 
  @beneficiary = beneficiary
  @beneficiary_bank_account = 
  @intermediary_bank_account = 
  @details = details
  @status = status
end

Instance Attribute Details

#beneficiaryBeneficiary

Beneficiary Information Object

Returns:



31
32
33
# File 'lib/payments_api/models/payment.rb', line 31

def beneficiary
  @beneficiary
end

#beneficiary_bank_accountBankAccount

Bank Account Information Object.NOTE - originatorBankAccount bank data should not be provided when creating a new Payment. This information is retrieved from the database based on the provided bank ID.NOTE - bank object is required for all BankAccount objects except originatorBankAccount

Returns:



39
40
41
# File 'lib/payments_api/models/payment.rb', line 39

def 
  @beneficiary_bank_account
end

#detailsPaymentDetails

Payment Information Data

Returns:



51
52
53
# File 'lib/payments_api/models/payment.rb', line 51

def details
  @details
end

#idInteger

Payment ID

Returns:

  • (Integer)


11
12
13
# File 'lib/payments_api/models/payment.rb', line 11

def id
  @id
end

#intermediary_bank_accountBankAccount

Bank Account Information Object.NOTE - originatorBankAccount bank data should not be provided when creating a new Payment. This information is retrieved from the database based on the provided bank ID.NOTE - bank object is required for all BankAccount objects except originatorBankAccount

Returns:



47
48
49
# File 'lib/payments_api/models/payment.rb', line 47

def 
  @intermediary_bank_account
end

#originatorOriginator

Originator Information Object

Returns:



19
20
21
# File 'lib/payments_api/models/payment.rb', line 19

def originator
  @originator
end

#originator_bank_accountBankAccount

Bank Account Information Object.NOTE - originatorBankAccount bank data should not be provided when creating a new Payment. This information is retrieved from the database based on the provided bank ID.NOTE - bank object is required for all BankAccount objects except originatorBankAccount

Returns:



27
28
29
# File 'lib/payments_api/models/payment.rb', line 27

def 
  @originator_bank_account
end

#quote_idInteger

Quote ID

Returns:

  • (Integer)


15
16
17
# File 'lib/payments_api/models/payment.rb', line 15

def quote_id
  @quote_id
end

#statusPaymentStatus

Payment Information Data

Returns:



55
56
57
# File 'lib/payments_api/models/payment.rb', line 55

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/payments_api/models/payment.rb', line 93

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  quote_id = hash['quoteId']
  originator = Originator.from_hash(hash['originator']) if
    hash['originator']
  beneficiary = Beneficiary.from_hash(hash['beneficiary']) if
    hash['beneficiary']
  if hash['beneficiaryBankAccount']
     = BankAccount.from_hash(hash['beneficiaryBankAccount'])
  end
  details = PaymentDetails.from_hash(hash['details']) if hash['details']
  id = hash['id']
  if hash['originatorBankAccount']
     = BankAccount.from_hash(hash['originatorBankAccount'])
  end
  if hash['intermediaryBankAccount']
     = BankAccount.from_hash(hash['intermediaryBankAccount'])
  end
  status = PaymentStatus.from_hash(hash['status']) if hash['status']

  # Create object from extracted values.
  Payment.new(quote_id,
              originator,
              beneficiary,
              ,
              details,
              id,
              ,
              ,
              status)
end

.namesObject

A mapping from model property names to API property names.



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/payments_api/models/payment.rb', line 58

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['quote_id'] = 'quoteId'
  @_hash['originator'] = 'originator'
  @_hash['originator_bank_account'] = 'originatorBankAccount'
  @_hash['beneficiary'] = 'beneficiary'
  @_hash['beneficiary_bank_account'] = 'beneficiaryBankAccount'
  @_hash['intermediary_bank_account'] = 'intermediaryBankAccount'
  @_hash['details'] = 'details'
  @_hash['status'] = 'status'
  @_hash
end