Class: NewStoreApi::RoutingOptionsRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::RoutingOptionsRequest
- Defined in:
- lib/new_store_api/models/routing_options_request.rb
Overview
Call to get a list of routing options. Also, colloquially known as 'soft routing'.
Instance Attribute Summary collapse
-
#delivery_destination ⇒ DeliveryDestination
Destination country and the zip code where the ordered products are to be delivered.
-
#line_items ⇒ Array[LineItem21]
List of line items to be routed.
-
#routing_strategy ⇒ Object
List of line items to be routed.
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(delivery_destination = nil, line_items = nil, routing_strategy = SKIP) ⇒ RoutingOptionsRequest
constructor
A new instance of RoutingOptionsRequest.
-
#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(delivery_destination = nil, line_items = nil, routing_strategy = SKIP) ⇒ RoutingOptionsRequest
Returns a new instance of RoutingOptionsRequest.
47 48 49 50 51 52 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 47 def initialize(delivery_destination = nil, line_items = nil, routing_strategy = SKIP) @delivery_destination = delivery_destination @line_items = line_items @routing_strategy = routing_strategy unless routing_strategy == SKIP end |
Instance Attribute Details
#delivery_destination ⇒ DeliveryDestination
Destination country and the zip code where the ordered products are to be delivered.
16 17 18 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 16 def delivery_destination @delivery_destination end |
#line_items ⇒ Array[LineItem21]
List of line items to be routed.
20 21 22 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 20 def line_items @line_items end |
#routing_strategy ⇒ Object
List of line items to be routed.
24 25 26 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 24 def routing_strategy @routing_strategy end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 55 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. delivery_destination = DeliveryDestination.from_hash(hash['delivery_destination']) if hash['delivery_destination'] # 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 << (LineItem21.from_hash(structure) if structure) end end line_items = nil unless hash.key?('line_items') routing_strategy = hash.key?('routing_strategy') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:RoutingOptionsRequestRoutingStrategy), hash['routing_strategy'] ) : SKIP # Create object from extracted values. RoutingOptionsRequest.new(delivery_destination, line_items, routing_strategy) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['delivery_destination'] = 'delivery_destination' @_hash['line_items'] = 'line_items' @_hash['routing_strategy'] = 'routing_strategy' @_hash end |
.nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 43 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 39 40 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 36 def self.optionals %w[ routing_strategy ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 83 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.delivery_destination, ->(val) { DeliveryDestination.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.line_items, ->(val) { LineItem21.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['delivery_destination'], ->(val) { DeliveryDestination.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['line_items'], ->(val) { LineItem21.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
117 118 119 120 121 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 117 def inspect class_name = self.class.name.split('::').last "<#{class_name} delivery_destination: #{@delivery_destination.inspect}, line_items:"\ " #{@line_items.inspect}, routing_strategy: #{@routing_strategy.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
110 111 112 113 114 |
# File 'lib/new_store_api/models/routing_options_request.rb', line 110 def to_s class_name = self.class.name.split('::').last "<#{class_name} delivery_destination: #{@delivery_destination}, line_items: #{@line_items},"\ " routing_strategy: #{@routing_strategy}>" end |