Class: AdvancedBilling::AllocationSettings
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::AllocationSettings
- Defined in:
- lib/advanced_billing/models/allocation_settings.rb
Overview
AllocationSettings Model.
Instance Attribute Summary collapse
-
#accrue_charge ⇒ String
Either “true” or “false”.
-
#downgrade_credit ⇒ CreditType
The type of credit to be created when upgrading/downgrading.
-
#upgrade_charge ⇒ CreditType
The type of credit to be created when upgrading/downgrading.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(upgrade_charge: SKIP, downgrade_credit: SKIP, accrue_charge: SKIP, additional_properties: {}) ⇒ AllocationSettings
constructor
A new instance of AllocationSettings.
Methods inherited from BaseModel
Constructor Details
#initialize(upgrade_charge: SKIP, downgrade_credit: SKIP, accrue_charge: SKIP, additional_properties: {}) ⇒ AllocationSettings
Returns a new instance of AllocationSettings.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 54 def initialize(upgrade_charge: SKIP, downgrade_credit: SKIP, accrue_charge: SKIP, additional_properties: {}) @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP @accrue_charge = accrue_charge unless accrue_charge == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#accrue_charge ⇒ String
Either “true” or “false”.
26 27 28 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 26 def accrue_charge @accrue_charge end |
#downgrade_credit ⇒ CreditType
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided. Available values: ‘full`, `prorated`, `none`.
22 23 24 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 22 def downgrade_credit @downgrade_credit end |
#upgrade_charge ⇒ CreditType
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided. Available values: ‘full`, `prorated`, `none`.
16 17 18 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 16 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 67 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 # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. AllocationSettings.new(upgrade_charge: upgrade_charge, downgrade_credit: downgrade_credit, accrue_charge: accrue_charge, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['accrue_charge'] = 'accrue_charge' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 47 def self.nullables %w[ upgrade_charge downgrade_credit ] end |
.optionals ⇒ Object
An array for optional fields
38 39 40 41 42 43 44 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 38 def self.optionals %w[ upgrade_charge downgrade_credit accrue_charge ] end |