Class: ApiReference::MatrixSubLineItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::MatrixSubLineItem
- Defined in:
- lib/api_reference/models/matrix_sub_line_item.rb
Overview
MatrixSubLineItem Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
The total amount for this sub line item.
-
#grouping ⇒ SubLineItemGrouping
The total amount for this sub line item.
-
#matrix_config ⇒ SubLineItemMatrixConfig
The scaled quantity for this line item for specific pricing structures.
-
#name ⇒ String
The total amount for this sub line item.
-
#quantity ⇒ Float
The total amount for this sub line item.
-
#scaled_quantity ⇒ Float
The scaled quantity for this line item for specific pricing structures.
-
#type ⇒ String
readonly
The total amount for this sub line item.
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(amount:, name:, quantity:, grouping:, matrix_config:, scaled_quantity: SKIP, additional_properties: nil) ⇒ MatrixSubLineItem
constructor
A new instance of MatrixSubLineItem.
-
#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, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(amount:, name:, quantity:, grouping:, matrix_config:, scaled_quantity: SKIP, additional_properties: nil) ⇒ MatrixSubLineItem
Returns a new instance of MatrixSubLineItem.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 68 def initialize(amount:, name:, quantity:, grouping:, matrix_config:, scaled_quantity: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @amount = amount @name = name @quantity = quantity @grouping = grouping @type = 'matrix' @scaled_quantity = scaled_quantity unless scaled_quantity == SKIP @matrix_config = matrix_config @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ String
The total amount for this sub line item.
14 15 16 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 14 def amount @amount end |
#grouping ⇒ SubLineItemGrouping
The total amount for this sub line item.
26 27 28 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 26 def grouping @grouping end |
#matrix_config ⇒ SubLineItemMatrixConfig
The scaled quantity for this line item for specific pricing structures
38 39 40 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 38 def matrix_config @matrix_config end |
#name ⇒ String
The total amount for this sub line item.
18 19 20 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 18 def name @name end |
#quantity ⇒ Float
The total amount for this sub line item.
22 23 24 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 22 def quantity @quantity end |
#scaled_quantity ⇒ Float
The scaled quantity for this line item for specific pricing structures
34 35 36 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 34 def scaled_quantity @scaled_quantity end |
#type ⇒ String (readonly)
The total amount for this sub line item.
30 31 32 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 30 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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/api_reference/models/matrix_sub_line_item.rb', line 84 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil name = hash.key?('name') ? hash['name'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil grouping = SubLineItemGrouping.from_hash(hash['grouping']) if hash['grouping'] matrix_config = SubLineItemMatrixConfig.from_hash(hash['matrix_config']) if hash['matrix_config'] scaled_quantity = hash.key?('scaled_quantity') ? hash['scaled_quantity'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. MatrixSubLineItem.new(amount: amount, name: name, quantity: quantity, grouping: grouping, matrix_config: matrix_config, scaled_quantity: scaled_quantity, additional_properties: additional_properties) 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/api_reference/models/matrix_sub_line_item.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['name'] = 'name' @_hash['quantity'] = 'quantity' @_hash['grouping'] = 'grouping' @_hash['type'] = 'type' @_hash['scaled_quantity'] = 'scaled_quantity' @_hash['matrix_config'] = 'matrix_config' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 64 65 66 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 61 def self.nullables %w[ grouping scaled_quantity ] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 54 def self.optionals %w[ scaled_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 151 152 153 154 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 116 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.quantity, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.grouping, ->(val) { SubLineItemGrouping.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.matrix_config, ->(val) { SubLineItemMatrixConfig.validate(val) }, is_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['quantity'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['grouping'], ->(val) { SubLineItemGrouping.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['matrix_config'], ->(val) { SubLineItemMatrixConfig.validate(val) }, is_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
165 166 167 168 169 170 171 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 165 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, name: #{@name.inspect}, quantity:"\ " #{@quantity.inspect}, grouping: #{@grouping.inspect}, type: #{@type.inspect},"\ " scaled_quantity: #{@scaled_quantity.inspect}, matrix_config: #{@matrix_config.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
157 158 159 160 161 162 |
# File 'lib/api_reference/models/matrix_sub_line_item.rb', line 157 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, name: #{@name}, quantity: #{@quantity}, grouping:"\ " #{@grouping}, type: #{@type}, scaled_quantity: #{@scaled_quantity}, matrix_config:"\ " #{@matrix_config}, additional_properties: #{@additional_properties}>" end |