Class: WalmartApIs::Item1

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

Overview

Information associated with a single SKU in the seller's catalog.

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(msku:, label_owner:, prep_instructions:, quantity:, expiration: SKIP, manufacturing_lot_code: SKIP, additional_properties: nil) ⇒ Item1

Returns a new instance of Item1.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/walmart_ap_is/models/item1.rb', line 63

def initialize(msku:, label_owner:, prep_instructions:, quantity:,
               expiration: SKIP, manufacturing_lot_code: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @msku = msku
  @expiration = expiration unless expiration == SKIP
  @label_owner = label_owner
  @manufacturing_lot_code = manufacturing_lot_code unless manufacturing_lot_code == SKIP
  @prep_instructions = prep_instructions
  @quantity = quantity
  @additional_properties = additional_properties
end

Instance Attribute Details

#expirationString

The expiration date of the MSKU. In ISO 8601 date format with pattern YYYY-MM-DD. The same MSKU with different expiration dates cannot go into the same box.

Returns:

  • (String)


20
21
22
# File 'lib/walmart_ap_is/models/item1.rb', line 20

def expiration
  @expiration
end

#label_ownerString

Specifies who will label the items. Options include SELLER and NONE.

Returns:

  • (String)


24
25
26
# File 'lib/walmart_ap_is/models/item1.rb', line 24

def label_owner
  @label_owner
end

#manufacturing_lot_codeString

The manufacturing lot code.

Returns:

  • (String)


28
29
30
# File 'lib/walmart_ap_is/models/item1.rb', line 28

def manufacturing_lot_code
  @manufacturing_lot_code
end

#mskuString

The merchant-defined SKU ID.

Returns:

  • (String)


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

def msku
  @msku
end

#prep_instructionsArray[PrepInstruction]

Special preparations that are required for an item.

Returns:



32
33
34
# File 'lib/walmart_ap_is/models/item1.rb', line 32

def prep_instructions
  @prep_instructions
end

#quantityInteger

The number of the specified MSKU.

Returns:

  • (Integer)


36
37
38
# File 'lib/walmart_ap_is/models/item1.rb', line 36

def quantity
  @quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
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
108
109
110
111
112
113
114
115
# File 'lib/walmart_ap_is/models/item1.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  msku = hash.key?('msku') ? hash['msku'] : nil
  label_owner = hash.key?('labelOwner') ? hash['labelOwner'] : nil
  # Parameter is an array, so we need to iterate through it
  prep_instructions = nil
  unless hash['prepInstructions'].nil?
    prep_instructions = []
    hash['prepInstructions'].each do |structure|
      prep_instructions << (PrepInstruction.from_hash(structure) if structure)
    end
  end

  prep_instructions = nil unless hash.key?('prepInstructions')
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  expiration = hash.key?('expiration') ? hash['expiration'] : SKIP
  manufacturing_lot_code =
    hash.key?('manufacturingLotCode') ? hash['manufacturingLotCode'] : SKIP

  # 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.
  Item1.new(msku: msku,
            label_owner: label_owner,
            prep_instructions: prep_instructions,
            quantity: quantity,
            expiration: expiration,
            manufacturing_lot_code: manufacturing_lot_code,
            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/walmart_ap_is/models/item1.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['msku'] = 'msku'
  @_hash['expiration'] = 'expiration'
  @_hash['label_owner'] = 'labelOwner'
  @_hash['manufacturing_lot_code'] = 'manufacturingLotCode'
  @_hash['prep_instructions'] = 'prepInstructions'
  @_hash['quantity'] = 'quantity'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/walmart_ap_is/models/item1.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
# File 'lib/walmart_ap_is/models/item1.rb', line 51

def self.optionals
  %w[
    expiration
    manufacturing_lot_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



127
128
129
130
131
132
133
# File 'lib/walmart_ap_is/models/item1.rb', line 127

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} msku: #{@msku.inspect}, expiration: #{@expiration.inspect}, label_owner:"\
  " #{@label_owner.inspect}, manufacturing_lot_code: #{@manufacturing_lot_code.inspect},"\
  " prep_instructions: #{@prep_instructions.inspect}, quantity: #{@quantity.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
123
124
# File 'lib/walmart_ap_is/models/item1.rb', line 118

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} msku: #{@msku}, expiration: #{@expiration}, label_owner: #{@label_owner},"\
  " manufacturing_lot_code: #{@manufacturing_lot_code}, prep_instructions:"\
  " #{@prep_instructions}, quantity: #{@quantity}, additional_properties:"\
  " #{@additional_properties}>"
end