Class: AdvancedBilling::ApplyDebitNoteEventData
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ApplyDebitNoteEventData
- Defined in:
- lib/advanced_billing/models/apply_debit_note_event_data.rb
Overview
Example schema for an ‘apply_debit_note` event
Instance Attribute Summary collapse
-
#applied_amount ⇒ String
The amount of the debit note applied to invoice.
-
#debit_note_number ⇒ String
A unique, identifying string that appears on the debit note and in places it is referenced.
-
#debit_note_uid ⇒ String
Unique identifier for the debit note.
-
#memo ⇒ String
The debit note memo.
-
#original_amount ⇒ String
The full, original amount of the debit note.
-
#transaction_time ⇒ DateTime
The time the debit note 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(debit_note_number:, debit_note_uid:, original_amount:, applied_amount:, memo: SKIP, transaction_time: SKIP, additional_properties: {}) ⇒ ApplyDebitNoteEventData
constructor
A new instance of ApplyDebitNoteEventData.
- #to_custom_transaction_time ⇒ Object
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(debit_note_number:, debit_note_uid:, original_amount:, applied_amount:, memo: SKIP, transaction_time: SKIP, additional_properties: {}) ⇒ ApplyDebitNoteEventData
Returns a new instance of ApplyDebitNoteEventData.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 68 def initialize(debit_note_number:, debit_note_uid:, original_amount:, applied_amount:, memo: SKIP, transaction_time: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @debit_note_number = debit_note_number @debit_note_uid = debit_note_uid @original_amount = original_amount @applied_amount = applied_amount @memo = memo unless memo == SKIP @transaction_time = transaction_time unless transaction_time == SKIP end |
Instance Attribute Details
#applied_amount ⇒ String
The amount of the debit note applied to invoice.
29 30 31 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 29 def applied_amount @applied_amount end |
#debit_note_number ⇒ String
A unique, identifying string that appears on the debit note and in places it is referenced.
16 17 18 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 16 def debit_note_number @debit_note_number end |
#debit_note_uid ⇒ String
Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix “db_” followed by alphanumeric characters.
21 22 23 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 21 def debit_note_uid @debit_note_uid end |
#memo ⇒ String
The debit note memo.
33 34 35 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 33 def memo @memo end |
#original_amount ⇒ String
The full, original amount of the debit note.
25 26 27 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 25 def original_amount @original_amount end |
#transaction_time ⇒ DateTime
The time the debit note was applied, in ISO 8601 format, i.e. “2019-06-07T17:20:06Z”
38 39 40 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 38 def transaction_time @transaction_time end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 110 111 112 113 114 115 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 85 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. debit_note_number = hash.key?('debit_note_number') ? hash['debit_note_number'] : nil debit_note_uid = hash.key?('debit_note_uid') ? hash['debit_note_uid'] : nil original_amount = hash.key?('original_amount') ? hash['original_amount'] : nil applied_amount = hash.key?('applied_amount') ? hash['applied_amount'] : nil memo = hash.key?('memo') ? hash['memo'] : SKIP transaction_time = if hash.key?('transaction_time') (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time']) else SKIP end # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. ApplyDebitNoteEventData.new(debit_note_number: debit_note_number, debit_note_uid: debit_note_uid, original_amount: original_amount, applied_amount: applied_amount, memo: memo, transaction_time: transaction_time, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['debit_note_number'] = 'debit_note_number' @_hash['debit_note_uid'] = 'debit_note_uid' @_hash['original_amount'] = 'original_amount' @_hash['applied_amount'] = 'applied_amount' @_hash['memo'] = 'memo' @_hash['transaction_time'] = 'transaction_time' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 64 65 66 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 61 def self.nullables %w[ memo transaction_time ] end |
.optionals ⇒ Object
An array for optional fields
53 54 55 56 57 58 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 53 def self.optionals %w[ memo transaction_time ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 123 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.debit_note_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.debit_note_uid, ->(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 }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['debit_note_number'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['debit_note_uid'], ->(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 }) ) end |
Instance Method Details
#to_custom_transaction_time ⇒ Object
117 118 119 |
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 117 def to_custom_transaction_time DateTimeHelper.to_rfc3339(transaction_time) end |