Class: AdvancedBilling::AccountBalance

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

Overview

AccountBalance Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(balance_in_cents: SKIP, automatic_balance_in_cents: SKIP, remittance_balance_in_cents: SKIP, additional_properties: {}) ⇒ AccountBalance

Returns a new instance of AccountBalance.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/account_balance.rb', line 50

def initialize(balance_in_cents: SKIP, automatic_balance_in_cents: SKIP,
               remittance_balance_in_cents: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @balance_in_cents = balance_in_cents unless balance_in_cents == SKIP
  unless automatic_balance_in_cents == SKIP
    @automatic_balance_in_cents =
      automatic_balance_in_cents
  end
  unless remittance_balance_in_cents == SKIP
    @remittance_balance_in_cents =
      remittance_balance_in_cents
  end
end

Instance Attribute Details

#automatic_balance_in_centsInteger

The automatic balance in cents.

Returns:

  • (Integer)


18
19
20
# File 'lib/advanced_billing/models/account_balance.rb', line 18

def automatic_balance_in_cents
  @automatic_balance_in_cents
end

#balance_in_centsInteger

The balance in cents.

Returns:

  • (Integer)


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

def balance_in_cents
  @balance_in_cents
end

#remittance_balance_in_centsInteger

The remittance balance in cents.

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/account_balance.rb', line 22

def remittance_balance_in_cents
  @remittance_balance_in_cents
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
88
# File 'lib/advanced_billing/models/account_balance.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  balance_in_cents =
    hash.key?('balance_in_cents') ? hash['balance_in_cents'] : SKIP
  automatic_balance_in_cents =
    hash.key?('automatic_balance_in_cents') ? hash['automatic_balance_in_cents'] : SKIP
  remittance_balance_in_cents =
    hash.key?('remittance_balance_in_cents') ? hash['remittance_balance_in_cents'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  AccountBalance.new(balance_in_cents: balance_in_cents,
                     automatic_balance_in_cents: automatic_balance_in_cents,
                     remittance_balance_in_cents: remittance_balance_in_cents,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/advanced_billing/models/account_balance.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['balance_in_cents'] = 'balance_in_cents'
  @_hash['automatic_balance_in_cents'] = 'automatic_balance_in_cents'
  @_hash['remittance_balance_in_cents'] = 'remittance_balance_in_cents'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    automatic_balance_in_cents
    remittance_balance_in_cents
  ]
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/advanced_billing/models/account_balance.rb', line 34

def self.optionals
  %w[
    balance_in_cents
    automatic_balance_in_cents
    remittance_balance_in_cents
  ]
end