Class: WalmartApIs::Payload

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

Overview

Payload 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(fulfillment_order: SKIP, fulfillment_order_items: SKIP, fulfillment_shipments: SKIP, additional_properties: nil) ⇒ Payload

Returns a new instance of Payload.



47
48
49
50
51
52
53
54
55
56
# File 'lib/walmart_ap_is/models/payload.rb', line 47

def initialize(fulfillment_order: SKIP, fulfillment_order_items: SKIP,
               fulfillment_shipments: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @fulfillment_order = fulfillment_order unless fulfillment_order == SKIP
  @fulfillment_order_items = fulfillment_order_items unless fulfillment_order_items == SKIP
  @fulfillment_shipments = fulfillment_shipments unless fulfillment_shipments == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#fulfillment_orderFulfillmentOrder

TODO: Write general description for this method

Returns:



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

def fulfillment_order
  @fulfillment_order
end

#fulfillment_order_itemsArray[FulfillmentOrderItem]

TODO: Write general description for this method

Returns:



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

def fulfillment_order_items
  @fulfillment_order_items
end

#fulfillment_shipmentsArray[FulfillmentShipment]

TODO: Write general description for this method

Returns:



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

def fulfillment_shipments
  @fulfillment_shipments
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/walmart_ap_is/models/payload.rb', line 59

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fulfillment_order = FulfillmentOrder.from_hash(hash['fulfillmentOrder']) if
    hash['fulfillmentOrder']
  # Parameter is an array, so we need to iterate through it
  fulfillment_order_items = nil
  unless hash['fulfillmentOrderItems'].nil?
    fulfillment_order_items = []
    hash['fulfillmentOrderItems'].each do |structure|
      fulfillment_order_items << (FulfillmentOrderItem.from_hash(structure) if structure)
    end
  end

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

  fulfillment_shipments = SKIP unless hash.key?('fulfillmentShipments')

  # 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.
  Payload.new(fulfillment_order: fulfillment_order,
              fulfillment_order_items: fulfillment_order_items,
              fulfillment_shipments: fulfillment_shipments,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['fulfillment_order'] = 'fulfillmentOrder'
  @_hash['fulfillment_order_items'] = 'fulfillmentOrderItems'
  @_hash['fulfillment_shipments'] = 'fulfillmentShipments'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/walmart_ap_is/models/payload.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/walmart_ap_is/models/payload.rb', line 34

def self.optionals
  %w[
    fulfillment_order
    fulfillment_order_items
    fulfillment_shipments
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



109
110
111
112
113
114
# File 'lib/walmart_ap_is/models/payload.rb', line 109

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

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
106
# File 'lib/walmart_ap_is/models/payload.rb', line 101

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