Class: NewStoreApi::TaskPackageItem

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

Overview

TaskPackageItem 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_id = nil, product_id = nil, raw_product_id = nil, epc = SKIP, serial_number = SKIP) ⇒ TaskPackageItem

Returns a new instance of TaskPackageItem.



59
60
61
62
63
64
65
66
# File 'lib/new_store_api/models/task_package_item.rb', line 59

def initialize(item_id = nil, product_id = nil, raw_product_id = nil,
               epc = SKIP, serial_number = SKIP)
  @epc = epc unless epc == SKIP
  @item_id = item_id
  @product_id = product_id
  @raw_product_id = raw_product_id
  @serial_number = serial_number unless serial_number == SKIP
end

Instance Attribute Details

#epcEpcBody

TODO: Write general description for this method

Returns:



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

def epc
  @epc
end

#item_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def item_id
  @item_id
end

#product_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def product_id
  @product_id
end

#raw_product_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def raw_product_id
  @raw_product_id
end

#serial_numberString

TODO: Write general description for this method

Returns:

  • (String)


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

def serial_number
  @serial_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/new_store_api/models/task_package_item.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  product_id = hash.key?('product_id') ? hash['product_id'] : nil
  raw_product_id =
    hash.key?('raw_product_id') ? hash['raw_product_id'] : nil
  epc = EpcBody.from_hash(hash['epc']) if hash['epc']
  serial_number = hash.key?('serial_number') ? hash['serial_number'] : SKIP

  # Create object from extracted values.
  TaskPackageItem.new(item_id,
                      product_id,
                      raw_product_id,
                      epc,
                      serial_number)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/new_store_api/models/task_package_item.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['epc'] = 'epc'
  @_hash['item_id'] = 'item_id'
  @_hash['product_id'] = 'product_id'
  @_hash['raw_product_id'] = 'raw_product_id'
  @_hash['serial_number'] = 'serial_number'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
55
56
57
# File 'lib/new_store_api/models/task_package_item.rb', line 52

def self.nullables
  %w[
    epc
    serial_number
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    epc
    serial_number
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



96
97
98
99
100
101
# File 'lib/new_store_api/models/task_package_item.rb', line 96

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

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
# File 'lib/new_store_api/models/task_package_item.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} epc: #{@epc}, item_id: #{@item_id}, product_id: #{@product_id},"\
  " raw_product_id: #{@raw_product_id}, serial_number: #{@serial_number}>"
end