Class: ApiReference::AggregatedCost
- Defined in:
- lib/api_reference/models/aggregated_cost.rb
Overview
AggregatedCost Model.
Instance Attribute Summary collapse
-
#per_price_costs ⇒ Array[PerPriceCost]
Total costs for the timeframe, including any minimums and discounts.
-
#subtotal ⇒ String
Total costs for the timeframe, excluding any minimums and discounts.
-
#timeframe_end ⇒ DateTime
Total costs for the timeframe, including any minimums and discounts.
-
#timeframe_start ⇒ DateTime
Total costs for the timeframe, including any minimums and discounts.
-
#total ⇒ String
Total costs for the timeframe, including any 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.
Instance Method Summary collapse
-
#initialize(subtotal:, total:, timeframe_start:, timeframe_end:, per_price_costs:, additional_properties: nil) ⇒ AggregatedCost
constructor
A new instance of AggregatedCost.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_timeframe_end ⇒ Object
- #to_custom_timeframe_start ⇒ Object
-
#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:, timeframe_start:, timeframe_end:, per_price_costs:, additional_properties: nil) ⇒ AggregatedCost
Returns a new instance of AggregatedCost.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 54 def initialize(subtotal:, total:, timeframe_start:, timeframe_end:, per_price_costs:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @subtotal = subtotal @total = total @timeframe_start = timeframe_start @timeframe_end = timeframe_end @per_price_costs = per_price_costs @additional_properties = additional_properties end |
Instance Attribute Details
#per_price_costs ⇒ Array[PerPriceCost]
Total costs for the timeframe, including any minimums and discounts.
31 32 33 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 31 def per_price_costs @per_price_costs end |
#subtotal ⇒ String
Total costs for the timeframe, excluding any minimums and discounts.
15 16 17 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 15 def subtotal @subtotal end |
#timeframe_end ⇒ DateTime
Total costs for the timeframe, including any minimums and discounts.
27 28 29 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 27 def timeframe_end @timeframe_end end |
#timeframe_start ⇒ DateTime
Total costs for the timeframe, including any minimums and discounts.
23 24 25 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 23 def timeframe_start @timeframe_start end |
#total ⇒ String
Total costs for the timeframe, including any minimums and discounts.
19 20 21 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 19 def total @total end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
68 69 70 71 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 99 100 101 102 103 104 105 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 68 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 timeframe_start = if hash.key?('timeframe_start') (DateTimeHelper.from_rfc3339(hash['timeframe_start']) if hash['timeframe_start']) end timeframe_end = if hash.key?('timeframe_end') (DateTimeHelper.from_rfc3339(hash['timeframe_end']) if hash['timeframe_end']) end # Parameter is an array, so we need to iterate through it per_price_costs = nil unless hash['per_price_costs'].nil? per_price_costs = [] hash['per_price_costs'].each do |structure| per_price_costs << (PerPriceCost.from_hash(structure) if structure) end end per_price_costs = nil unless hash.key?('per_price_costs') # 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. AggregatedCost.new(subtotal: subtotal, total: total, timeframe_start: timeframe_start, timeframe_end: timeframe_end, per_price_costs: per_price_costs, 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/aggregated_cost.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['subtotal'] = 'subtotal' @_hash['total'] = 'total' @_hash['timeframe_start'] = 'timeframe_start' @_hash['timeframe_end'] = 'timeframe_end' @_hash['per_price_costs'] = 'per_price_costs' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
45 46 47 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 45 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
124 125 126 127 128 129 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 124 def inspect class_name = self.class.name.split('::').last "<#{class_name} subtotal: #{@subtotal.inspect}, total: #{@total.inspect}, timeframe_start:"\ " #{@timeframe_start.inspect}, timeframe_end: #{@timeframe_end.inspect}, per_price_costs:"\ " #{@per_price_costs.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_timeframe_end ⇒ Object
111 112 113 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 111 def to_custom_timeframe_end DateTimeHelper.to_rfc3339(timeframe_end) end |
#to_custom_timeframe_start ⇒ Object
107 108 109 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 107 def to_custom_timeframe_start DateTimeHelper.to_rfc3339(timeframe_start) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
116 117 118 119 120 121 |
# File 'lib/api_reference/models/aggregated_cost.rb', line 116 def to_s class_name = self.class.name.split('::').last "<#{class_name} subtotal: #{@subtotal}, total: #{@total}, timeframe_start:"\ " #{@timeframe_start}, timeframe_end: #{@timeframe_end}, per_price_costs:"\ " #{@per_price_costs}, additional_properties: #{@additional_properties}>" end |