Class: WalmartApIs::GetOffersResult

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

Overview

The payload for the getListingOffers and getItemOffers operations.

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(marketplace_id:, item_condition:, status:, identifier:, summary:, offers:, walmart_item_id: SKIP, sku: SKIP, additional_properties: nil) ⇒ GetOffersResult

Returns a new instance of GetOffersResult.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 74

def initialize(marketplace_id:, item_condition:, status:, identifier:,
               summary:, offers:, walmart_item_id: SKIP, sku: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @marketplace_id = marketplace_id
  @walmart_item_id = walmart_item_id unless walmart_item_id == SKIP
  @sku = sku unless sku == SKIP
  @item_condition = item_condition
  @status = status
  @identifier = identifier
  @summary = summary
  @offers = offers
  @additional_properties = additional_properties
end

Instance Attribute Details

#identifierItemIdentifier1

Information that identifies an item.

Returns:



35
36
37
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 35

def identifier
  @identifier
end

#item_conditionConditionType2

Indicates the condition of the item. Possible values: New, Used, Collectible, Refurbished, Club.

Returns:



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

def item_condition
  @item_condition
end

#marketplace_idString

A marketplace identifier.

Returns:

  • (String)


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

def marketplace_id
  @marketplace_id
end

#offersArray[OfferDetail]

A list of offer details. The list is the same length as TotalOfferCount in the Summary or 20, whichever is less.

Returns:



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

def offers
  @offers
end

#skuString

The stock keeping unit (SKU) of the item.

Returns:

  • (String)


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

def sku
  @sku
end

#statusString

The status of the operation.

Returns:

  • (String)


31
32
33
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 31

def status
  @status
end

#summarySummary

Contains price information about the product, including LowestPrices, BuyBoxPrices, and NumberOfOffers.

Returns:



40
41
42
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 40

def summary
  @summary
end

#walmart_item_idString

The Walmart Item ID of the item.

Returns:

  • (String)


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

def walmart_item_id
  @walmart_item_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 92

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  marketplace_id = hash.key?('marketplaceId') ? hash['marketplaceId'] : nil
  item_condition = hash.key?('ItemCondition') ? hash['ItemCondition'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  identifier = ItemIdentifier1.from_hash(hash['Identifier']) if hash['Identifier']
  summary = Summary.from_hash(hash['Summary']) if hash['Summary']
  # Parameter is an array, so we need to iterate through it
  offers = nil
  unless hash['Offers'].nil?
    offers = []
    hash['Offers'].each do |structure|
      offers << (OfferDetail.from_hash(structure) if structure)
    end
  end

  offers = nil unless hash.key?('Offers')
  walmart_item_id =
    hash.key?('walmartItemId') ? hash['walmartItemId'] : SKIP
  sku = hash.key?('SKU') ? hash['SKU'] : 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.
  GetOffersResult.new(marketplace_id: marketplace_id,
                      item_condition: item_condition,
                      status: status,
                      identifier: identifier,
                      summary: summary,
                      offers: offers,
                      walmart_item_id: walmart_item_id,
                      sku: sku,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['marketplace_id'] = 'marketplaceId'
  @_hash['walmart_item_id'] = 'walmartItemId'
  @_hash['sku'] = 'SKU'
  @_hash['item_condition'] = 'ItemCondition'
  @_hash['status'] = 'status'
  @_hash['identifier'] = 'Identifier'
  @_hash['summary'] = 'Summary'
  @_hash['offers'] = 'Offers'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



62
63
64
65
66
67
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 62

def self.optionals
  %w[
    walmart_item_id
    sku
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



144
145
146
147
148
149
150
151
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 144

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} marketplace_id: #{@marketplace_id.inspect}, walmart_item_id:"\
  " #{@walmart_item_id.inspect}, sku: #{@sku.inspect}, item_condition:"\
  " #{@item_condition.inspect}, status: #{@status.inspect}, identifier:"\
  " #{@identifier.inspect}, summary: #{@summary.inspect}, offers: #{@offers.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



135
136
137
138
139
140
141
# File 'lib/walmart_ap_is/models/get_offers_result.rb', line 135

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} marketplace_id: #{@marketplace_id}, walmart_item_id: #{@walmart_item_id},"\
  " sku: #{@sku}, item_condition: #{@item_condition}, status: #{@status}, identifier:"\
  " #{@identifier}, summary: #{@summary}, offers: #{@offers}, additional_properties:"\
  " #{@additional_properties}>"
end