Class: NewStoreApi::RoutingSimulationResponsePayload
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::RoutingSimulationResponsePayload
- Defined in:
- lib/new_store_api/models/routing_simulation_response_payload.rb
Overview
Response body for a routing simulation run.
Instance Attribute Summary collapse
-
#decision_trace ⇒ RoutingDecisionTrace
Optional decision trace explaining how routing chose placements.
-
#items ⇒ Array[SimulationRoutedItem]
Flat list of routed line items with their selected locations.
-
#not_routed_items ⇒ Array[NotRoutedItemResponse]
Line items that could not be routed.
-
#result ⇒ Hash[String, Object]
Routing result assignments grouped by location and service level.
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(items = nil, result = nil, decision_trace = SKIP, not_routed_items = SKIP) ⇒ RoutingSimulationResponsePayload
constructor
A new instance of RoutingSimulationResponsePayload.
-
#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(items = nil, result = nil, decision_trace = SKIP, not_routed_items = SKIP) ⇒ RoutingSimulationResponsePayload
Returns a new instance of RoutingSimulationResponsePayload.
53 54 55 56 57 58 59 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 53 def initialize(items = nil, result = nil, decision_trace = SKIP, not_routed_items = SKIP) @decision_trace = decision_trace unless decision_trace == SKIP @items = items @not_routed_items = not_routed_items unless not_routed_items == SKIP @result = result end |
Instance Attribute Details
#decision_trace ⇒ RoutingDecisionTrace
Optional decision trace explaining how routing chose placements.
14 15 16 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 14 def decision_trace @decision_trace end |
#items ⇒ Array[SimulationRoutedItem]
Flat list of routed line items with their selected locations.
18 19 20 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 18 def items @items end |
#not_routed_items ⇒ Array[NotRoutedItemResponse]
Line items that could not be routed.
22 23 24 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 22 def not_routed_items @not_routed_items end |
#result ⇒ Hash[String, Object]
Routing result assignments grouped by location and service level.
26 27 28 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 26 def result @result end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 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 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (SimulationRoutedItem.from_hash(structure) if structure) end end items = nil unless hash.key?('items') result = hash.key?('result') ? hash['result'] : nil decision_trace = RoutingDecisionTrace.from_hash(hash['decision_trace']) if hash['decision_trace'] # Parameter is an array, so we need to iterate through it not_routed_items = nil unless hash['not_routed_items'].nil? not_routed_items = [] hash['not_routed_items'].each do |structure| not_routed_items << (NotRoutedItemResponse.from_hash(structure) if structure) end end not_routed_items = SKIP unless hash.key?('not_routed_items') # Create object from extracted values. RoutingSimulationResponsePayload.new(items, result, decision_trace, not_routed_items) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['decision_trace'] = 'decision_trace' @_hash['items'] = 'items' @_hash['not_routed_items'] = 'not_routed_items' @_hash['result'] = 'result' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 50 51 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 47 def self.nullables %w[ decision_trace ] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 39 def self.optionals %w[ decision_trace not_routed_items ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
105 106 107 108 109 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 105 def inspect class_name = self.class.name.split('::').last "<#{class_name} decision_trace: #{@decision_trace.inspect}, items: #{@items.inspect},"\ " not_routed_items: #{@not_routed_items.inspect}, result: #{@result.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
98 99 100 101 102 |
# File 'lib/new_store_api/models/routing_simulation_response_payload.rb', line 98 def to_s class_name = self.class.name.split('::').last "<#{class_name} decision_trace: #{@decision_trace}, items: #{@items}, not_routed_items:"\ " #{@not_routed_items}, result: #{@result}>" end |