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.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(upgrade_charge: SKIP, downgrade_credit: SKIP, accrue_charge: SKIP, additional_properties: {}) ⇒ AllocationSettings
Returns a new instance of AllocationSettings.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 52 def initialize(upgrade_charge: SKIP, downgrade_credit: SKIP, accrue_charge: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @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_charge ⇒ String
Either “true” or “false”.
24 25 26 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 24 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.
20 21 22 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 20 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.
15 16 17 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 15 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 65 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. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. AllocationSettings.new(upgrade_charge: upgrade_charge, downgrade_credit: downgrade_credit, accrue_charge: accrue_charge, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 27 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
45 46 47 48 49 50 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 45 def self.nullables %w[ upgrade_charge downgrade_credit ] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 39 40 41 42 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 36 def self.optionals %w[ upgrade_charge downgrade_credit accrue_charge ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
93 94 95 96 97 98 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 93 def inspect class_name = self.class.name.split('::').last "<#{class_name} upgrade_charge: #{@upgrade_charge.inspect}, downgrade_credit:"\ " #{@downgrade_credit.inspect}, accrue_charge: #{@accrue_charge.inspect},"\ " additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
86 87 88 89 90 |
# File 'lib/advanced_billing/models/allocation_settings.rb', line 86 def to_s class_name = self.class.name.split('::').last "<#{class_name} upgrade_charge: #{@upgrade_charge}, downgrade_credit: #{@downgrade_credit},"\ " accrue_charge: #{@accrue_charge}, additional_properties: #{get_additional_properties}>" end |