Class: WalmartApIs::ReservedQuantity

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

Overview

Breakdown of reserved quantities

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(total_reserved_quantity: SKIP, pending_customer_order_quantity: SKIP, pending_transshipment_quantity: SKIP, additional_properties: nil) ⇒ ReservedQuantity

Returns a new instance of ReservedQuantity.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 49

def initialize(total_reserved_quantity: SKIP,
               pending_customer_order_quantity: SKIP,
               pending_transshipment_quantity: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_reserved_quantity = total_reserved_quantity unless total_reserved_quantity == SKIP
  unless pending_customer_order_quantity == SKIP
    @pending_customer_order_quantity =
      pending_customer_order_quantity
  end
  unless pending_transshipment_quantity == SKIP
    @pending_transshipment_quantity =
      pending_transshipment_quantity
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#pending_customer_order_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 18

def pending_customer_order_quantity
  @pending_customer_order_quantity
end

#pending_transshipment_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 22

def pending_transshipment_quantity
  @pending_transshipment_quantity
end

#total_reserved_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def total_reserved_quantity
  @total_reserved_quantity
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
87
88
89
90
91
92
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_reserved_quantity =
    hash.key?('totalReservedQuantity') ? hash['totalReservedQuantity'] : SKIP
  pending_customer_order_quantity =
    hash.key?('pendingCustomerOrderQuantity') ? hash['pendingCustomerOrderQuantity'] : SKIP
  pending_transshipment_quantity =
    hash.key?('pendingTransshipmentQuantity') ? hash['pendingTransshipmentQuantity'] : 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.
  ReservedQuantity.new(total_reserved_quantity: total_reserved_quantity,
                       pending_customer_order_quantity: pending_customer_order_quantity,
                       pending_transshipment_quantity: pending_transshipment_quantity,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
32
33
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_reserved_quantity'] = 'totalReservedQuantity'
  @_hash['pending_customer_order_quantity'] =
    'pendingCustomerOrderQuantity'
  @_hash['pending_transshipment_quantity'] =
    'pendingTransshipmentQuantity'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
42
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 36

def self.optionals
  %w[
    total_reserved_quantity
    pending_customer_order_quantity
    pending_transshipment_quantity
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
108
109
110
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 104

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_reserved_quantity: #{@total_reserved_quantity.inspect},"\
  " pending_customer_order_quantity: #{@pending_customer_order_quantity.inspect},"\
  " pending_transshipment_quantity: #{@pending_transshipment_quantity.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
100
101
# File 'lib/walmart_ap_is/models/reserved_quantity.rb', line 95

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_reserved_quantity: #{@total_reserved_quantity},"\
  " pending_customer_order_quantity: #{@pending_customer_order_quantity},"\
  " pending_transshipment_quantity: #{@pending_transshipment_quantity}, additional_properties:"\
  " #{@additional_properties}>"
end