Class: AdvancedBilling::FailedPaymentEventData
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::FailedPaymentEventData
- Defined in:
- lib/advanced_billing/models/failed_payment_event_data.rb
Overview
Example schema for an ‘failed_payment` event
Instance Attribute Summary collapse
-
#amount_in_cents ⇒ Integer
The monetary value of the payment, expressed in cents.
-
#applied_amount ⇒ Integer
The monetary value of the payment, expressed in dollars.
-
#memo ⇒ String
The memo passed when the payment was created.
-
#payment_method ⇒ InvoicePaymentMethodType
The memo passed when the payment was created.
-
#transaction_id ⇒ Integer
The transaction ID of the failed payment.
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(amount_in_cents:, applied_amount:, payment_method:, transaction_id:, memo: SKIP, additional_properties: {}) ⇒ FailedPaymentEventData
constructor
A new instance of FailedPaymentEventData.
Methods inherited from BaseModel
Constructor Details
#initialize(amount_in_cents:, applied_amount:, payment_method:, transaction_id:, memo: SKIP, additional_properties: {}) ⇒ FailedPaymentEventData
Returns a new instance of FailedPaymentEventData.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 57 def initialize(amount_in_cents:, applied_amount:, payment_method:, transaction_id:, memo: SKIP, additional_properties: {}) @amount_in_cents = amount_in_cents @applied_amount = applied_amount @memo = memo unless memo == SKIP @payment_method = payment_method @transaction_id = transaction_id # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#amount_in_cents ⇒ Integer
The monetary value of the payment, expressed in cents.
14 15 16 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 14 def amount_in_cents @amount_in_cents end |
#applied_amount ⇒ Integer
The monetary value of the payment, expressed in dollars.
18 19 20 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 18 def applied_amount @applied_amount end |
#memo ⇒ String
The memo passed when the payment was created.
22 23 24 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 22 def memo @memo end |
#payment_method ⇒ InvoicePaymentMethodType
The memo passed when the payment was created.
26 27 28 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 26 def payment_method @payment_method end |
#transaction_id ⇒ Integer
The transaction ID of the failed payment.
30 31 32 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 30 def transaction_id @transaction_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount_in_cents = hash.key?('amount_in_cents') ? hash['amount_in_cents'] : nil applied_amount = hash.key?('applied_amount') ? hash['applied_amount'] : nil payment_method = hash.key?('payment_method') ? hash['payment_method'] : nil transaction_id = hash.key?('transaction_id') ? hash['transaction_id'] : nil memo = hash.key?('memo') ? hash['memo'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. FailedPaymentEventData.new(amount_in_cents: amount_in_cents, applied_amount: applied_amount, payment_method: payment_method, transaction_id: transaction_id, memo: memo, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['amount_in_cents'] = 'amount_in_cents' @_hash['applied_amount'] = 'applied_amount' @_hash['memo'] = 'memo' @_hash['payment_method'] = 'payment_method' @_hash['transaction_id'] = 'transaction_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
51 52 53 54 55 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 51 def self.nullables %w[ memo ] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 44 def self.optionals %w[ memo ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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 126 |
# File 'lib/advanced_billing/models/failed_payment_event_data.rb', line 100 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.amount_in_cents, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.applied_amount, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.payment_method, ->(val) { InvoicePaymentMethodType.validate(val) }) and APIHelper.valid_type?(value.transaction_id, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['amount_in_cents'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['applied_amount'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['payment_method'], ->(val) { InvoicePaymentMethodType.validate(val) }) and APIHelper.valid_type?(value['transaction_id'], ->(val) { val.instance_of? Integer }) ) end |