Class: NewStoreApi::OrderConflictResolutionRequest

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

Overview

Triggers processing of logistic orders in 'conflict' state. Specific action (cancel, reroute, swap, etc) for each conflicted item in order must be defined.

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(items = nil, order_id = nil) ⇒ OrderConflictResolutionRequest

Returns a new instance of OrderConflictResolutionRequest.



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

def initialize(items = nil, order_id = nil)
  @items = items
  @order_id = order_id
end

Instance Attribute Details

#itemsArray[Object]

Complete list of items and actions to be performed on them (reroute/cancel or swap).

Returns:

  • (Array[Object])


17
18
19
# File 'lib/new_store_api/models/order_conflict_resolution_request.rb', line 17

def items
  @items
end

#order_idString

The internal identifier(Sales Order UUID) of the order that we want to fix.

Returns:

  • (String)


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

def order_id
  @order_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/new_store_api/models/order_conflict_resolution_request.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  items = hash.key?('items') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:OrderConflictResolutionRequestItems), hash['items']
  ) : nil
  order_id = hash.key?('order_id') ? hash['order_id'] : nil

  # Create object from extracted values.
  OrderConflictResolutionRequest.new(items,
                                     order_id)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['items'] = 'items'
  @_hash['order_id'] = 'order_id'
  @_hash
end

.nullablesObject

An array for nullable fields



38
39
40
# File 'lib/new_store_api/models/order_conflict_resolution_request.rb', line 38

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
# File 'lib/new_store_api/models/order_conflict_resolution_request.rb', line 33

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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/order_conflict_resolution_request.rb', line 64

def self.validate(value)
  if value.instance_of? self
    return (
      UnionTypeLookUp.get(:OrderConflictResolutionRequestItems)
                     .validate(value.items) and
        APIHelper.valid_type?(value.order_id,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    UnionTypeLookUp.get(:OrderConflictResolutionRequestItems)
                   .validate(value['items']) and
      APIHelper.valid_type?(value['order_id'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



91
92
93
94
# File 'lib/new_store_api/models/order_conflict_resolution_request.rb', line 91

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} items: #{@items.inspect}, order_id: #{@order_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} items: #{@items}, order_id: #{@order_id}>"
end