Class: ApiReference::CreditNote
- Defined in:
- lib/api_reference/models/credit_note.rb
Overview
The Credit Note resource represents a credit that has been applied to a particular invoice.
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
The creation time of the resource in Orb.
-
#credit_note_number ⇒ String
The unique identifier for credit notes.
-
#credit_note_pdf ⇒ String
A URL to a PDF of the credit note.
-
#customer ⇒ CustomerMinified
The total including creditable invoice-level discounts or minimums, and tax.
-
#discounts ⇒ Array[CreditNoteDiscount]
Any discounts applied on the original invoice.
-
#id ⇒ String
The Orb id of this credit note.
-
#invoice_id ⇒ String
The id of the invoice resource that this credit note is applied to.
-
#line_items ⇒ Array[CreditNoteLineItem]
All of the line items associated with this credit note.
-
#maximum_amount_adjustment ⇒ CreditNoteDiscount
The maximum amount applied on the original invoice.
-
#memo ⇒ String
An optional memo supplied on the credit note.
-
#minimum_amount_refunded ⇒ String
Any credited amount from the applied minimum on the invoice.
-
#reason ⇒ Reason
An optional memo supplied on the credit note.
-
#subtotal ⇒ String
The total prior to any creditable invoice-level discounts or minimums.
-
#total ⇒ String
The total including creditable invoice-level discounts or minimums, and tax.
-
#type ⇒ Type3
An optional memo supplied on the credit note.
-
#voided_at ⇒ DateTime
The time at which the credit note was voided in Orb, if applicable.
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(id:, created_at:, voided_at:, credit_note_number:, invoice_id:, memo:, reason:, type:, subtotal:, total:, customer:, credit_note_pdf:, minimum_amount_refunded:, maximum_amount_adjustment:, line_items:, discounts: SKIP, additional_properties: nil) ⇒ CreditNote
constructor
A new instance of CreditNote.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_voided_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the 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(id:, created_at:, voided_at:, credit_note_number:, invoice_id:, memo:, reason:, type:, subtotal:, total:, customer:, credit_note_pdf:, minimum_amount_refunded:, maximum_amount_adjustment:, line_items:, discounts: SKIP, additional_properties: nil) ⇒ CreditNote
Returns a new instance of CreditNote.
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 |
# File 'lib/api_reference/models/credit_note.rb', line 121 def initialize(id:, created_at:, voided_at:, credit_note_number:, invoice_id:, memo:, reason:, type:, subtotal:, total:, customer:, credit_note_pdf:, minimum_amount_refunded:, maximum_amount_adjustment:, line_items:, discounts: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @created_at = created_at @voided_at = voided_at @credit_note_number = credit_note_number @invoice_id = invoice_id @memo = memo @reason = reason @type = type @subtotal = subtotal @total = total @customer = customer @credit_note_pdf = credit_note_pdf @minimum_amount_refunded = minimum_amount_refunded @discounts = discounts unless discounts == SKIP @maximum_amount_adjustment = maximum_amount_adjustment @line_items = line_items @additional_properties = additional_properties end |
Instance Attribute Details
#created_at ⇒ DateTime
The creation time of the resource in Orb.
20 21 22 |
# File 'lib/api_reference/models/credit_note.rb', line 20 def created_at @created_at end |
#credit_note_number ⇒ String
The unique identifier for credit notes.
28 29 30 |
# File 'lib/api_reference/models/credit_note.rb', line 28 def credit_note_number @credit_note_number end |
#credit_note_pdf ⇒ String
A URL to a PDF of the credit note.
62 63 64 |
# File 'lib/api_reference/models/credit_note.rb', line 62 def credit_note_pdf @credit_note_pdf end |
#customer ⇒ CustomerMinified
The total including creditable invoice-level discounts or minimums, and tax.
58 59 60 |
# File 'lib/api_reference/models/credit_note.rb', line 58 def customer @customer end |
#discounts ⇒ Array[CreditNoteDiscount]
Any discounts applied on the original invoice.
70 71 72 |
# File 'lib/api_reference/models/credit_note.rb', line 70 def discounts @discounts end |
#id ⇒ String
The Orb id of this credit note.
16 17 18 |
# File 'lib/api_reference/models/credit_note.rb', line 16 def id @id end |
#invoice_id ⇒ String
The id of the invoice resource that this credit note is applied to.
32 33 34 |
# File 'lib/api_reference/models/credit_note.rb', line 32 def invoice_id @invoice_id end |
#line_items ⇒ Array[CreditNoteLineItem]
All of the line items associated with this credit note.
78 79 80 |
# File 'lib/api_reference/models/credit_note.rb', line 78 def line_items @line_items end |
#maximum_amount_adjustment ⇒ CreditNoteDiscount
The maximum amount applied on the original invoice
74 75 76 |
# File 'lib/api_reference/models/credit_note.rb', line 74 def maximum_amount_adjustment @maximum_amount_adjustment end |
#memo ⇒ String
An optional memo supplied on the credit note.
36 37 38 |
# File 'lib/api_reference/models/credit_note.rb', line 36 def memo @memo end |
#minimum_amount_refunded ⇒ String
Any credited amount from the applied minimum on the invoice.
66 67 68 |
# File 'lib/api_reference/models/credit_note.rb', line 66 def minimum_amount_refunded @minimum_amount_refunded end |
#reason ⇒ Reason
An optional memo supplied on the credit note.
40 41 42 |
# File 'lib/api_reference/models/credit_note.rb', line 40 def reason @reason end |
#subtotal ⇒ String
The total prior to any creditable invoice-level discounts or minimums.
48 49 50 |
# File 'lib/api_reference/models/credit_note.rb', line 48 def subtotal @subtotal end |
#total ⇒ String
The total including creditable invoice-level discounts or minimums, and tax.
53 54 55 |
# File 'lib/api_reference/models/credit_note.rb', line 53 def total @total end |
#type ⇒ Type3
An optional memo supplied on the credit note.
44 45 46 |
# File 'lib/api_reference/models/credit_note.rb', line 44 def type @type end |
#voided_at ⇒ DateTime
The time at which the credit note was voided in Orb, if applicable.
24 25 26 |
# File 'lib/api_reference/models/credit_note.rb', line 24 def voided_at @voided_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/api_reference/models/credit_note.rb', line 149 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end voided_at = if hash.key?('voided_at') (DateTimeHelper.from_rfc3339(hash['voided_at']) if hash['voided_at']) end credit_note_number = hash.key?('credit_note_number') ? hash['credit_note_number'] : nil invoice_id = hash.key?('invoice_id') ? hash['invoice_id'] : nil memo = hash.key?('memo') ? hash['memo'] : nil reason = hash.key?('reason') ? hash['reason'] : nil type = hash.key?('type') ? hash['type'] : nil subtotal = hash.key?('subtotal') ? hash['subtotal'] : nil total = hash.key?('total') ? hash['total'] : nil customer = CustomerMinified.from_hash(hash['customer']) if hash['customer'] credit_note_pdf = hash.key?('credit_note_pdf') ? hash['credit_note_pdf'] : nil minimum_amount_refunded = hash.key?('minimum_amount_refunded') ? hash['minimum_amount_refunded'] : nil maximum_amount_adjustment = CreditNoteDiscount.from_hash(hash['maximum_amount_adjustment']) if hash['maximum_amount_adjustment'] # Parameter is an array, so we need to iterate through it line_items = nil unless hash['line_items'].nil? line_items = [] hash['line_items'].each do |structure| line_items << (CreditNoteLineItem.from_hash(structure) if structure) end end line_items = nil unless hash.key?('line_items') # Parameter is an array, so we need to iterate through it discounts = nil unless hash['discounts'].nil? discounts = [] hash['discounts'].each do |structure| discounts << (CreditNoteDiscount.from_hash(structure) if structure) end end discounts = SKIP unless hash.key?('discounts') # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. CreditNote.new(id: id, created_at: created_at, voided_at: voided_at, credit_note_number: credit_note_number, invoice_id: invoice_id, memo: memo, reason: reason, type: type, subtotal: subtotal, total: total, customer: customer, credit_note_pdf: credit_note_pdf, minimum_amount_refunded: minimum_amount_refunded, maximum_amount_adjustment: maximum_amount_adjustment, line_items: line_items, discounts: discounts, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/api_reference/models/credit_note.rb', line 81 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['created_at'] = 'created_at' @_hash['voided_at'] = 'voided_at' @_hash['credit_note_number'] = 'credit_note_number' @_hash['invoice_id'] = 'invoice_id' @_hash['memo'] = 'memo' @_hash['reason'] = 'reason' @_hash['type'] = 'type' @_hash['subtotal'] = 'subtotal' @_hash['total'] = 'total' @_hash['customer'] = 'customer' @_hash['credit_note_pdf'] = 'credit_note_pdf' @_hash['minimum_amount_refunded'] = 'minimum_amount_refunded' @_hash['discounts'] = 'discounts' @_hash['maximum_amount_adjustment'] = 'maximum_amount_adjustment' @_hash['line_items'] = 'line_items' @_hash end |
.nullables ⇒ Object
An array for nullable fields
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/api_reference/models/credit_note.rb', line 110 def self.nullables %w[ voided_at memo reason credit_note_pdf minimum_amount_refunded maximum_amount_adjustment ] end |
.optionals ⇒ Object
An array for optional fields
103 104 105 106 107 |
# File 'lib/api_reference/models/credit_note.rb', line 103 def self.optionals %w[ discounts ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/api_reference/models/credit_note.rb', line 233 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.created_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.voided_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.credit_note_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.invoice_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.reason, ->(val) { Reason.validate(val) }) and APIHelper.valid_type?(value.type, ->(val) { Type3.validate(val) }) and APIHelper.valid_type?(value.subtotal, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.total, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.customer, ->(val) { CustomerMinified.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.credit_note_pdf, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.minimum_amount_refunded, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.maximum_amount_adjustment, ->(val) { CreditNoteDiscount.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.line_items, ->(val) { CreditNoteLineItem.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['created_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['voided_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['credit_note_number'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['invoice_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['reason'], ->(val) { Reason.validate(val) }) and APIHelper.valid_type?(value['type'], ->(val) { Type3.validate(val) }) and APIHelper.valid_type?(value['subtotal'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['total'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['customer'], ->(val) { CustomerMinified.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['credit_note_pdf'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['minimum_amount_refunded'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['maximum_amount_adjustment'], ->(val) { CreditNoteDiscount.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['line_items'], ->(val) { CreditNoteLineItem.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/api_reference/models/credit_note.rb', line 326 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, created_at: #{@created_at.inspect}, voided_at:"\ " #{@voided_at.inspect}, credit_note_number: #{@credit_note_number.inspect}, invoice_id:"\ " #{@invoice_id.inspect}, memo: #{@memo.inspect}, reason: #{@reason.inspect}, type:"\ " #{@type.inspect}, subtotal: #{@subtotal.inspect}, total: #{@total.inspect}, customer:"\ " #{@customer.inspect}, credit_note_pdf: #{@credit_note_pdf.inspect},"\ " minimum_amount_refunded: #{@minimum_amount_refunded.inspect}, discounts:"\ " #{@discounts.inspect}, maximum_amount_adjustment: #{@maximum_amount_adjustment.inspect},"\ " line_items: #{@line_items.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_created_at ⇒ Object
223 224 225 |
# File 'lib/api_reference/models/credit_note.rb', line 223 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_voided_at ⇒ Object
227 228 229 |
# File 'lib/api_reference/models/credit_note.rb', line 227 def to_custom_voided_at DateTimeHelper.to_rfc3339(voided_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
314 315 316 317 318 319 320 321 322 323 |
# File 'lib/api_reference/models/credit_note.rb', line 314 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, created_at: #{@created_at}, voided_at: #{@voided_at},"\ " credit_note_number: #{@credit_note_number}, invoice_id: #{@invoice_id}, memo: #{@memo},"\ " reason: #{@reason}, type: #{@type}, subtotal: #{@subtotal}, total: #{@total}, customer:"\ " #{@customer}, credit_note_pdf: #{@credit_note_pdf}, minimum_amount_refunded:"\ " #{@minimum_amount_refunded}, discounts: #{@discounts}, maximum_amount_adjustment:"\ " #{@maximum_amount_adjustment}, line_items: #{@line_items}, additional_properties:"\ " #{@additional_properties}>" end |