Class: AdvancedBilling::AccountBalances

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

Overview

AccountBalances Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(open_invoices = SKIP, pending_discounts = SKIP, service_credits = SKIP, prepayments = SKIP) ⇒ AccountBalances

Returns a new instance of AccountBalances.



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

def initialize(open_invoices = SKIP, pending_discounts = SKIP,
               service_credits = SKIP, prepayments = SKIP)
  @open_invoices = open_invoices unless open_invoices == SKIP
  @pending_discounts = pending_discounts unless pending_discounts == SKIP
  @service_credits = service_credits unless service_credits == SKIP
  @prepayments = prepayments unless prepayments == SKIP
end

Instance Attribute Details

#open_invoicesAccountBalance

The balance, in cents, of the sum of the subscription’s open, payable invoices.

Returns:



15
16
17
# File 'lib/advanced_billing/models/account_balances.rb', line 15

def open_invoices
  @open_invoices
end

#pending_discountsAccountBalance

The balance, in cents, of the subscription’s Pending Discount account.

Returns:



19
20
21
# File 'lib/advanced_billing/models/account_balances.rb', line 19

def pending_discounts
  @pending_discounts
end

#prepaymentsAccountBalance

The balance, in cents, of the subscription’s Prepayment account.

Returns:



27
28
29
# File 'lib/advanced_billing/models/account_balances.rb', line 27

def prepayments
  @prepayments
end

#service_creditsAccountBalance

The balance, in cents, of the subscription’s Service Credit account.

Returns:



23
24
25
# File 'lib/advanced_billing/models/account_balances.rb', line 23

def service_credits
  @service_credits
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  open_invoices = AccountBalance.from_hash(hash['open_invoices']) if hash['open_invoices']
  pending_discounts = AccountBalance.from_hash(hash['pending_discounts']) if
    hash['pending_discounts']
  service_credits = AccountBalance.from_hash(hash['service_credits']) if
    hash['service_credits']
  prepayments = AccountBalance.from_hash(hash['prepayments']) if hash['prepayments']

  # Create object from extracted values.
  AccountBalances.new(open_invoices,
                      pending_discounts,
                      service_credits,
                      prepayments)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['open_invoices'] = 'open_invoices'
  @_hash['pending_discounts'] = 'pending_discounts'
  @_hash['service_credits'] = 'service_credits'
  @_hash['prepayments'] = 'prepayments'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/advanced_billing/models/account_balances.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    open_invoices
    pending_discounts
    service_credits
    prepayments
  ]
end