Class: NewStoreApi::Item22

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

Overview

A combination of item id (Sales Order Item UUID) and action to be taken to this item (reroute/cancel or swap).

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(item_id = nil, route_to = nil) ⇒ Item22

Returns a new instance of Item22.



45
46
47
48
49
# File 'lib/new_store_api/models/item22.rb', line 45

def initialize(item_id = nil, route_to = nil)
  @action = 'manual_routing'
  @item_id = item_id
  @route_to = route_to
end

Instance Attribute Details

#actionString (readonly)

Action to be performed with the item(manual_routing).

Returns:

  • (String)


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

def action
  @action
end

#item_idString

Identifier (Sales Order Item UUID) of a single item in logistic order.

Returns:

  • (String)


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

def item_id
  @item_id
end

#route_toRouteTo

Contains the fulfillment node identifier where the sales order item should be routed to (used for manual routing action).

Returns:



24
25
26
# File 'lib/new_store_api/models/item22.rb', line 24

def route_to
  @route_to
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/new_store_api/models/item22.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  route_to = RouteTo.from_hash(hash['route_to']) if hash['route_to']

  # Create object from extracted values.
  Item22.new(item_id,
             route_to)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['action'] = 'action'
  @_hash['item_id'] = 'item_id'
  @_hash['route_to'] = 'route_to'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/new_store_api/models/item22.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
# File 'lib/new_store_api/models/item22.rb', line 36

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Item22 | Hash)

    value against the validation is performed.



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
# File 'lib/new_store_api/models/item22.rb', line 66

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.action,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.item_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.route_to,
                              ->(val) { RouteTo.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['action'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['item_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['route_to'],
                            ->(val) { RouteTo.validate(val) },
                            is_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



99
100
101
102
103
# File 'lib/new_store_api/models/item22.rb', line 99

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

#to_sObject

Provides a human-readable string representation of the object.



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

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