Class: AdvancedBilling::ApplyPaymentEventData
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ApplyPaymentEventData
- Defined in:
- lib/advanced_billing/models/apply_payment_event_data.rb
Overview
Example schema for an ‘apply_payment` event
Instance Attribute Summary collapse
-
#applied_amount ⇒ String
The amount of the payment applied to this invoice.
-
#consolidation_level ⇒ InvoiceConsolidationLevel
TODO: Write general description for this method.
-
#external ⇒ TrueClass | FalseClass
The Chargify id of the original payment.
-
#memo ⇒ String
The payment memo.
-
#original_amount ⇒ String
The full, original amount of the payment transaction as a string in full units.
-
#parent_invoice_number ⇒ Integer
The Chargify id of the original payment.
-
#payment_method ⇒ Object
A nested data structure detailing the method of payment.
-
#prepayment ⇒ TrueClass | FalseClass
The Chargify id of the original payment.
-
#remaining_prepayment_amount ⇒ String
The Chargify id of the original payment.
-
#transaction_id ⇒ Integer
The Chargify id of the original payment.
-
#transaction_time ⇒ DateTime
The time the payment was applied, in ISO 8601 format, i.e.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(consolidation_level:, memo:, original_amount:, applied_amount:, transaction_time:, payment_method:, transaction_id: SKIP, parent_invoice_number: SKIP, remaining_prepayment_amount: SKIP, prepayment: SKIP, external: SKIP, additional_properties: {}) ⇒ ApplyPaymentEventData
constructor
A new instance of ApplyPaymentEventData.
- #to_custom_transaction_time ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(consolidation_level:, memo:, original_amount:, applied_amount:, transaction_time:, payment_method:, transaction_id: SKIP, parent_invoice_number: SKIP, remaining_prepayment_amount: SKIP, prepayment: SKIP, external: SKIP, additional_properties: {}) ⇒ ApplyPaymentEventData
Returns a new instance of ApplyPaymentEventData.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 102 def initialize(consolidation_level:, memo:, original_amount:, applied_amount:, transaction_time:, payment_method:, transaction_id: SKIP, parent_invoice_number: SKIP, remaining_prepayment_amount: SKIP, prepayment: SKIP, external: SKIP, additional_properties: {}) @consolidation_level = consolidation_level @memo = memo @original_amount = original_amount @applied_amount = applied_amount @transaction_time = transaction_time @payment_method = payment_method @transaction_id = transaction_id unless transaction_id == SKIP @parent_invoice_number = parent_invoice_number unless parent_invoice_number == SKIP unless remaining_prepayment_amount == SKIP @remaining_prepayment_amount = remaining_prepayment_amount end @prepayment = prepayment unless prepayment == SKIP @external = external unless external == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#applied_amount ⇒ String
The amount of the payment applied to this invoice. Incoming payments can be split amongst several invoices, which will result in a ‘applied_amount` less than the `original_amount`. Example: A $100.99 payment, of which $40.11 is applied to this invoice, will have an `applied_amount` of `“40.11”`.
35 36 37 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 35 def applied_amount @applied_amount end |
#consolidation_level ⇒ InvoiceConsolidationLevel
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 15 def consolidation_level @consolidation_level end |
#external ⇒ TrueClass | FalseClass
The Chargify id of the original payment
64 65 66 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 64 def external @external end |
#memo ⇒ String
The payment memo
19 20 21 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 19 def memo @memo end |
#original_amount ⇒ String
The full, original amount of the payment transaction as a string in full units. Incoming payments can be split amongst several invoices, which will result in a ‘applied_amount` less than the `original_amount`. Example: A $100.99 payment, of which $40.11 is applied to this invoice, will have an `original_amount` of `“100.99”`.
27 28 29 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 27 def original_amount @original_amount end |
#parent_invoice_number ⇒ Integer
The Chargify id of the original payment
52 53 54 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 52 def parent_invoice_number @parent_invoice_number end |
#payment_method ⇒ Object
A nested data structure detailing the method of payment
44 45 46 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 44 def payment_method @payment_method end |
#prepayment ⇒ TrueClass | FalseClass
The Chargify id of the original payment
60 61 62 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 60 def prepayment @prepayment end |
#remaining_prepayment_amount ⇒ String
The Chargify id of the original payment
56 57 58 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 56 def remaining_prepayment_amount @remaining_prepayment_amount end |
#transaction_id ⇒ Integer
The Chargify id of the original payment
48 49 50 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 48 def transaction_id @transaction_id end |
#transaction_time ⇒ DateTime
The time the payment was applied, in ISO 8601 format, i.e. “2019-06-07T17:20:06Z”
40 41 42 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 40 def transaction_time @transaction_time end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
129 130 131 132 133 134 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 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 129 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. consolidation_level = hash.key?('consolidation_level') ? hash['consolidation_level'] : nil memo = hash.key?('memo') ? hash['memo'] : nil original_amount = hash.key?('original_amount') ? hash['original_amount'] : nil applied_amount = hash.key?('applied_amount') ? hash['applied_amount'] : nil transaction_time = if hash.key?('transaction_time') (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time']) end payment_method = hash.key?('payment_method') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:InvoiceEventPayment), hash['payment_method'] ) : nil transaction_id = hash.key?('transaction_id') ? hash['transaction_id'] : SKIP parent_invoice_number = hash.key?('parent_invoice_number') ? hash['parent_invoice_number'] : SKIP remaining_prepayment_amount = hash.key?('remaining_prepayment_amount') ? hash['remaining_prepayment_amount'] : SKIP prepayment = hash.key?('prepayment') ? hash['prepayment'] : SKIP external = hash.key?('external') ? hash['external'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. ApplyPaymentEventData.new(consolidation_level: consolidation_level, memo: memo, original_amount: original_amount, applied_amount: applied_amount, transaction_time: transaction_time, payment_method: payment_method, transaction_id: transaction_id, parent_invoice_number: parent_invoice_number, remaining_prepayment_amount: remaining_prepayment_amount, prepayment: prepayment, external: external, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 67 def self.names @_hash = {} if @_hash.nil? @_hash['consolidation_level'] = 'consolidation_level' @_hash['memo'] = 'memo' @_hash['original_amount'] = 'original_amount' @_hash['applied_amount'] = 'applied_amount' @_hash['transaction_time'] = 'transaction_time' @_hash['payment_method'] = 'payment_method' @_hash['transaction_id'] = 'transaction_id' @_hash['parent_invoice_number'] = 'parent_invoice_number' @_hash['remaining_prepayment_amount'] = 'remaining_prepayment_amount' @_hash['prepayment'] = 'prepayment' @_hash['external'] = 'external' @_hash end |
.nullables ⇒ Object
An array for nullable fields
95 96 97 98 99 100 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 95 def self.nullables %w[ parent_invoice_number remaining_prepayment_amount ] end |
.optionals ⇒ Object
An array for optional fields
84 85 86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 84 def self.optionals %w[ transaction_id parent_invoice_number remaining_prepayment_amount prepayment external ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 179 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.consolidation_level, ->(val) { InvoiceConsolidationLevel.validate(val) }) and APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.original_amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.applied_amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.transaction_time, ->(val) { val.instance_of? DateTime }) and UnionTypeLookUp.get(:InvoiceEventPayment) .validate(value.payment_method) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['consolidation_level'], ->(val) { InvoiceConsolidationLevel.validate(val) }) and APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['original_amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['applied_amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['transaction_time'], ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:InvoiceEventPayment) .validate(value['payment_method']) ) end |
Instance Method Details
#to_custom_transaction_time ⇒ Object
173 174 175 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 173 def to_custom_transaction_time DateTimeHelper.to_rfc3339(transaction_time) end |