Class: ApiReference::Invoice
- Defined in:
- lib/api_reference/models/invoice.rb
Overview
An Invoice is a fundamental billing entity,
representing the request for payment for a single subscription. This
includes a set of line items, which correspond to prices in the
subscription's plan and can represent fixed recurring fees or usage-based
fees. They are generated at the end of a billing period, or as the result of
an action, such as a cancellation.
Instance Attribute Summary collapse
-
#amount_due ⇒ String
This is the final amount required to be charged to the customer and reflects the application of the customer balance to the
totalof the invoice. -
#auto_collection ⇒ AutoCollection
If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be issued.
-
#billing_address ⇒ Address
The total after any minimums and discounts have been applied.
-
#created_at ⇒ DateTime
The creation time of the resource in Orb.
-
#credit_notes ⇒ Array[CreditNoteSummary]
A list of credit notes associated with the invoice.
-
#currency ⇒ String
An ISO 4217 currency string or
credits. -
#customer ⇒ CustomerMinified
An ISO 4217 currency string or
credits. -
#customer_balance_transactions ⇒ Array[CustomerBalanceTransaction]
The total after any minimums and discounts have been applied.
-
#customer_tax_id ⇒ CustomerTaxId
If the invoice has a status of
draft, this will be the time that the invoice will be eligible to be issued, otherwise it will benull. -
#discount ⇒ Object
This field is deprecated in favor of
discounts. -
#discounts ⇒ Array[Object]
This field is deprecated in favor of
discounts. -
#due_date ⇒ DateTime
When the invoice payment is due.
-
#eligible_to_issue_at ⇒ DateTime
If the invoice has a status of
draft, this will be the time that the invoice will be eligible to be issued, otherwise it will benull. -
#hosted_invoice_url ⇒ String
A URL for the customer-facing invoice portal.
-
#id ⇒ String
When the invoice payment is due.
-
#invoice_date ⇒ DateTime
The scheduled date of the invoice.
-
#invoice_number ⇒ String
Automatically generated invoice number to help track and reconcile invoices.
-
#invoice_pdf ⇒ String
The link to download the PDF representation of the
Invoice. -
#invoice_source ⇒ InvoiceSource
The total after any minimums and discounts have been applied.
-
#issue_failed_at ⇒ DateTime
If the invoice failed to issue, this will be the last time it failed to issue (even if it is now in a different state.).
-
#issued_at ⇒ DateTime
If the invoice has been issued, this will be the time it transitioned to
issued(even if it is now in a different state.). -
#line_items ⇒ Array[InvoiceLineItem]
The breakdown of prices in this invoice.
-
#maximum ⇒ Maximum
This field is deprecated in favor of
discounts. -
#maximum_amount ⇒ String
This field is deprecated in favor of
discounts. -
#memo ⇒ String
Free-form text which is available on the invoice PDF and the Orb invoice portal.
-
#metadata ⇒ Hash[String, String]
User specified key-value pairs for the resource.
-
#minimum ⇒ Minimum
This field is deprecated in favor of
discounts. -
#minimum_amount ⇒ String
This field is deprecated in favor of
discounts. -
#paid_at ⇒ DateTime
If the invoice has a status of
paid, this gives a timestamp when the invoice was paid. -
#payment_attempts ⇒ Array[PaymentAttempt]
A list of payment attempts associated with the invoice.
-
#payment_failed_at ⇒ DateTime
If payment was attempted on this invoice but failed, this will be the time of the most recent attempt.
-
#payment_started_at ⇒ DateTime
If payment was attempted on this invoice, this will be the start time of the most recent attempt.
-
#scheduled_issue_at ⇒ DateTime
If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be issued.
-
#shipping_address ⇒ Address
The total after any minimums and discounts have been applied.
-
#status ⇒ Status1
The total after any minimums and discounts have been applied.
-
#subscription ⇒ SubscriptionMinified
Automatically generated invoice number to help track and reconcile invoices.
-
#subtotal ⇒ String
The total before any discounts and minimums are applied.
-
#sync_failed_at ⇒ DateTime
If the invoice failed to sync, this will be the last time an external invoicing provider sync was attempted.
-
#total ⇒ String
The total after any minimums and discounts have been applied.
-
#voided_at ⇒ DateTime
If the invoice has a status of
void, this gives a timestamp when the invoice was voided. -
#will_auto_issue ⇒ TrueClass | FalseClass
This is true if the invoice will be automatically issued in the future, and false otherwise.
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(metadata:, voided_at:, paid_at:, issued_at:, scheduled_issue_at:, auto_collection:, issue_failed_at:, sync_failed_at:, payment_failed_at:, payment_started_at:, amount_due:, created_at:, currency:, customer:, due_date:, id:, invoice_pdf:, invoice_number:, subscription:, total:, customer_balance_transactions:, status:, invoice_source:, shipping_address:, billing_address:, hosted_invoice_url:, will_auto_issue:, eligible_to_issue_at:, customer_tax_id:, memo:, credit_notes:, payment_attempts:, discount:, discounts:, minimum:, minimum_amount:, maximum:, maximum_amount:, line_items:, subtotal:, invoice_date:, additional_properties: nil) ⇒ Invoice
constructor
A new instance of Invoice.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_due_date ⇒ Object
- #to_custom_eligible_to_issue_at ⇒ Object
- #to_custom_invoice_date ⇒ Object
- #to_custom_issue_failed_at ⇒ Object
- #to_custom_issued_at ⇒ Object
- #to_custom_paid_at ⇒ Object
- #to_custom_payment_failed_at ⇒ Object
- #to_custom_payment_started_at ⇒ Object
- #to_custom_scheduled_issue_at ⇒ Object
- #to_custom_sync_failed_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(metadata:, voided_at:, paid_at:, issued_at:, scheduled_issue_at:, auto_collection:, issue_failed_at:, sync_failed_at:, payment_failed_at:, payment_started_at:, amount_due:, created_at:, currency:, customer:, due_date:, id:, invoice_pdf:, invoice_number:, subscription:, total:, customer_balance_transactions:, status:, invoice_source:, shipping_address:, billing_address:, hosted_invoice_url:, will_auto_issue:, eligible_to_issue_at:, customer_tax_id:, memo:, credit_notes:, payment_attempts:, discount:, discounts:, minimum:, minimum_amount:, maximum:, maximum_amount:, line_items:, subtotal:, invoice_date:, additional_properties: nil) ⇒ Invoice
Returns a new instance of Invoice.
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/api_reference/models/invoice.rb', line 308 def initialize(metadata:, voided_at:, paid_at:, issued_at:, scheduled_issue_at:, auto_collection:, issue_failed_at:, sync_failed_at:, payment_failed_at:, payment_started_at:, amount_due:, created_at:, currency:, customer:, due_date:, id:, invoice_pdf:, invoice_number:, subscription:, total:, customer_balance_transactions:, status:, invoice_source:, shipping_address:, billing_address:, hosted_invoice_url:, will_auto_issue:, eligible_to_issue_at:, customer_tax_id:, memo:, credit_notes:, payment_attempts:, discount:, discounts:, minimum:, minimum_amount:, maximum:, maximum_amount:, line_items:, subtotal:, invoice_date:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @metadata = @voided_at = voided_at @paid_at = paid_at @issued_at = issued_at @scheduled_issue_at = scheduled_issue_at @auto_collection = auto_collection @issue_failed_at = issue_failed_at @sync_failed_at = sync_failed_at @payment_failed_at = payment_failed_at @payment_started_at = payment_started_at @amount_due = amount_due @created_at = created_at @currency = currency @customer = customer @due_date = due_date @id = id @invoice_pdf = invoice_pdf @invoice_number = invoice_number @subscription = subscription @total = total @customer_balance_transactions = customer_balance_transactions @status = status @invoice_source = invoice_source @shipping_address = shipping_address @billing_address = billing_address @hosted_invoice_url = hosted_invoice_url @will_auto_issue = will_auto_issue @eligible_to_issue_at = eligible_to_issue_at @customer_tax_id = customer_tax_id @memo = memo @credit_notes = credit_notes @payment_attempts = payment_attempts @discount = discount @discounts = discounts @minimum = minimum @minimum_amount = minimum_amount @maximum = maximum @maximum_amount = maximum_amount @line_items = line_items @subtotal = subtotal @invoice_date = invoice_date @additional_properties = additional_properties end |
Instance Attribute Details
#amount_due ⇒ String
This is the final amount required to be charged to the customer and
reflects the application of the customer balance to the total of the
invoice.
77 78 79 |
# File 'lib/api_reference/models/invoice.rb', line 77 def amount_due @amount_due end |
#auto_collection ⇒ AutoCollection
If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be issued.
48 49 50 |
# File 'lib/api_reference/models/invoice.rb', line 48 def auto_collection @auto_collection end |
#billing_address ⇒ Address
The total after any minimums and discounts have been applied.
139 140 141 |
# File 'lib/api_reference/models/invoice.rb', line 139 def billing_address @billing_address end |
#created_at ⇒ DateTime
The creation time of the resource in Orb.
81 82 83 |
# File 'lib/api_reference/models/invoice.rb', line 81 def created_at @created_at end |
#credit_notes ⇒ Array[CreditNoteSummary]
A list of credit notes associated with the invoice
173 174 175 |
# File 'lib/api_reference/models/invoice.rb', line 173 def credit_notes @credit_notes end |
#currency ⇒ String
An ISO 4217 currency string or credits
85 86 87 |
# File 'lib/api_reference/models/invoice.rb', line 85 def currency @currency end |
#customer ⇒ CustomerMinified
An ISO 4217 currency string or credits
89 90 91 |
# File 'lib/api_reference/models/invoice.rb', line 89 def customer @customer end |
#customer_balance_transactions ⇒ Array[CustomerBalanceTransaction]
The total after any minimums and discounts have been applied.
123 124 125 |
# File 'lib/api_reference/models/invoice.rb', line 123 def customer_balance_transactions @customer_balance_transactions end |
#customer_tax_id ⇒ CustomerTaxId
If the invoice has a status of draft, this will be the time that the
invoice will be eligible to be issued, otherwise it will be null. If
auto-issue is true, the invoice will automatically begin issuing at this
time.
164 165 166 |
# File 'lib/api_reference/models/invoice.rb', line 164 def customer_tax_id @customer_tax_id end |
#discount ⇒ Object
This field is deprecated in favor of discounts. If a discounts list is
provided, the first discount in the list will be returned. If the list is
empty, None will be returned.
183 184 185 |
# File 'lib/api_reference/models/invoice.rb', line 183 def discount @discount end |
#discounts ⇒ Array[Object]
This field is deprecated in favor of discounts. If a discounts list is
provided, the first discount in the list will be returned. If the list is
empty, None will be returned.
189 190 191 |
# File 'lib/api_reference/models/invoice.rb', line 189 def discounts @discounts end |
#due_date ⇒ DateTime
When the invoice payment is due. The due date is null if the invoice is not yet finalized.
94 95 96 |
# File 'lib/api_reference/models/invoice.rb', line 94 def due_date @due_date end |
#eligible_to_issue_at ⇒ DateTime
If the invoice has a status of draft, this will be the time that the
invoice will be eligible to be issued, otherwise it will be null. If
auto-issue is true, the invoice will automatically begin issuing at this
time.
157 158 159 |
# File 'lib/api_reference/models/invoice.rb', line 157 def eligible_to_issue_at @eligible_to_issue_at end |
#hosted_invoice_url ⇒ String
A URL for the customer-facing invoice portal. This URL expires 60 days after the link is generated, or 30 days after the invoice's due date — whichever is later.
145 146 147 |
# File 'lib/api_reference/models/invoice.rb', line 145 def hosted_invoice_url @hosted_invoice_url end |
#id ⇒ String
When the invoice payment is due. The due date is null if the invoice is not yet finalized.
99 100 101 |
# File 'lib/api_reference/models/invoice.rb', line 99 def id @id end |
#invoice_date ⇒ DateTime
The scheduled date of the invoice
225 226 227 |
# File 'lib/api_reference/models/invoice.rb', line 225 def invoice_date @invoice_date end |
#invoice_number ⇒ String
Automatically generated invoice number to help track and reconcile
invoices. Invoice numbers have a prefix such as RFOBWG. These can be
sequential per account or customer.
109 110 111 |
# File 'lib/api_reference/models/invoice.rb', line 109 def invoice_number @invoice_number end |
#invoice_pdf ⇒ String
The link to download the PDF representation of the Invoice.
103 104 105 |
# File 'lib/api_reference/models/invoice.rb', line 103 def invoice_pdf @invoice_pdf end |
#invoice_source ⇒ InvoiceSource
The total after any minimums and discounts have been applied.
131 132 133 |
# File 'lib/api_reference/models/invoice.rb', line 131 def invoice_source @invoice_source end |
#issue_failed_at ⇒ DateTime
If the invoice failed to issue, this will be the last time it failed to issue (even if it is now in a different state.)
53 54 55 |
# File 'lib/api_reference/models/invoice.rb', line 53 def issue_failed_at @issue_failed_at end |
#issued_at ⇒ DateTime
If the invoice has been issued, this will be the time it transitioned to
issued (even if it is now in a different state.)
38 39 40 |
# File 'lib/api_reference/models/invoice.rb', line 38 def issued_at @issued_at end |
#line_items ⇒ Array[InvoiceLineItem]
The breakdown of prices in this invoice.
217 218 219 |
# File 'lib/api_reference/models/invoice.rb', line 217 def line_items @line_items end |
#maximum ⇒ Maximum
This field is deprecated in favor of discounts. If a discounts list is
provided, the first discount in the list will be returned. If the list is
empty, None will be returned.
207 208 209 |
# File 'lib/api_reference/models/invoice.rb', line 207 def maximum @maximum end |
#maximum_amount ⇒ String
This field is deprecated in favor of discounts. If a discounts list is
provided, the first discount in the list will be returned. If the list is
empty, None will be returned.
213 214 215 |
# File 'lib/api_reference/models/invoice.rb', line 213 def maximum_amount @maximum_amount end |
#memo ⇒ String
Free-form text which is available on the invoice PDF and the Orb invoice portal.
169 170 171 |
# File 'lib/api_reference/models/invoice.rb', line 169 def memo @memo end |
#metadata ⇒ Hash[String, String]
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
23 24 25 |
# File 'lib/api_reference/models/invoice.rb', line 23 def @metadata end |
#minimum ⇒ Minimum
This field is deprecated in favor of discounts. If a discounts list is
provided, the first discount in the list will be returned. If the list is
empty, None will be returned.
195 196 197 |
# File 'lib/api_reference/models/invoice.rb', line 195 def minimum @minimum end |
#minimum_amount ⇒ String
This field is deprecated in favor of discounts. If a discounts list is
provided, the first discount in the list will be returned. If the list is
empty, None will be returned.
201 202 203 |
# File 'lib/api_reference/models/invoice.rb', line 201 def minimum_amount @minimum_amount end |
#paid_at ⇒ DateTime
If the invoice has a status of paid, this gives a timestamp when the
invoice was paid.
33 34 35 |
# File 'lib/api_reference/models/invoice.rb', line 33 def paid_at @paid_at end |
#payment_attempts ⇒ Array[PaymentAttempt]
A list of payment attempts associated with the invoice
177 178 179 |
# File 'lib/api_reference/models/invoice.rb', line 177 def payment_attempts @payment_attempts end |
#payment_failed_at ⇒ DateTime
If payment was attempted on this invoice but failed, this will be the time of the most recent attempt.
64 65 66 |
# File 'lib/api_reference/models/invoice.rb', line 64 def payment_failed_at @payment_failed_at end |
#payment_started_at ⇒ DateTime
If payment was attempted on this invoice, this will be the start time of the most recent attempt. This field is especially useful for delayed-notification payment mechanisms (like bank transfers), where payment can take 3 days or more.
71 72 73 |
# File 'lib/api_reference/models/invoice.rb', line 71 def payment_started_at @payment_started_at end |
#scheduled_issue_at ⇒ DateTime
If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be issued.
43 44 45 |
# File 'lib/api_reference/models/invoice.rb', line 43 def scheduled_issue_at @scheduled_issue_at end |
#shipping_address ⇒ Address
The total after any minimums and discounts have been applied.
135 136 137 |
# File 'lib/api_reference/models/invoice.rb', line 135 def shipping_address @shipping_address end |
#status ⇒ Status1
The total after any minimums and discounts have been applied.
127 128 129 |
# File 'lib/api_reference/models/invoice.rb', line 127 def status @status end |
#subscription ⇒ SubscriptionMinified
Automatically generated invoice number to help track and reconcile
invoices. Invoice numbers have a prefix such as RFOBWG. These can be
sequential per account or customer.
115 116 117 |
# File 'lib/api_reference/models/invoice.rb', line 115 def subscription @subscription end |
#subtotal ⇒ String
The total before any discounts and minimums are applied.
221 222 223 |
# File 'lib/api_reference/models/invoice.rb', line 221 def subtotal @subtotal end |
#sync_failed_at ⇒ DateTime
If the invoice failed to sync, this will be the last time an external
invoicing provider sync was attempted. This field will always be null
for invoices using Orb Invoicing.
59 60 61 |
# File 'lib/api_reference/models/invoice.rb', line 59 def sync_failed_at @sync_failed_at end |
#total ⇒ String
The total after any minimums and discounts have been applied.
119 120 121 |
# File 'lib/api_reference/models/invoice.rb', line 119 def total @total end |
#voided_at ⇒ DateTime
If the invoice has a status of void, this gives a timestamp when the
invoice was voided.
28 29 30 |
# File 'lib/api_reference/models/invoice.rb', line 28 def voided_at @voided_at end |
#will_auto_issue ⇒ TrueClass | FalseClass
This is true if the invoice will be automatically issued in the future, and false otherwise.
150 151 152 |
# File 'lib/api_reference/models/invoice.rb', line 150 def will_auto_issue @will_auto_issue end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/api_reference/models/invoice.rb', line 368 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('metadata') ? hash['metadata'] : nil voided_at = if hash.key?('voided_at') (DateTimeHelper.from_rfc3339(hash['voided_at']) if hash['voided_at']) end paid_at = if hash.key?('paid_at') (DateTimeHelper.from_rfc3339(hash['paid_at']) if hash['paid_at']) end issued_at = if hash.key?('issued_at') (DateTimeHelper.from_rfc3339(hash['issued_at']) if hash['issued_at']) end scheduled_issue_at = if hash.key?('scheduled_issue_at') (DateTimeHelper.from_rfc3339(hash['scheduled_issue_at']) if hash['scheduled_issue_at']) end auto_collection = AutoCollection.from_hash(hash['auto_collection']) if hash['auto_collection'] issue_failed_at = if hash.key?('issue_failed_at') (DateTimeHelper.from_rfc3339(hash['issue_failed_at']) if hash['issue_failed_at']) end sync_failed_at = if hash.key?('sync_failed_at') (DateTimeHelper.from_rfc3339(hash['sync_failed_at']) if hash['sync_failed_at']) end payment_failed_at = if hash.key?('payment_failed_at') (DateTimeHelper.from_rfc3339(hash['payment_failed_at']) if hash['payment_failed_at']) end payment_started_at = if hash.key?('payment_started_at') (DateTimeHelper.from_rfc3339(hash['payment_started_at']) if hash['payment_started_at']) end amount_due = hash.key?('amount_due') ? hash['amount_due'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end currency = hash.key?('currency') ? hash['currency'] : nil customer = CustomerMinified.from_hash(hash['customer']) if hash['customer'] due_date = if hash.key?('due_date') (DateTimeHelper.from_rfc3339(hash['due_date']) if hash['due_date']) end id = hash.key?('id') ? hash['id'] : nil invoice_pdf = hash.key?('invoice_pdf') ? hash['invoice_pdf'] : nil invoice_number = hash.key?('invoice_number') ? hash['invoice_number'] : nil subscription = SubscriptionMinified.from_hash(hash['subscription']) if hash['subscription'] total = hash.key?('total') ? hash['total'] : nil # Parameter is an array, so we need to iterate through it customer_balance_transactions = nil unless hash['customer_balance_transactions'].nil? customer_balance_transactions = [] hash['customer_balance_transactions'].each do |structure| customer_balance_transactions << (CustomerBalanceTransaction.from_hash(structure) if structure) end end customer_balance_transactions = nil unless hash.key?('customer_balance_transactions') status = hash.key?('status') ? hash['status'] : nil invoice_source = hash.key?('invoice_source') ? hash['invoice_source'] : nil shipping_address = Address.from_hash(hash['shipping_address']) if hash['shipping_address'] billing_address = Address.from_hash(hash['billing_address']) if hash['billing_address'] hosted_invoice_url = hash.key?('hosted_invoice_url') ? hash['hosted_invoice_url'] : nil will_auto_issue = hash.key?('will_auto_issue') ? hash['will_auto_issue'] : nil eligible_to_issue_at = if hash.key?('eligible_to_issue_at') (DateTimeHelper.from_rfc3339(hash['eligible_to_issue_at']) if hash['eligible_to_issue_at']) end customer_tax_id = CustomerTaxId.from_hash(hash['customer_tax_id']) if hash['customer_tax_id'] memo = hash.key?('memo') ? hash['memo'] : nil # Parameter is an array, so we need to iterate through it credit_notes = nil unless hash['credit_notes'].nil? credit_notes = [] hash['credit_notes'].each do |structure| credit_notes << (CreditNoteSummary.from_hash(structure) if structure) end end credit_notes = nil unless hash.key?('credit_notes') # Parameter is an array, so we need to iterate through it payment_attempts = nil unless hash['payment_attempts'].nil? payment_attempts = [] hash['payment_attempts'].each do |structure| payment_attempts << (PaymentAttempt.from_hash(structure) if structure) end end payment_attempts = nil unless hash.key?('payment_attempts') discount = hash.key?('discount') ? hash['discount'] : nil discounts = hash.key?('discounts') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:InvoiceLevelDiscount), hash['discounts'] ) : nil minimum = Minimum.from_hash(hash['minimum']) if hash['minimum'] minimum_amount = hash.key?('minimum_amount') ? hash['minimum_amount'] : nil maximum = Maximum.from_hash(hash['maximum']) if hash['maximum'] maximum_amount = hash.key?('maximum_amount') ? hash['maximum_amount'] : nil # 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 << (InvoiceLineItem.from_hash(structure) if structure) end end line_items = nil unless hash.key?('line_items') subtotal = hash.key?('subtotal') ? hash['subtotal'] : nil invoice_date = if hash.key?('invoice_date') (DateTimeHelper.from_rfc3339(hash['invoice_date']) if hash['invoice_date']) end # 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. Invoice.new(metadata: , voided_at: voided_at, paid_at: paid_at, issued_at: issued_at, scheduled_issue_at: scheduled_issue_at, auto_collection: auto_collection, issue_failed_at: issue_failed_at, sync_failed_at: sync_failed_at, payment_failed_at: payment_failed_at, payment_started_at: payment_started_at, amount_due: amount_due, created_at: created_at, currency: currency, customer: customer, due_date: due_date, id: id, invoice_pdf: invoice_pdf, invoice_number: invoice_number, subscription: subscription, total: total, customer_balance_transactions: customer_balance_transactions, status: status, invoice_source: invoice_source, shipping_address: shipping_address, billing_address: billing_address, hosted_invoice_url: hosted_invoice_url, will_auto_issue: will_auto_issue, eligible_to_issue_at: eligible_to_issue_at, customer_tax_id: customer_tax_id, memo: memo, credit_notes: credit_notes, payment_attempts: payment_attempts, discount: discount, discounts: discounts, minimum: minimum, minimum_amount: minimum_amount, maximum: maximum, maximum_amount: maximum_amount, line_items: line_items, subtotal: subtotal, invoice_date: invoice_date, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
228 229 230 231 232 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 |
# File 'lib/api_reference/models/invoice.rb', line 228 def self.names @_hash = {} if @_hash.nil? @_hash['metadata'] = 'metadata' @_hash['voided_at'] = 'voided_at' @_hash['paid_at'] = 'paid_at' @_hash['issued_at'] = 'issued_at' @_hash['scheduled_issue_at'] = 'scheduled_issue_at' @_hash['auto_collection'] = 'auto_collection' @_hash['issue_failed_at'] = 'issue_failed_at' @_hash['sync_failed_at'] = 'sync_failed_at' @_hash['payment_failed_at'] = 'payment_failed_at' @_hash['payment_started_at'] = 'payment_started_at' @_hash['amount_due'] = 'amount_due' @_hash['created_at'] = 'created_at' @_hash['currency'] = 'currency' @_hash['customer'] = 'customer' @_hash['due_date'] = 'due_date' @_hash['id'] = 'id' @_hash['invoice_pdf'] = 'invoice_pdf' @_hash['invoice_number'] = 'invoice_number' @_hash['subscription'] = 'subscription' @_hash['total'] = 'total' @_hash['customer_balance_transactions'] = 'customer_balance_transactions' @_hash['status'] = 'status' @_hash['invoice_source'] = 'invoice_source' @_hash['shipping_address'] = 'shipping_address' @_hash['billing_address'] = 'billing_address' @_hash['hosted_invoice_url'] = 'hosted_invoice_url' @_hash['will_auto_issue'] = 'will_auto_issue' @_hash['eligible_to_issue_at'] = 'eligible_to_issue_at' @_hash['customer_tax_id'] = 'customer_tax_id' @_hash['memo'] = 'memo' @_hash['credit_notes'] = 'credit_notes' @_hash['payment_attempts'] = 'payment_attempts' @_hash['discount'] = 'discount' @_hash['discounts'] = 'discounts' @_hash['minimum'] = 'minimum' @_hash['minimum_amount'] = 'minimum_amount' @_hash['maximum'] = 'maximum' @_hash['maximum_amount'] = 'maximum_amount' @_hash['line_items'] = 'line_items' @_hash['subtotal'] = 'subtotal' @_hash['invoice_date'] = 'invoice_date' @_hash end |
.nullables ⇒ Object
An array for nullable fields
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 |
# File 'lib/api_reference/models/invoice.rb', line 281 def self.nullables %w[ voided_at paid_at issued_at scheduled_issue_at issue_failed_at sync_failed_at payment_failed_at payment_started_at due_date invoice_pdf subscription shipping_address billing_address hosted_invoice_url eligible_to_issue_at customer_tax_id memo discount minimum minimum_amount maximum maximum_amount ] end |
.optionals ⇒ Object
An array for optional fields
276 277 278 |
# File 'lib/api_reference/models/invoice.rb', line 276 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'lib/api_reference/models/invoice.rb', line 586 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value., ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.voided_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.paid_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.issued_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.scheduled_issue_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.auto_collection, ->(val) { AutoCollection.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.issue_failed_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.sync_failed_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.payment_failed_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.payment_started_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.amount_due, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.created_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.currency, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.customer, ->(val) { CustomerMinified.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.due_date, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.invoice_pdf, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.invoice_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.subscription, ->(val) { SubscriptionMinified.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.total, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.customer_balance_transactions, ->(val) { CustomerBalanceTransaction.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.status, ->(val) { Status1.validate(val) }) and APIHelper.valid_type?(value.invoice_source, ->(val) { InvoiceSource.validate(val) }) and APIHelper.valid_type?(value.shipping_address, ->(val) { Address.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.billing_address, ->(val) { Address.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.hosted_invoice_url, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.will_auto_issue, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.eligible_to_issue_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.customer_tax_id, ->(val) { CustomerTaxId.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.credit_notes, ->(val) { CreditNoteSummary.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.payment_attempts, ->(val) { PaymentAttempt.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.discount, ->(val) { val.instance_of? Object }) and UnionTypeLookUp.get(:InvoiceLevelDiscount) .validate(value.discounts) and APIHelper.valid_type?(value.minimum, ->(val) { Minimum.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.minimum_amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.maximum, ->(val) { Maximum.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.maximum_amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.line_items, ->(val) { InvoiceLineItem.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.subtotal, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.invoice_date, ->(val) { val.instance_of? DateTime }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['metadata'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['voided_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['paid_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['issued_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['scheduled_issue_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['auto_collection'], ->(val) { AutoCollection.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['issue_failed_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['sync_failed_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['payment_failed_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['payment_started_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['amount_due'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['created_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['currency'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['customer'], ->(val) { CustomerMinified.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['due_date'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['invoice_pdf'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['invoice_number'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['subscription'], ->(val) { SubscriptionMinified.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['total'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['customer_balance_transactions'], ->(val) { CustomerBalanceTransaction.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['status'], ->(val) { Status1.validate(val) }) and APIHelper.valid_type?(value['invoice_source'], ->(val) { InvoiceSource.validate(val) }) and APIHelper.valid_type?(value['shipping_address'], ->(val) { Address.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['billing_address'], ->(val) { Address.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['hosted_invoice_url'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['will_auto_issue'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['eligible_to_issue_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['customer_tax_id'], ->(val) { CustomerTaxId.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['credit_notes'], ->(val) { CreditNoteSummary.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['payment_attempts'], ->(val) { PaymentAttempt.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['discount'], ->(val) { val.instance_of? Object }) and UnionTypeLookUp.get(:InvoiceLevelDiscount) .validate(value['discounts']) and APIHelper.valid_type?(value['minimum'], ->(val) { Minimum.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['minimum_amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['maximum'], ->(val) { Maximum.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['maximum_amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['line_items'], ->(val) { InvoiceLineItem.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['subtotal'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['invoice_date'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/api_reference/models/invoice.rb', line 817 def inspect class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata.inspect}, voided_at: #{@voided_at.inspect}, paid_at:"\ " #{@paid_at.inspect}, issued_at: #{@issued_at.inspect}, scheduled_issue_at:"\ " #{@scheduled_issue_at.inspect}, auto_collection: #{@auto_collection.inspect},"\ " issue_failed_at: #{@issue_failed_at.inspect}, sync_failed_at: #{@sync_failed_at.inspect},"\ " payment_failed_at: #{@payment_failed_at.inspect}, payment_started_at:"\ " #{@payment_started_at.inspect}, amount_due: #{@amount_due.inspect}, created_at:"\ " #{@created_at.inspect}, currency: #{@currency.inspect}, customer: #{@customer.inspect},"\ " due_date: #{@due_date.inspect}, id: #{@id.inspect}, invoice_pdf: #{@invoice_pdf.inspect},"\ " invoice_number: #{@invoice_number.inspect}, subscription: #{@subscription.inspect}, total:"\ " #{@total.inspect}, customer_balance_transactions:"\ " #{@customer_balance_transactions.inspect}, status: #{@status.inspect}, invoice_source:"\ " #{@invoice_source.inspect}, shipping_address: #{@shipping_address.inspect},"\ " billing_address: #{@billing_address.inspect}, hosted_invoice_url:"\ " #{@hosted_invoice_url.inspect}, will_auto_issue: #{@will_auto_issue.inspect},"\ " eligible_to_issue_at: #{@eligible_to_issue_at.inspect}, customer_tax_id:"\ " #{@customer_tax_id.inspect}, memo: #{@memo.inspect}, credit_notes:"\ " #{@credit_notes.inspect}, payment_attempts: #{@payment_attempts.inspect}, discount:"\ " #{@discount.inspect}, discounts: #{@discounts.inspect}, minimum: #{@minimum.inspect},"\ " minimum_amount: #{@minimum_amount.inspect}, maximum: #{@maximum.inspect}, maximum_amount:"\ " #{@maximum_amount.inspect}, line_items: #{@line_items.inspect}, subtotal:"\ " #{@subtotal.inspect}, invoice_date: #{@invoice_date.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_created_at ⇒ Object
568 569 570 |
# File 'lib/api_reference/models/invoice.rb', line 568 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_due_date ⇒ Object
572 573 574 |
# File 'lib/api_reference/models/invoice.rb', line 572 def to_custom_due_date DateTimeHelper.to_rfc3339(due_date) end |
#to_custom_eligible_to_issue_at ⇒ Object
576 577 578 |
# File 'lib/api_reference/models/invoice.rb', line 576 def to_custom_eligible_to_issue_at DateTimeHelper.to_rfc3339(eligible_to_issue_at) end |
#to_custom_invoice_date ⇒ Object
580 581 582 |
# File 'lib/api_reference/models/invoice.rb', line 580 def to_custom_invoice_date DateTimeHelper.to_rfc3339(invoice_date) end |
#to_custom_issue_failed_at ⇒ Object
552 553 554 |
# File 'lib/api_reference/models/invoice.rb', line 552 def to_custom_issue_failed_at DateTimeHelper.to_rfc3339(issue_failed_at) end |
#to_custom_issued_at ⇒ Object
544 545 546 |
# File 'lib/api_reference/models/invoice.rb', line 544 def to_custom_issued_at DateTimeHelper.to_rfc3339(issued_at) end |
#to_custom_paid_at ⇒ Object
540 541 542 |
# File 'lib/api_reference/models/invoice.rb', line 540 def to_custom_paid_at DateTimeHelper.to_rfc3339(paid_at) end |
#to_custom_payment_failed_at ⇒ Object
560 561 562 |
# File 'lib/api_reference/models/invoice.rb', line 560 def to_custom_payment_failed_at DateTimeHelper.to_rfc3339(payment_failed_at) end |
#to_custom_payment_started_at ⇒ Object
564 565 566 |
# File 'lib/api_reference/models/invoice.rb', line 564 def to_custom_payment_started_at DateTimeHelper.to_rfc3339(payment_started_at) end |
#to_custom_scheduled_issue_at ⇒ Object
548 549 550 |
# File 'lib/api_reference/models/invoice.rb', line 548 def to_custom_scheduled_issue_at DateTimeHelper.to_rfc3339(scheduled_issue_at) end |
#to_custom_sync_failed_at ⇒ Object
556 557 558 |
# File 'lib/api_reference/models/invoice.rb', line 556 def to_custom_sync_failed_at DateTimeHelper.to_rfc3339(sync_failed_at) end |
#to_custom_voided_at ⇒ Object
536 537 538 |
# File 'lib/api_reference/models/invoice.rb', line 536 def to_custom_voided_at DateTimeHelper.to_rfc3339(voided_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/api_reference/models/invoice.rb', line 795 def to_s class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata}, voided_at: #{@voided_at}, paid_at: #{@paid_at},"\ " issued_at: #{@issued_at}, scheduled_issue_at: #{@scheduled_issue_at}, auto_collection:"\ " #{@auto_collection}, issue_failed_at: #{@issue_failed_at}, sync_failed_at:"\ " #{@sync_failed_at}, payment_failed_at: #{@payment_failed_at}, payment_started_at:"\ " #{@payment_started_at}, amount_due: #{@amount_due}, created_at: #{@created_at}, currency:"\ " #{@currency}, customer: #{@customer}, due_date: #{@due_date}, id: #{@id}, invoice_pdf:"\ " #{@invoice_pdf}, invoice_number: #{@invoice_number}, subscription: #{@subscription},"\ " total: #{@total}, customer_balance_transactions: #{@customer_balance_transactions},"\ " status: #{@status}, invoice_source: #{@invoice_source}, shipping_address:"\ " #{@shipping_address}, billing_address: #{@billing_address}, hosted_invoice_url:"\ " #{@hosted_invoice_url}, will_auto_issue: #{@will_auto_issue}, eligible_to_issue_at:"\ " #{@eligible_to_issue_at}, customer_tax_id: #{@customer_tax_id}, memo: #{@memo},"\ " credit_notes: #{@credit_notes}, payment_attempts: #{@payment_attempts}, discount:"\ " #{@discount}, discounts: #{@discounts}, minimum: #{@minimum}, minimum_amount:"\ " #{@minimum_amount}, maximum: #{@maximum}, maximum_amount: #{@maximum_amount}, line_items:"\ " #{@line_items}, subtotal: #{@subtotal}, invoice_date: #{@invoice_date},"\ " additional_properties: #{@additional_properties}>" end |