Class: NewStoreApi::FulfillmentTaskItemModel

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

Overview

FulfillmentTaskItemModel 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_ids = nil, product_id = nil, quantity = nil, raw_product_id = nil, color = SKIP, external_identifiers = SKIP, image_url = SKIP, serialized_inventory = SKIP, size = SKIP, sku = SKIP, title = SKIP) ⇒ FulfillmentTaskItemModel

Returns a new instance of FulfillmentTaskItemModel.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 99

def initialize(item_ids = nil, product_id = nil, quantity = nil,
               raw_product_id = nil, color = SKIP,
               external_identifiers = SKIP, image_url = SKIP,
               serialized_inventory = SKIP, size = SKIP, sku = SKIP,
               title = SKIP)
  @color = color unless color == SKIP
  @external_identifiers = external_identifiers unless external_identifiers == SKIP
  @image_url = image_url unless image_url == SKIP
  @item_ids = item_ids
  @product_id = product_id
  @quantity = quantity
  @raw_product_id = raw_product_id
  @serialized_inventory = serialized_inventory unless serialized_inventory == SKIP
  @size = size unless size == SKIP
  @sku = sku unless sku == SKIP
  @title = title unless title == SKIP
end

Instance Attribute Details

#colorString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 14

def color
  @color
end

#external_identifiersArray[FulfillmentTaskItemExternalIdentier]

TODO: Write general description for this method



18
19
20
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 18

def external_identifiers
  @external_identifiers
end

#image_urlString

TODO: Write general description for this method

Returns:

  • (String)


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

def image_url
  @image_url
end

#item_idsArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


26
27
28
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 26

def item_ids
  @item_ids
end

#product_idString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 30

def product_id
  @product_id
end

#quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 34

def quantity
  @quantity
end

#raw_product_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def raw_product_id
  @raw_product_id
end

#serialized_inventoryTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def serialized_inventory
  @serialized_inventory
end

#sizeString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 46

def size
  @size
end

#skuString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 50

def sku
  @sku
end

#titleString

TODO: Write general description for this method

Returns:

  • (String)


54
55
56
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 54

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
155
156
157
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 118

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_ids = hash.key?('item_ids') ? hash['item_ids'] : nil
  product_id = hash.key?('product_id') ? hash['product_id'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  raw_product_id =
    hash.key?('raw_product_id') ? hash['raw_product_id'] : nil
  color = hash.key?('color') ? hash['color'] : SKIP
  # Parameter is an array, so we need to iterate through it
  external_identifiers = nil
  unless hash['external_identifiers'].nil?
    external_identifiers = []
    hash['external_identifiers'].each do |structure|
      external_identifiers << (FulfillmentTaskItemExternalIdentier.from_hash(structure) if structure)
    end
  end

  external_identifiers = SKIP unless hash.key?('external_identifiers')
  image_url = hash.key?('image_url') ? hash['image_url'] : SKIP
  serialized_inventory =
    hash.key?('serialized_inventory') ? hash['serialized_inventory'] : SKIP
  size = hash.key?('size') ? hash['size'] : SKIP
  sku = hash.key?('sku') ? hash['sku'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP

  # Create object from extracted values.
  FulfillmentTaskItemModel.new(item_ids,
                               product_id,
                               quantity,
                               raw_product_id,
                               color,
                               external_identifiers,
                               image_url,
                               serialized_inventory,
                               size,
                               sku,
                               title)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['color'] = 'color'
  @_hash['external_identifiers'] = 'external_identifiers'
  @_hash['image_url'] = 'image_url'
  @_hash['item_ids'] = 'item_ids'
  @_hash['product_id'] = 'product_id'
  @_hash['quantity'] = 'quantity'
  @_hash['raw_product_id'] = 'raw_product_id'
  @_hash['serialized_inventory'] = 'serialized_inventory'
  @_hash['size'] = 'size'
  @_hash['sku'] = 'sku'
  @_hash['title'] = 'title'
  @_hash
end

.nullablesObject

An array for nullable fields



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 87

def self.nullables
  %w[
    color
    external_identifiers
    image_url
    serialized_inventory
    size
    sku
    title
  ]
end

.optionalsObject

An array for optional fields



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 74

def self.optionals
  %w[
    color
    external_identifiers
    image_url
    serialized_inventory
    size
    sku
    title
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



169
170
171
172
173
174
175
176
177
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 169

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} color: #{@color.inspect}, external_identifiers:"\
  " #{@external_identifiers.inspect}, image_url: #{@image_url.inspect}, item_ids:"\
  " #{@item_ids.inspect}, product_id: #{@product_id.inspect}, quantity: #{@quantity.inspect},"\
  " raw_product_id: #{@raw_product_id.inspect}, serialized_inventory:"\
  " #{@serialized_inventory.inspect}, size: #{@size.inspect}, sku: #{@sku.inspect}, title:"\
  " #{@title.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



160
161
162
163
164
165
166
# File 'lib/new_store_api/models/fulfillment_task_item_model.rb', line 160

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} color: #{@color}, external_identifiers: #{@external_identifiers},"\
  " image_url: #{@image_url}, item_ids: #{@item_ids}, product_id: #{@product_id}, quantity:"\
  " #{@quantity}, raw_product_id: #{@raw_product_id}, serialized_inventory:"\
  " #{@serialized_inventory}, size: #{@size}, sku: #{@sku}, title: #{@title}>"
end