Class: AdvancedBilling::PaidInvoice

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/paid_invoice.rb

Overview

PaidInvoice Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(invoice_id: SKIP, status: SKIP, due_amount: SKIP, paid_amount: SKIP, additional_properties: {}) ⇒ PaidInvoice

Returns a new instance of PaidInvoice.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/paid_invoice.rb', line 55

def initialize(invoice_id: SKIP, status: SKIP, due_amount: SKIP,
               paid_amount: SKIP, additional_properties: {})
  @invoice_id = invoice_id unless invoice_id == SKIP
  @status = status unless status == SKIP
  @due_amount = due_amount unless due_amount == SKIP
  @paid_amount = paid_amount unless paid_amount == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#due_amountString

The remaining due amount on the invoice

Returns:

  • (String)


24
25
26
# File 'lib/advanced_billing/models/paid_invoice.rb', line 24

def due_amount
  @due_amount
end

#invoice_idString

The uid of the paid invoice

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/paid_invoice.rb', line 14

def invoice_id
  @invoice_id
end

The total amount paid on this invoice (including any prior payments)

Returns:

  • (String)


28
29
30
# File 'lib/advanced_billing/models/paid_invoice.rb', line 28

def paid_amount
  @paid_amount
end

#statusInvoiceStatus

The current status of the invoice. See [Invoice Statuses](maxio.zendesk.com/hc/en-us/articles/24252287829645-Advan ced-Billing-Invoices-Overview#invoice-statuses) for more.

Returns:



20
21
22
# File 'lib/advanced_billing/models/paid_invoice.rb', line 20

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/advanced_billing/models/paid_invoice.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  invoice_id = hash.key?('invoice_id') ? hash['invoice_id'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  due_amount = hash.key?('due_amount') ? hash['due_amount'] : SKIP
  paid_amount = hash.key?('paid_amount') ? hash['paid_amount'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  PaidInvoice.new(invoice_id: invoice_id,
                  status: status,
                  due_amount: due_amount,
                  paid_amount: paid_amount,
                  additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/advanced_billing/models/paid_invoice.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['invoice_id'] = 'invoice_id'
  @_hash['status'] = 'status'
  @_hash['due_amount'] = 'due_amount'
  @_hash['paid_amount'] = 'paid_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/advanced_billing/models/paid_invoice.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
44
45
46
47
48
# File 'lib/advanced_billing/models/paid_invoice.rb', line 41

def self.optionals
  %w[
    invoice_id
    status
    due_amount
    paid_amount
  ]
end