Class: NewStoreApi::RoutingOptionsResponse

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

Overview

Represents a list of possible routing options. Also, colloquially known as the result of 'soft routing'.

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(routing_options = nil, status = nil, unavailable_products = SKIP) ⇒ RoutingOptionsResponse

Returns a new instance of RoutingOptionsResponse.



46
47
48
49
50
51
# File 'lib/new_store_api/models/routing_options_response.rb', line 46

def initialize(routing_options = nil, status = nil,
               unavailable_products = SKIP)
  @routing_options = routing_options
  @status = status
  @unavailable_products = unavailable_products unless unavailable_products == SKIP
end

Instance Attribute Details

#routing_optionsArray[FulfillmentNodeAssignment]

TODO: Write general description for this method

Returns:



15
16
17
# File 'lib/new_store_api/models/routing_options_response.rb', line 15

def routing_options
  @routing_options
end

#statusStatus21Enum

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/new_store_api/models/routing_options_response.rb', line 19

def status
  @status
end

#unavailable_productsArray[String]

Contains the list of unavailable products

Returns:

  • (Array[String])


23
24
25
# File 'lib/new_store_api/models/routing_options_response.rb', line 23

def unavailable_products
  @unavailable_products
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/new_store_api/models/routing_options_response.rb', line 54

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

  routing_options = nil unless hash.key?('routing_options')
  status = hash.key?('status') ? hash['status'] : nil
  unavailable_products =
    hash.key?('unavailable_products') ? hash['unavailable_products'] : SKIP

  # Create object from extracted values.
  RoutingOptionsResponse.new(routing_options,
                             status,
                             unavailable_products)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['routing_options'] = 'routing_options'
  @_hash['status'] = 'status'
  @_hash['unavailable_products'] = 'unavailable_products'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/new_store_api/models/routing_options_response.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
# File 'lib/new_store_api/models/routing_options_response.rb', line 35

def self.optionals
  %w[
    unavailable_products
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



86
87
88
89
90
# File 'lib/new_store_api/models/routing_options_response.rb', line 86

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

#to_sObject

Provides a human-readable string representation of the object.



79
80
81
82
83
# File 'lib/new_store_api/models/routing_options_response.rb', line 79

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