Class: ApiReference::PerPriceCost
- Defined in:
- lib/api_reference/models/per_price_cost.rb
Overview
PerPriceCost Model.
Instance Attribute Summary collapse
-
#price ⇒ Object
The price object.
-
#price_id ⇒ String
The price the cost is associated with.
-
#quantity ⇒ Float
The price's quantity for the timeframe.
-
#subtotal ⇒ String
Price's contributions for the timeframe, excluding any minimums and discounts.
-
#total ⇒ String
Price's contributions for the timeframe, including minimums and discounts.
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(subtotal:, total:, price:, price_id:, quantity: SKIP, additional_properties: nil) ⇒ PerPriceCost
constructor
A new instance of PerPriceCost.
-
#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(subtotal:, total:, price:, price_id:, quantity: SKIP, additional_properties: nil) ⇒ PerPriceCost
Returns a new instance of PerPriceCost.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/api_reference/models/per_price_cost.rb', line 58 def initialize(subtotal:, total:, price:, price_id:, quantity: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @quantity = quantity unless quantity == SKIP @subtotal = subtotal @total = total @price = price @price_id = price_id @additional_properties = additional_properties end |
Instance Attribute Details
#price ⇒ Object
The price object
27 28 29 |
# File 'lib/api_reference/models/per_price_cost.rb', line 27 def price @price end |
#price_id ⇒ String
The price the cost is associated with
31 32 33 |
# File 'lib/api_reference/models/per_price_cost.rb', line 31 def price_id @price_id end |
#quantity ⇒ Float
The price's quantity for the timeframe
14 15 16 |
# File 'lib/api_reference/models/per_price_cost.rb', line 14 def quantity @quantity end |
#subtotal ⇒ String
Price's contributions for the timeframe, excluding any minimums and discounts.
19 20 21 |
# File 'lib/api_reference/models/per_price_cost.rb', line 19 def subtotal @subtotal end |
#total ⇒ String
Price's contributions for the timeframe, including minimums and discounts.
23 24 25 |
# File 'lib/api_reference/models/per_price_cost.rb', line 23 def total @total end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/api_reference/models/per_price_cost.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. subtotal = hash.key?('subtotal') ? hash['subtotal'] : nil total = hash.key?('total') ? hash['total'] : nil price = hash.key?('price') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:PerPriceCostPrice), hash['price'] ) : nil price_id = hash.key?('price_id') ? hash['price_id'] : nil quantity = hash.key?('quantity') ? hash['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. PerPriceCost.new(subtotal: subtotal, total: total, price: price, price_id: price_id, quantity: quantity, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 |
# File 'lib/api_reference/models/per_price_cost.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['quantity'] = 'quantity' @_hash['subtotal'] = 'subtotal' @_hash['total'] = 'total' @_hash['price'] = 'price' @_hash['price_id'] = 'price_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
52 53 54 55 56 |
# File 'lib/api_reference/models/per_price_cost.rb', line 52 def self.nullables %w[ quantity ] end |
.optionals ⇒ Object
An array for optional fields
45 46 47 48 49 |
# File 'lib/api_reference/models/per_price_cost.rb', line 45 def self.optionals %w[ quantity ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
102 103 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 |
# File 'lib/api_reference/models/per_price_cost.rb', line 102 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.subtotal, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.total, ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:PerPriceCostPrice) .validate(value.price) and APIHelper.valid_type?(value.price_id, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['subtotal'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['total'], ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:PerPriceCostPrice) .validate(value['price']) and APIHelper.valid_type?(value['price_id'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
138 139 140 141 142 143 |
# File 'lib/api_reference/models/per_price_cost.rb', line 138 def inspect class_name = self.class.name.split('::').last "<#{class_name} quantity: #{@quantity.inspect}, subtotal: #{@subtotal.inspect}, total:"\ " #{@total.inspect}, price: #{@price.inspect}, price_id: #{@price_id.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
131 132 133 134 135 |
# File 'lib/api_reference/models/per_price_cost.rb', line 131 def to_s class_name = self.class.name.split('::').last "<#{class_name} quantity: #{@quantity}, subtotal: #{@subtotal}, total: #{@total}, price:"\ " #{@price}, price_id: #{@price_id}, additional_properties: #{@additional_properties}>" end |