Class: AdvancedBilling::Payment

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

Overview

Payment 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_uid = SKIP, status = SKIP, due_amount = SKIP, paid_amount = SKIP) ⇒ Payment

Returns a new instance of Payment.



55
56
57
58
59
60
61
# File 'lib/advanced_billing/models/payment.rb', line 55

def initialize(invoice_uid = SKIP, status = SKIP, due_amount = SKIP,
               paid_amount = SKIP)
  @invoice_uid = invoice_uid unless invoice_uid == SKIP
  @status = status unless status == SKIP
  @due_amount = due_amount unless due_amount == SKIP
  @paid_amount = paid_amount unless paid_amount == SKIP
end

Instance Attribute Details

#due_amountString

The remaining due amount on the invoice

Returns:

  • (String)


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

def due_amount
  @due_amount
end

#invoice_uidString

The uid of the paid invoice

Returns:

  • (String)


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

def invoice_uid
  @invoice_uid
end

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

Returns:

  • (String)


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

def paid_amount
  @paid_amount
end

#statusStatus

The current status of the invoice. See [Invoice Statuses](chargify.zendesk.com/hc/en-us/articles/4407737494171#lin e-item-breakdowns) for more.

Returns:



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

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/advanced_billing/models/payment.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  invoice_uid = hash.key?('invoice_uid') ? hash['invoice_uid'] : 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

  # Create object from extracted values.
  Payment.new(invoice_uid,
              status,
              due_amount,
              paid_amount)
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/payment.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['invoice_uid'] = 'invoice_uid'
  @_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/payment.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/payment.rb', line 41

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