Class: ApiReference::TierSubLineItem
- Defined in:
- lib/api_reference/models/tier_sub_line_item.rb
Overview
TierSubLineItem 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.
-
#name ⇒ String
The total amount for this sub line item.
-
#quantity ⇒ Float
The total amount for this sub line item.
-
#tier_config ⇒ TierSubLineItemTierConfig
The total amount for this sub line item.
-
#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:, tier_config:, additional_properties: nil) ⇒ TierSubLineItem
constructor
A new instance of TierSubLineItem.
-
#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:, tier_config:, additional_properties: nil) ⇒ TierSubLineItem
Returns a new instance of TierSubLineItem.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 60 def initialize(amount:, name:, quantity:, grouping:, tier_config:, 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 = 'tier' @tier_config = tier_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/tier_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/tier_sub_line_item.rb', line 26 def grouping @grouping end |
#name ⇒ String
The total amount for this sub line item.
18 19 20 |
# File 'lib/api_reference/models/tier_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/tier_sub_line_item.rb', line 22 def quantity @quantity end |
#tier_config ⇒ TierSubLineItemTierConfig
The total amount for this sub line item.
34 35 36 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 34 def tier_config @tier_config end |
#type ⇒ String (readonly)
The total amount for this sub line item.
30 31 32 |
# File 'lib/api_reference/models/tier_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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 75 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'] tier_config = TierSubLineItemTierConfig.from_hash(hash['tier_config']) if hash['tier_config'] # 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. TierSubLineItem.new(amount: amount, name: name, quantity: quantity, grouping: grouping, tier_config: tier_config, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['name'] = 'name' @_hash['quantity'] = 'quantity' @_hash['grouping'] = 'grouping' @_hash['type'] = 'type' @_hash['tier_config'] = 'tier_config' @_hash end |
.nullables ⇒ Object
An array for nullable fields
54 55 56 57 58 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 54 def self.nullables %w[ grouping ] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 49 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
104 105 106 107 108 109 110 111 112 113 114 115 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 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 104 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.tier_config, ->(val) { TierSubLineItemTierConfig.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['tier_config'], ->(val) { TierSubLineItemTierConfig.validate(val) }, is_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
153 154 155 156 157 158 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 153 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}, tier_config:"\ " #{@tier_config.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
145 146 147 148 149 150 |
# File 'lib/api_reference/models/tier_sub_line_item.rb', line 145 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, name: #{@name}, quantity: #{@quantity}, grouping:"\ " #{@grouping}, type: #{@type}, tier_config: #{@tier_config}, additional_properties:"\ " #{@additional_properties}>" end |