Class: AdvancedBilling::VoidInvoiceEventData
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::VoidInvoiceEventData
- Defined in:
- lib/advanced_billing/models/void_invoice_event_data.rb
Overview
Example schema for an ‘void_invoice` event
Instance Attribute Summary collapse
-
#applied_amount ⇒ String
The amount of the void.
-
#credit_note_attributes ⇒ CreditNote
TODO: Write general description for this method.
-
#is_advance_invoice ⇒ TrueClass | FalseClass
If true, the invoice is an advance invoice.
-
#memo ⇒ String
The memo provided during invoice voiding.
-
#reason ⇒ String
The reason for the void.
-
#transaction_time ⇒ DateTime
The time the refund 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(credit_note_attributes:, memo:, applied_amount:, transaction_time:, is_advance_invoice:, reason:, additional_properties: {}) ⇒ VoidInvoiceEventData
constructor
A new instance of VoidInvoiceEventData.
- #to_custom_transaction_time ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(credit_note_attributes:, memo:, applied_amount:, transaction_time:, is_advance_invoice:, reason:, additional_properties: {}) ⇒ VoidInvoiceEventData
Returns a new instance of VoidInvoiceEventData.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 65 def initialize(credit_note_attributes:, memo:, applied_amount:, transaction_time:, is_advance_invoice:, reason:, additional_properties: {}) @credit_note_attributes = credit_note_attributes @memo = memo @applied_amount = applied_amount @transaction_time = transaction_time @is_advance_invoice = is_advance_invoice @reason = reason # 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 void.
23 24 25 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 23 def applied_amount @applied_amount end |
#credit_note_attributes ⇒ CreditNote
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 15 def credit_note_attributes @credit_note_attributes end |
#is_advance_invoice ⇒ TrueClass | FalseClass
If true, the invoice is an advance invoice.
32 33 34 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 32 def is_advance_invoice @is_advance_invoice end |
#memo ⇒ String
The memo provided during invoice voiding.
19 20 21 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 19 def memo @memo end |
#reason ⇒ String
The reason for the void.
36 37 38 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 36 def reason @reason end |
#transaction_time ⇒ DateTime
The time the refund was applied, in ISO 8601 format, i.e. “2019-06-07T17:20:06Z”
28 29 30 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 28 def transaction_time @transaction_time end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 82 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. credit_note_attributes = CreditNote.from_hash(hash['credit_note_attributes']) if hash['credit_note_attributes'] memo = hash.key?('memo') ? hash['memo'] : 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 is_advance_invoice = hash.key?('is_advance_invoice') ? hash['is_advance_invoice'] : nil reason = hash.key?('reason') ? hash['reason'] : nil # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. VoidInvoiceEventData.new(credit_note_attributes: credit_note_attributes, memo: memo, applied_amount: applied_amount, transaction_time: transaction_time, is_advance_invoice: is_advance_invoice, reason: reason, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['credit_note_attributes'] = 'credit_note_attributes' @_hash['memo'] = 'memo' @_hash['applied_amount'] = 'applied_amount' @_hash['transaction_time'] = 'transaction_time' @_hash['is_advance_invoice'] = 'is_advance_invoice' @_hash['reason'] = 'reason' @_hash end |
.nullables ⇒ Object
An array for nullable fields
56 57 58 59 60 61 62 63 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 56 def self.nullables %w[ credit_note_attributes memo applied_amount transaction_time ] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 51 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
117 118 119 120 121 122 123 124 125 126 127 128 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 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 117 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.credit_note_attributes, ->(val) { CreditNote.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.memo, ->(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 APIHelper.valid_type?(value.is_advance_invoice, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.reason, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['credit_note_attributes'], ->(val) { CreditNote.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['memo'], ->(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 APIHelper.valid_type?(value['is_advance_invoice'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['reason'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#to_custom_transaction_time ⇒ Object
111 112 113 |
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 111 def to_custom_transaction_time DateTimeHelper.to_rfc3339(transaction_time) end |