Class: WalmartApIs::InventorySummary

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

Overview

InventorySummary 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(seller_sku:, walmart_item_id: SKIP, ship_node: SKIP, fulfillment_type: SKIP, condition: Condition::NEW, total_quantity: SKIP, available_quantity: SKIP, reserved_quantity: SKIP, researching_quantity: SKIP, last_updated: SKIP, additional_properties: nil) ⇒ InventorySummary

Returns a new instance of InventorySummary.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 89

def initialize(seller_sku:, walmart_item_id: SKIP, ship_node: SKIP,
               fulfillment_type: SKIP, condition: Condition::NEW,
               total_quantity: SKIP, available_quantity: SKIP,
               reserved_quantity: SKIP, researching_quantity: SKIP,
               last_updated: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @seller_sku = seller_sku
  @walmart_item_id = walmart_item_id unless walmart_item_id == SKIP
  @ship_node = ship_node unless ship_node == SKIP
  @fulfillment_type = fulfillment_type unless fulfillment_type == SKIP
  @condition = condition unless condition == SKIP
  @total_quantity = total_quantity unless total_quantity == SKIP
  @available_quantity = available_quantity unless available_quantity == SKIP
  @reserved_quantity = reserved_quantity unless reserved_quantity == SKIP
  @researching_quantity = researching_quantity unless researching_quantity == SKIP
  @last_updated = last_updated unless last_updated == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#available_quantityQuantity

TODO: Write general description for this method

Returns:



39
40
41
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 39

def available_quantity
  @available_quantity
end

#conditionCondition

TODO: Write general description for this method

Returns:



31
32
33
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 31

def condition
  @condition
end

#fulfillment_typeFulfillmentType

TODO: Write general description for this method

Returns:



27
28
29
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 27

def fulfillment_type
  @fulfillment_type
end

#last_updatedDateTime

Breakdown of reserved quantities

Returns:

  • (DateTime)


51
52
53
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 51

def last_updated
  @last_updated
end

#researching_quantityQuantity

Breakdown of reserved quantities

Returns:



47
48
49
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 47

def researching_quantity
  @researching_quantity
end

#reserved_quantityReservedQuantity

Breakdown of reserved quantities

Returns:



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

def reserved_quantity
  @reserved_quantity
end

#seller_skuString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 15

def seller_sku
  @seller_sku
end

#ship_nodeString

TODO: Write general description for this method

Returns:

  • (String)


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

def ship_node
  @ship_node
end

#total_quantityQuantity

TODO: Write general description for this method

Returns:



35
36
37
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 35

def total_quantity
  @total_quantity
end

#walmart_item_idString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 19

def walmart_item_id
  @walmart_item_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 111

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  seller_sku = hash.key?('sellerSku') ? hash['sellerSku'] : nil
  walmart_item_id =
    hash.key?('walmartItemId') ? hash['walmartItemId'] : SKIP
  ship_node = hash.key?('shipNode') ? hash['shipNode'] : SKIP
  fulfillment_type =
    hash.key?('fulfillmentType') ? hash['fulfillmentType'] : SKIP
  condition = hash['condition'] ||= Condition::NEW
  total_quantity = Quantity.from_hash(hash['totalQuantity']) if hash['totalQuantity']
  available_quantity = Quantity.from_hash(hash['availableQuantity']) if
    hash['availableQuantity']
  reserved_quantity = ReservedQuantity.from_hash(hash['reservedQuantity']) if
    hash['reservedQuantity']
  researching_quantity = Quantity.from_hash(hash['researchingQuantity']) if
    hash['researchingQuantity']
  last_updated = if hash.key?('lastUpdated')
                   (DateTimeHelper.from_rfc3339(hash['lastUpdated']) if hash['lastUpdated'])
                 else
                   SKIP
                 end

  # 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.
  InventorySummary.new(seller_sku: seller_sku,
                       walmart_item_id: walmart_item_id,
                       ship_node: ship_node,
                       fulfillment_type: fulfillment_type,
                       condition: condition,
                       total_quantity: total_quantity,
                       available_quantity: available_quantity,
                       reserved_quantity: reserved_quantity,
                       researching_quantity: researching_quantity,
                       last_updated: last_updated,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 54

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['seller_sku'] = 'sellerSku'
  @_hash['walmart_item_id'] = 'walmartItemId'
  @_hash['ship_node'] = 'shipNode'
  @_hash['fulfillment_type'] = 'fulfillmentType'
  @_hash['condition'] = 'condition'
  @_hash['total_quantity'] = 'totalQuantity'
  @_hash['available_quantity'] = 'availableQuantity'
  @_hash['reserved_quantity'] = 'reservedQuantity'
  @_hash['researching_quantity'] = 'researchingQuantity'
  @_hash['last_updated'] = 'lastUpdated'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 85

def self.nullables
  []
end

.optionalsObject

An array for optional fields



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 70

def self.optionals
  %w[
    walmart_item_id
    ship_node
    fulfillment_type
    condition
    total_quantity
    available_quantity
    reserved_quantity
    researching_quantity
    last_updated
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



172
173
174
175
176
177
178
179
180
181
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 172

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} seller_sku: #{@seller_sku.inspect}, walmart_item_id:"\
  " #{@walmart_item_id.inspect}, ship_node: #{@ship_node.inspect}, fulfillment_type:"\
  " #{@fulfillment_type.inspect}, condition: #{@condition.inspect}, total_quantity:"\
  " #{@total_quantity.inspect}, available_quantity: #{@available_quantity.inspect},"\
  " reserved_quantity: #{@reserved_quantity.inspect}, researching_quantity:"\
  " #{@researching_quantity.inspect}, last_updated: #{@last_updated.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_last_updatedObject



156
157
158
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 156

def to_custom_last_updated
  DateTimeHelper.to_rfc3339(last_updated)
end

#to_sObject

Provides a human-readable string representation of the object.



161
162
163
164
165
166
167
168
169
# File 'lib/walmart_ap_is/models/inventory_summary.rb', line 161

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} seller_sku: #{@seller_sku}, walmart_item_id: #{@walmart_item_id},"\
  " ship_node: #{@ship_node}, fulfillment_type: #{@fulfillment_type}, condition:"\
  " #{@condition}, total_quantity: #{@total_quantity}, available_quantity:"\
  " #{@available_quantity}, reserved_quantity: #{@reserved_quantity}, researching_quantity:"\
  " #{@researching_quantity}, last_updated: #{@last_updated}, additional_properties:"\
  " #{@additional_properties}>"
end