Class: MistApi::ResponseInventory

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/response_inventory.rb

Overview

ResponseInventory 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(added = SKIP, duplicated = SKIP, error = SKIP, inventory_added = SKIP, inventory_duplicated = SKIP, reason = SKIP) ⇒ ResponseInventory

Returns a new instance of ResponseInventory.



65
66
67
68
69
70
71
72
73
74
# File 'lib/mist_api/models/response_inventory.rb', line 65

def initialize(added = SKIP, duplicated = SKIP, error = SKIP,
               inventory_added = SKIP, inventory_duplicated = SKIP,
               reason = SKIP)
  @added = added unless added == SKIP
  @duplicated = duplicated unless duplicated == SKIP
  @error = error unless error == SKIP
  @inventory_added = inventory_added unless inventory_added == SKIP
  @inventory_duplicated = inventory_duplicated unless inventory_duplicated == SKIP
  @reason = reason unless reason == SKIP
end

Instance Attribute Details

#addedArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


14
15
16
# File 'lib/mist_api/models/response_inventory.rb', line 14

def added
  @added
end

#duplicatedArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


18
19
20
# File 'lib/mist_api/models/response_inventory.rb', line 18

def duplicated
  @duplicated
end

#errorArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


22
23
24
# File 'lib/mist_api/models/response_inventory.rb', line 22

def error
  @error
end

#inventory_addedArray[ResponseInventoryInventoryAddedItems]

TODO: Write general description for this method



26
27
28
# File 'lib/mist_api/models/response_inventory.rb', line 26

def inventory_added
  @inventory_added
end

#inventory_duplicatedArray[ResponseInventoryInventoryDuplicatedItems]

TODO: Write general description for this method



30
31
32
# File 'lib/mist_api/models/response_inventory.rb', line 30

def inventory_duplicated
  @inventory_duplicated
end

#reasonArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


34
35
36
# File 'lib/mist_api/models/response_inventory.rb', line 34

def reason
  @reason
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
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
# File 'lib/mist_api/models/response_inventory.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  added = hash.key?('added') ? hash['added'] : SKIP
  duplicated = hash.key?('duplicated') ? hash['duplicated'] : SKIP
  error = hash.key?('error') ? hash['error'] : SKIP
  # Parameter is an array, so we need to iterate through it
  inventory_added = nil
  unless hash['inventory_added'].nil?
    inventory_added = []
    hash['inventory_added'].each do |structure|
      inventory_added << (ResponseInventoryInventoryAddedItems.from_hash(structure) if structure)
    end
  end

  inventory_added = SKIP unless hash.key?('inventory_added')
  # Parameter is an array, so we need to iterate through it
  inventory_duplicated = nil
  unless hash['inventory_duplicated'].nil?
    inventory_duplicated = []
    hash['inventory_duplicated'].each do |structure|
      inventory_duplicated << (ResponseInventoryInventoryDuplicatedItems.from_hash(structure) if structure)
    end
  end

  inventory_duplicated = SKIP unless hash.key?('inventory_duplicated')
  reason = hash.key?('reason') ? hash['reason'] : SKIP

  # Create object from extracted values.
  ResponseInventory.new(added,
                        duplicated,
                        error,
                        inventory_added,
                        inventory_duplicated,
                        reason)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/mist_api/models/response_inventory.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['added'] = 'added'
  @_hash['duplicated'] = 'duplicated'
  @_hash['error'] = 'error'
  @_hash['inventory_added'] = 'inventory_added'
  @_hash['inventory_duplicated'] = 'inventory_duplicated'
  @_hash['reason'] = 'reason'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/mist_api/models/response_inventory.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/mist_api/models/response_inventory.rb', line 49

def self.optionals
  %w[
    added
    duplicated
    error
    inventory_added
    inventory_duplicated
    reason
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



124
125
126
127
128
129
# File 'lib/mist_api/models/response_inventory.rb', line 124

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} added: #{@added.inspect}, duplicated: #{@duplicated.inspect}, error:"\
  " #{@error.inspect}, inventory_added: #{@inventory_added.inspect}, inventory_duplicated:"\
  " #{@inventory_duplicated.inspect}, reason: #{@reason.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
121
# File 'lib/mist_api/models/response_inventory.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} added: #{@added}, duplicated: #{@duplicated}, error: #{@error},"\
  " inventory_added: #{@inventory_added}, inventory_duplicated: #{@inventory_duplicated},"\
  " reason: #{@reason}>"
end