Class: AdvancedBilling::ComponentAllocationChange
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ComponentAllocationChange
- Defined in:
- lib/advanced_billing/models/component_allocation_change.rb
Overview
ComponentAllocationChange Model.
Instance Attribute Summary collapse
-
#allocated_quantity ⇒ Object
TODO: Write general description for this method.
-
#allocation_id ⇒ Integer
TODO: Write general description for this method.
-
#component_handle ⇒ String
TODO: Write general description for this method.
-
#component_id ⇒ Integer
TODO: Write general description for this method.
-
#memo ⇒ String
TODO: Write general description for this method.
-
#new_allocation ⇒ Integer
TODO: Write general description for this method.
-
#previous_allocation ⇒ Integer
TODO: Write general description for this method.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(previous_allocation:, new_allocation:, component_id:, component_handle:, memo:, allocation_id:, allocated_quantity: SKIP, additional_properties: {}) ⇒ ComponentAllocationChange
constructor
A new instance of ComponentAllocationChange.
Methods inherited from BaseModel
Constructor Details
#initialize(previous_allocation:, new_allocation:, component_id:, component_handle:, memo:, allocation_id:, allocated_quantity: SKIP, additional_properties: {}) ⇒ ComponentAllocationChange
Returns a new instance of ComponentAllocationChange.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 65 def initialize(previous_allocation:, new_allocation:, component_id:, component_handle:, memo:, allocation_id:, allocated_quantity: SKIP, additional_properties: {}) @previous_allocation = previous_allocation @new_allocation = new_allocation @component_id = component_id @component_handle = component_handle @memo = memo @allocation_id = allocation_id @allocated_quantity = allocated_quantity unless allocated_quantity == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#allocated_quantity ⇒ Object
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 38 def allocated_quantity @allocated_quantity end |
#allocation_id ⇒ Integer
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 34 def allocation_id @allocation_id end |
#component_handle ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 26 def component_handle @component_handle end |
#component_id ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 22 def component_id @component_id end |
#memo ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 30 def memo @memo end |
#new_allocation ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 18 def new_allocation @new_allocation end |
#previous_allocation ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 14 def previous_allocation @previous_allocation end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 83 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. previous_allocation = hash.key?('previous_allocation') ? hash['previous_allocation'] : nil new_allocation = hash.key?('new_allocation') ? hash['new_allocation'] : nil component_id = hash.key?('component_id') ? hash['component_id'] : nil component_handle = hash.key?('component_handle') ? hash['component_handle'] : nil memo = hash.key?('memo') ? hash['memo'] : nil allocation_id = hash.key?('allocation_id') ? hash['allocation_id'] : nil allocated_quantity = hash.key?('allocated_quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:ComponentAllocationChangeAllocatedQuantity), hash['allocated_quantity'] ) : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. ComponentAllocationChange.new(previous_allocation: previous_allocation, new_allocation: new_allocation, component_id: component_id, component_handle: component_handle, memo: memo, allocation_id: allocation_id, allocated_quantity: allocated_quantity, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['previous_allocation'] = 'previous_allocation' @_hash['new_allocation'] = 'new_allocation' @_hash['component_id'] = 'component_id' @_hash['component_handle'] = 'component_handle' @_hash['memo'] = 'memo' @_hash['allocation_id'] = 'allocation_id' @_hash['allocated_quantity'] = 'allocated_quantity' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 54 def self.optionals %w[ allocated_quantity ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/advanced_billing/models/component_allocation_change.rb', line 116 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.previous_allocation, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.new_allocation, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.component_id, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.component_handle, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.allocation_id, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['previous_allocation'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['new_allocation'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['component_id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['component_handle'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['allocation_id'], ->(val) { val.instance_of? Integer }) ) end |