Class: AdvancedBilling::AllocationSettings

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

Overview

AllocationSettings Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(upgrade_charge = SKIP, downgrade_credit = SKIP, accrue_charge = SKIP) ⇒ AllocationSettings

Returns a new instance of AllocationSettings.



50
51
52
53
54
55
# File 'lib/advanced_billing/models/allocation_settings.rb', line 50

def initialize(upgrade_charge = SKIP, downgrade_credit = SKIP,
               accrue_charge = SKIP)
  @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP
  @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP
  @accrue_charge = accrue_charge unless accrue_charge == SKIP
end

Instance Attribute Details

#accrue_chargeTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def accrue_charge
  @accrue_charge
end

#downgrade_creditString

TODO: Write general description for this method

Returns:

  • (String)


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

def downgrade_credit
  @downgrade_credit
end

#upgrade_chargeString

TODO: Write general description for this method

Returns:

  • (String)


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

def upgrade_charge
  @upgrade_charge
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/allocation_settings.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  upgrade_charge =
    hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP
  downgrade_credit =
    hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP
  accrue_charge = hash.key?('accrue_charge') ? hash['accrue_charge'] : SKIP

  # Create object from extracted values.
  AllocationSettings.new(upgrade_charge,
                         downgrade_credit,
                         accrue_charge)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['upgrade_charge'] = 'upgrade_charge'
  @_hash['downgrade_credit'] = 'downgrade_credit'
  @_hash['accrue_charge'] = 'accrue_charge'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    upgrade_charge
    downgrade_credit
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    upgrade_charge
    downgrade_credit
    accrue_charge
  ]
end