Class: WalmartApIs::ChannelDetails

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

Overview

ChannelDetails 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(channel_type:, marketplace_order_details: SKIP, marketplace_shipment_details: SKIP, additional_properties: nil) ⇒ ChannelDetails

Returns a new instance of ChannelDetails.



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

def initialize(channel_type:, marketplace_order_details: SKIP,
               marketplace_shipment_details: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @channel_type = channel_type
  unless marketplace_order_details == SKIP
    @marketplace_order_details =
      marketplace_order_details
  end
  unless marketplace_shipment_details == SKIP
    @marketplace_shipment_details =
      marketplace_shipment_details
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#channel_typeChannelType

Sales-channel hint that lets shipping-v4 route differently for WFS-fulfilled orders, marketplace-seller-fulfilled orders, and external (off-Walmart) orders.

Returns:



16
17
18
# File 'lib/walmart_ap_is/models/channel_details.rb', line 16

def channel_type
  @channel_type
end

#marketplace_order_detailsMarketplaceOrderDetails

Marketplace-side order context for orders originating on the Walmart Marketplace surface. Equivalent in shape to industry SP-API's order-details block; renamed to be vendor-neutral.



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

def marketplace_order_details
  @marketplace_order_details
end

#marketplace_shipment_detailsMarketplaceShipmentDetails

Marketplace-side shipment context. Renamed from the industry SP-API "vendor-shipment-details" block to be vendor-neutral.



27
28
29
# File 'lib/walmart_ap_is/models/channel_details.rb', line 27

def marketplace_shipment_details
  @marketplace_shipment_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/walmart_ap_is/models/channel_details.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  channel_type = hash.key?('channelType') ? hash['channelType'] : nil
  if hash['marketplaceOrderDetails']
    marketplace_order_details = MarketplaceOrderDetails.from_hash(hash['marketplaceOrderDetails'])
  end
  if hash['marketplaceShipmentDetails']
    marketplace_shipment_details = MarketplaceShipmentDetails.from_hash(hash['marketplaceShipmentDetails'])
  end

  # 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.
  ChannelDetails.new(channel_type: channel_type,
                     marketplace_order_details: marketplace_order_details,
                     marketplace_shipment_details: marketplace_shipment_details,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
# File 'lib/walmart_ap_is/models/channel_details.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['channel_type'] = 'channelType'
  @_hash['marketplace_order_details'] = 'marketplaceOrderDetails'
  @_hash['marketplace_shipment_details'] = 'marketplaceShipmentDetails'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/walmart_ap_is/models/channel_details.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
# File 'lib/walmart_ap_is/models/channel_details.rb', line 39

def self.optionals
  %w[
    marketplace_order_details
    marketplace_shipment_details
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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

#to_sObject

Provides a human-readable string representation of the object.



97
98
99
100
101
102
# File 'lib/walmart_ap_is/models/channel_details.rb', line 97

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