Class: AdvancedBilling::InvoicePayment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/invoice_payment.rb

Overview

InvoicePayment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(transaction_time: SKIP, memo: SKIP, original_amount: SKIP, applied_amount: SKIP, payment_method: SKIP, transaction_id: SKIP, prepayment: SKIP, gateway_handle: SKIP, gateway_used: SKIP, gateway_transaction_id: SKIP, received_on: SKIP, uid: SKIP, additional_properties: {}) ⇒ InvoicePayment

Returns a new instance of InvoicePayment.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/advanced_billing/models/invoice_payment.rb', line 110

def initialize(transaction_time: SKIP, memo: SKIP, original_amount: SKIP,
               applied_amount: SKIP, payment_method: SKIP,
               transaction_id: SKIP, prepayment: SKIP, gateway_handle: SKIP,
               gateway_used: SKIP, gateway_transaction_id: SKIP,
               received_on: SKIP, uid: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @transaction_time = transaction_time unless transaction_time == SKIP
  @memo = memo unless memo == SKIP
  @original_amount = original_amount unless original_amount == SKIP
  @applied_amount = applied_amount unless applied_amount == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @transaction_id = transaction_id unless transaction_id == SKIP
  @prepayment = prepayment unless prepayment == SKIP
  @gateway_handle = gateway_handle unless gateway_handle == SKIP
  @gateway_used = gateway_used unless gateway_used == SKIP
  @gateway_transaction_id = gateway_transaction_id unless gateway_transaction_id == SKIP
  @received_on = received_on unless received_on == SKIP
  @uid = uid unless uid == SKIP
end

Instance Attribute Details

#applied_amountString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/advanced_billing/models/invoice_payment.rb', line 27

def applied_amount
  @applied_amount
end

#gateway_handleString

TODO: Write general description for this method

Returns:

  • (String)


43
44
45
# File 'lib/advanced_billing/models/invoice_payment.rb', line 43

def gateway_handle
  @gateway_handle
end

#gateway_transaction_idString

The transaction ID for the payment as returned from the payment gateway

Returns:

  • (String)


51
52
53
# File 'lib/advanced_billing/models/invoice_payment.rb', line 51

def gateway_transaction_id
  @gateway_transaction_id
end

#gateway_usedString

TODO: Write general description for this method

Returns:

  • (String)


47
48
49
# File 'lib/advanced_billing/models/invoice_payment.rb', line 47

def gateway_used
  @gateway_used
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/invoice_payment.rb', line 19

def memo
  @memo
end

#original_amountString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/invoice_payment.rb', line 23

def original_amount
  @original_amount
end

#payment_methodInvoicePaymentMethod

TODO: Write general description for this method



31
32
33
# File 'lib/advanced_billing/models/invoice_payment.rb', line 31

def payment_method
  @payment_method
end

#prepaymentTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


39
40
41
# File 'lib/advanced_billing/models/invoice_payment.rb', line 39

def prepayment
  @prepayment
end

#received_onDate

Date reflecting when the payment was received from a customer. Must be in the past. Applicable only to ‘external` payments.

Returns:

  • (Date)


57
58
59
# File 'lib/advanced_billing/models/invoice_payment.rb', line 57

def received_on
  @received_on
end

#transaction_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


35
36
37
# File 'lib/advanced_billing/models/invoice_payment.rb', line 35

def transaction_id
  @transaction_id
end

#transaction_timeDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


15
16
17
# File 'lib/advanced_billing/models/invoice_payment.rb', line 15

def transaction_time
  @transaction_time
end

#uidString

Date reflecting when the payment was received from a customer. Must be in the past. Applicable only to ‘external` payments.

Returns:

  • (String)


63
64
65
# File 'lib/advanced_billing/models/invoice_payment.rb', line 63

def uid
  @uid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/advanced_billing/models/invoice_payment.rb', line 135

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_time = if hash.key?('transaction_time')
                       (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time'])
                     else
                       SKIP
                     end
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  original_amount =
    hash.key?('original_amount') ? hash['original_amount'] : SKIP
  applied_amount =
    hash.key?('applied_amount') ? hash['applied_amount'] : SKIP
  payment_method = InvoicePaymentMethod.from_hash(hash['payment_method']) if
    hash['payment_method']
  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : SKIP
  prepayment = hash.key?('prepayment') ? hash['prepayment'] : SKIP
  gateway_handle =
    hash.key?('gateway_handle') ? hash['gateway_handle'] : SKIP
  gateway_used = hash.key?('gateway_used') ? hash['gateway_used'] : SKIP
  gateway_transaction_id =
    hash.key?('gateway_transaction_id') ? hash['gateway_transaction_id'] : SKIP
  received_on = hash.key?('received_on') ? hash['received_on'] : SKIP
  uid = hash.key?('uid') ? hash['uid'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  InvoicePayment.new(transaction_time: transaction_time,
                     memo: memo,
                     original_amount: original_amount,
                     applied_amount: applied_amount,
                     payment_method: payment_method,
                     transaction_id: transaction_id,
                     prepayment: prepayment,
                     gateway_handle: gateway_handle,
                     gateway_used: gateway_used,
                     gateway_transaction_id: gateway_transaction_id,
                     received_on: received_on,
                     uid: uid,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/advanced_billing/models/invoice_payment.rb', line 66

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_time'] = 'transaction_time'
  @_hash['memo'] = 'memo'
  @_hash['original_amount'] = 'original_amount'
  @_hash['applied_amount'] = 'applied_amount'
  @_hash['payment_method'] = 'payment_method'
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['prepayment'] = 'prepayment'
  @_hash['gateway_handle'] = 'gateway_handle'
  @_hash['gateway_used'] = 'gateway_used'
  @_hash['gateway_transaction_id'] = 'gateway_transaction_id'
  @_hash['received_on'] = 'received_on'
  @_hash['uid'] = 'uid'
  @_hash
end

.nullablesObject

An array for nullable fields



102
103
104
105
106
107
108
# File 'lib/advanced_billing/models/invoice_payment.rb', line 102

def self.nullables
  %w[
    gateway_handle
    gateway_transaction_id
    received_on
  ]
end

.optionalsObject

An array for optional fields



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/advanced_billing/models/invoice_payment.rb', line 84

def self.optionals
  %w[
    transaction_time
    memo
    original_amount
    applied_amount
    payment_method
    transaction_id
    prepayment
    gateway_handle
    gateway_used
    gateway_transaction_id
    received_on
    uid
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoicePayment | Hash)

    value against the validation is performed.



187
188
189
190
191
192
193
# File 'lib/advanced_billing/models/invoice_payment.rb', line 187

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#to_custom_transaction_timeObject



181
182
183
# File 'lib/advanced_billing/models/invoice_payment.rb', line 181

def to_custom_transaction_time
  DateTimeHelper.to_rfc3339(transaction_time)
end