Class: WalmartApIs::WfsItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/wfs_item.rb

Overview

WfsItem Model.

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_information:, inventory_data: SKIP, inventory_insights: SKIP, additional_properties: nil) ⇒ WfsItem

Returns a new instance of WfsItem.



47
48
49
50
51
52
53
54
55
56
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 47

def initialize(item_information:, inventory_data: SKIP,
               inventory_insights: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @item_information = item_information
  @inventory_data = inventory_data unless inventory_data == SKIP
  @inventory_insights = inventory_insights unless inventory_insights == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#inventory_dataWfsInventoryData

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 18

def inventory_data
  @inventory_data
end

#inventory_insightsWfsInventoryInsights

Demand intelligence and replenishment recommendations (WFS-only — no SP-API equivalent)



23
24
25
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 23

def inventory_insights
  @inventory_insights
end

#item_informationWfsItemInformation

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 14

def item_information
  @item_information
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 59

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_information = WfsItemInformation.from_hash(hash['itemInformation']) if
    hash['itemInformation']
  inventory_data = WfsInventoryData.from_hash(hash['inventoryData']) if hash['inventoryData']
  inventory_insights = WfsInventoryInsights.from_hash(hash['inventoryInsights']) if
    hash['inventoryInsights']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  WfsItem.new(item_information: item_information,
              inventory_data: inventory_data,
              inventory_insights: inventory_insights,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_information'] = 'itemInformation'
  @_hash['inventory_data'] = 'inventoryData'
  @_hash['inventory_insights'] = 'inventoryInsights'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
40
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 35

def self.optionals
  %w[
    inventory_data
    inventory_insights
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



92
93
94
95
96
97
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 92

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} item_information: #{@item_information.inspect}, inventory_data:"\
  " #{@inventory_data.inspect}, inventory_insights: #{@inventory_insights.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



84
85
86
87
88
89
# File 'lib/walmart_ap_is/models/wfs_item.rb', line 84

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} item_information: #{@item_information}, inventory_data: #{@inventory_data},"\
  " inventory_insights: #{@inventory_insights}, additional_properties:"\
  " #{@additional_properties}>"
end