Class: NewStoreApi::RoutingSimulationRequestPayload

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/routing_simulation_request_payload.rb

Overview

Request body for a routing simulation run.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(availabilities = nil, fulfillment_config = nil, line_items = nil) ⇒ RoutingSimulationRequestPayload

Returns a new instance of RoutingSimulationRequestPayload.



43
44
45
46
47
48
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 43

def initialize(availabilities = nil, fulfillment_config = nil,
               line_items = nil)
  @availabilities = availabilities
  @fulfillment_config = fulfillment_config
  @line_items = line_items
end

Instance Attribute Details

#availabilitiesArray[AvailabilityRow]

Product availability rows used as ATP input for the simulation.

Returns:



14
15
16
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 14

def availabilities
  @availabilities
end

#fulfillment_configFulfillmentConfigV2Body

Fulfillment configuration supplied inline for the simulation.



18
19
20
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 18

def fulfillment_config
  @fulfillment_config
end

#line_itemsArray[RoutingSimulationLineItem]

Order line items to route in the simulation.

Returns:



22
23
24
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 22

def line_items
  @line_items
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 51

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
  availabilities = nil
  unless hash['availabilities'].nil?
    availabilities = []
    hash['availabilities'].each do |structure|
      availabilities << (AvailabilityRow.from_hash(structure) if structure)
    end
  end

  availabilities = nil unless hash.key?('availabilities')
  fulfillment_config = FulfillmentConfigV2Body.from_hash(hash['fulfillment_config']) if
    hash['fulfillment_config']
  # Parameter is an array, so we need to iterate through it
  line_items = nil
  unless hash['line_items'].nil?
    line_items = []
    hash['line_items'].each do |structure|
      line_items << (RoutingSimulationLineItem.from_hash(structure) if structure)
    end
  end

  line_items = nil unless hash.key?('line_items')

  # Create object from extracted values.
  RoutingSimulationRequestPayload.new(availabilities,
                                      fulfillment_config,
                                      line_items)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['availabilities'] = 'availabilities'
  @_hash['fulfillment_config'] = 'fulfillment_config'
  @_hash['line_items'] = 'line_items'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 34

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



92
93
94
95
96
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 92

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} availabilities: #{@availabilities.inspect}, fulfillment_config:"\
  " #{@fulfillment_config.inspect}, line_items: #{@line_items.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



85
86
87
88
89
# File 'lib/new_store_api/models/routing_simulation_request_payload.rb', line 85

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} availabilities: #{@availabilities}, fulfillment_config:"\
  " #{@fulfillment_config}, line_items: #{@line_items}>"
end