Class: AdvancedBilling::ApplyCreditNoteEventData
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ApplyCreditNoteEventData
- Defined in:
- lib/advanced_billing/models/apply_credit_note_event_data.rb
Overview
Example schema for an ‘apply_credit_note` event
Instance Attribute Summary collapse
-
#applied_amount ⇒ String
The amount of the credit note applied to invoice.
-
#applied_credit_notes ⇒ Array[AppliedCreditNoteData]
List of credit notes applied to children invoices (if consolidated invoice).
-
#consolidated_invoice ⇒ TrueClass | FalseClass
Shows whether it was applied to consolidated invoice or not.
-
#credit_note_number ⇒ String
A unique, identifying string that appears on the credit note and in places it is referenced.
-
#credit_note_uid ⇒ String
Unique identifier for the credit note.
-
#memo ⇒ String
The credit note memo.
-
#original_amount ⇒ String
The full, original amount of the credit note.
-
#role ⇒ String
The role of the credit note (e.g. ‘general’).
-
#transaction_time ⇒ DateTime
The time the credit note was applied, in ISO 8601 format, i.e.
-
#uid ⇒ String
Unique identifier for the credit note application.
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(uid:, credit_note_number:, credit_note_uid:, original_amount:, applied_amount:, transaction_time: SKIP, memo: SKIP, role: SKIP, consolidated_invoice: SKIP, applied_credit_notes: SKIP, additional_properties: {}) ⇒ ApplyCreditNoteEventData
constructor
A new instance of ApplyCreditNoteEventData.
- #to_custom_transaction_time ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(uid:, credit_note_number:, credit_note_uid:, original_amount:, applied_amount:, transaction_time: SKIP, memo: SKIP, role: SKIP, consolidated_invoice: SKIP, applied_credit_notes: SKIP, additional_properties: {}) ⇒ ApplyCreditNoteEventData
Returns a new instance of ApplyCreditNoteEventData.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 93 def initialize(uid:, credit_note_number:, credit_note_uid:, original_amount:, applied_amount:, transaction_time: SKIP, memo: SKIP, role: SKIP, consolidated_invoice: SKIP, applied_credit_notes: SKIP, additional_properties: {}) @uid = uid @credit_note_number = credit_note_number @credit_note_uid = credit_note_uid @original_amount = original_amount @applied_amount = applied_amount @transaction_time = transaction_time unless transaction_time == SKIP @memo = memo unless memo == SKIP @role = role unless role == SKIP @consolidated_invoice = consolidated_invoice unless consolidated_invoice == SKIP @applied_credit_notes = applied_credit_notes unless applied_credit_notes == 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 credit note applied to invoice.
35 36 37 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 35 def applied_amount @applied_amount end |
#applied_credit_notes ⇒ Array[AppliedCreditNoteData]
List of credit notes applied to children invoices (if consolidated invoice)
57 58 59 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 57 def applied_credit_notes @applied_credit_notes end |
#consolidated_invoice ⇒ TrueClass | FalseClass
Shows whether it was applied to consolidated invoice or not
52 53 54 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 52 def consolidated_invoice @consolidated_invoice end |
#credit_note_number ⇒ String
A unique, identifying string that appears on the credit note and in places it is referenced.
22 23 24 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 22 def credit_note_number @credit_note_number end |
#credit_note_uid ⇒ String
Unique identifier for the credit note. It is generated automatically by Chargify and has the prefix “cn_” followed by alphanumeric characters.
27 28 29 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 27 def credit_note_uid @credit_note_uid end |
#memo ⇒ String
The credit note memo.
44 45 46 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 44 def memo @memo end |
#original_amount ⇒ String
The full, original amount of the credit note.
31 32 33 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 31 def original_amount @original_amount end |
#role ⇒ String
The role of the credit note (e.g. ‘general’)
48 49 50 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 48 def role @role end |
#transaction_time ⇒ DateTime
The time the credit note was applied, in ISO 8601 format, i.e. “2019-06-07T17:20:06Z”
40 41 42 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 40 def transaction_time @transaction_time end |
#uid ⇒ String
Unique identifier for the credit note application. It is generated automatically by Chargify and has the prefix “cdt_” followed by alphanumeric characters.
17 18 19 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 17 def uid @uid end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
115 116 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 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 115 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. uid = hash.key?('uid') ? hash['uid'] : nil credit_note_number = hash.key?('credit_note_number') ? hash['credit_note_number'] : nil credit_note_uid = hash.key?('credit_note_uid') ? hash['credit_note_uid'] : 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']) else SKIP end memo = hash.key?('memo') ? hash['memo'] : SKIP role = hash.key?('role') ? hash['role'] : SKIP consolidated_invoice = hash.key?('consolidated_invoice') ? hash['consolidated_invoice'] : SKIP # Parameter is an array, so we need to iterate through it applied_credit_notes = nil unless hash['applied_credit_notes'].nil? applied_credit_notes = [] hash['applied_credit_notes'].each do |structure| applied_credit_notes << (AppliedCreditNoteData.from_hash(structure) if structure) end end applied_credit_notes = SKIP unless hash.key?('applied_credit_notes') # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. ApplyCreditNoteEventData.new(uid: uid, credit_note_number: credit_note_number, credit_note_uid: credit_note_uid, original_amount: original_amount, applied_amount: applied_amount, transaction_time: transaction_time, memo: memo, role: role, consolidated_invoice: consolidated_invoice, applied_credit_notes: applied_credit_notes, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 60 def self.names @_hash = {} if @_hash.nil? @_hash['uid'] = 'uid' @_hash['credit_note_number'] = 'credit_note_number' @_hash['credit_note_uid'] = 'credit_note_uid' @_hash['original_amount'] = 'original_amount' @_hash['applied_amount'] = 'applied_amount' @_hash['transaction_time'] = 'transaction_time' @_hash['memo'] = 'memo' @_hash['role'] = 'role' @_hash['consolidated_invoice'] = 'consolidated_invoice' @_hash['applied_credit_notes'] = 'applied_credit_notes' @_hash end |
.nullables ⇒ Object
An array for nullable fields
87 88 89 90 91 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 87 def self.nullables %w[ memo ] end |
.optionals ⇒ Object
An array for optional fields
76 77 78 79 80 81 82 83 84 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 76 def self.optionals %w[ transaction_time memo role consolidated_invoice applied_credit_notes ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 171 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.uid, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.credit_note_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.credit_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['uid'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['credit_note_number'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['credit_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
165 166 167 |
# File 'lib/advanced_billing/models/apply_credit_note_event_data.rb', line 165 def to_custom_transaction_time DateTimeHelper.to_rfc3339(transaction_time) end |