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.
-
#memo ⇒ String
The payment memo.
-
#original_amount ⇒ String
The full, original amount of the payment transaction as a string in full units.
-
#payment_method ⇒ Object
A nested data structure detailing the method of 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(memo = SKIP, original_amount = SKIP, applied_amount = SKIP, transaction_time = SKIP, payment_method = SKIP, transaction_id = SKIP) ⇒ ApplyPaymentEventData
constructor
A new instance of ApplyPaymentEventData.
- #to_custom_transaction_time ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(memo = SKIP, original_amount = SKIP, applied_amount = SKIP, transaction_time = SKIP, payment_method = SKIP, transaction_id = SKIP) ⇒ ApplyPaymentEventData
Returns a new instance of ApplyPaymentEventData.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 75 def initialize(memo = SKIP, original_amount = SKIP, applied_amount = SKIP, transaction_time = SKIP, payment_method = SKIP, transaction_id = SKIP) @memo = memo unless memo == SKIP @original_amount = original_amount unless original_amount == SKIP @applied_amount = applied_amount unless applied_amount == SKIP @transaction_time = transaction_time unless transaction_time == SKIP @payment_method = payment_method unless payment_method == SKIP @transaction_id = transaction_id unless transaction_id == SKIP 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”`.
31 32 33 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 31 def applied_amount @applied_amount end |
#memo ⇒ String
The payment memo
15 16 17 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 15 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”`.
23 24 25 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 23 def original_amount @original_amount end |
#payment_method ⇒ Object
A nested data structure detailing the method of payment
40 41 42 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 40 def payment_method @payment_method end |
#transaction_id ⇒ Integer
The Chargify id of the original payment
44 45 46 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 44 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”
36 37 38 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 36 def transaction_time @transaction_time end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 87 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. 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 transaction_time = if hash.key?('transaction_time') (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time']) else SKIP end payment_method = hash.key?('payment_method') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:ApplyPaymentEventDataPaymentMethod), hash['payment_method'] ) : SKIP transaction_id = hash.key?('transaction_id') ? hash['transaction_id'] : SKIP # Create object from extracted values. ApplyPaymentEventData.new(memo, original_amount, applied_amount, transaction_time, payment_method, transaction_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_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 end |
.nullables ⇒ Object
An array for nullable fields
71 72 73 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 71 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 59 def self.optionals %w[ memo original_amount applied_amount transaction_time payment_method transaction_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
122 123 124 125 126 127 128 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 122 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_time ⇒ Object
116 117 118 |
# File 'lib/advanced_billing/models/apply_payment_event_data.rb', line 116 def to_custom_transaction_time DateTimeHelper.to_rfc3339(transaction_time) end |