Class: WalmartApIs::OfferDetail

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

Overview

Schema for an individual offer detail.

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(sub_condition:, shipping_time:, listing_price:, shipping:, is_fulfilled_by_wfs:, my_offer: SKIP, offer_type: SKIP, seller_id: SKIP, condition_notes: SKIP, seller_feedback_rating: SKIP, quantity_discount_prices: SKIP, ships_from: SKIP, wfs_prime_details: SKIP, is_buy_box_winner: SKIP, is_featured_merchant: SKIP, additional_properties: nil) ⇒ OfferDetail

Returns a new instance of OfferDetail.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 118

def initialize(sub_condition:, shipping_time:, listing_price:, shipping:,
               is_fulfilled_by_wfs:, my_offer: SKIP, offer_type: SKIP,
               seller_id: SKIP, condition_notes: SKIP,
               seller_feedback_rating: SKIP, quantity_discount_prices: SKIP,
               ships_from: SKIP, wfs_prime_details: SKIP,
               is_buy_box_winner: SKIP, is_featured_merchant: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @my_offer = my_offer unless my_offer == SKIP
  @offer_type = offer_type unless offer_type == SKIP
  @sub_condition = sub_condition
  @seller_id = seller_id unless seller_id == SKIP
  @condition_notes = condition_notes unless condition_notes == SKIP
  @seller_feedback_rating = seller_feedback_rating unless seller_feedback_rating == SKIP
  @shipping_time = shipping_time
  @listing_price = listing_price
  @quantity_discount_prices = quantity_discount_prices unless quantity_discount_prices == SKIP
  @shipping = shipping
  @ships_from = ships_from unless ships_from == SKIP
  @is_fulfilled_by_wfs = is_fulfilled_by_wfs
  @wfs_prime_details = wfs_prime_details unless wfs_prime_details == SKIP
  @is_buy_box_winner = is_buy_box_winner unless is_buy_box_winner == SKIP
  @is_featured_merchant = is_featured_merchant unless is_featured_merchant == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#condition_notesString

Information about the condition of the item.

Returns:

  • (String)


32
33
34
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 32

def condition_notes
  @condition_notes
end

#is_buy_box_winnerTrueClass | FalseClass

When true, the offer is currently in the Buy Box.

Returns:

  • (TrueClass | FalseClass)


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

def is_buy_box_winner
  @is_buy_box_winner
end

When true, the seller of the item is eligible to win the Buy Box.

Returns:

  • (TrueClass | FalseClass)


74
75
76
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 74

def is_featured_merchant
  @is_featured_merchant
end

#is_fulfilled_by_wfsTrueClass | FalseClass

When true, the offer is fulfilled by Walmart Fulfillment Services (WFS).

Returns:

  • (TrueClass | FalseClass)


62
63
64
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 62

def is_fulfilled_by_wfs
  @is_fulfilled_by_wfs
end

#listing_priceMoneyType

Currency type and monetary value.

Returns:



46
47
48
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 46

def listing_price
  @listing_price
end

#my_offerTrueClass | FalseClass

When true, this is the seller's offer.

Returns:

  • (TrueClass | FalseClass)


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

def my_offer
  @my_offer
end

#offer_typeOfferType

Indicates whether the offer is a B2B or B2C offer.

Returns:



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

def offer_type
  @offer_type
end

#quantity_discount_pricesArray[QuantityDiscountPriceType]

Item pricing information when buying in bulk.

Returns:



50
51
52
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 50

def quantity_discount_prices
  @quantity_discount_prices
end

#seller_feedback_ratingSellerFeedbackType

Information about the seller's feedback, including the percentage of positive feedback and total ratings.

Returns:



37
38
39
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 37

def seller_feedback_rating
  @seller_feedback_rating
end

#seller_idString

The seller identifier for the offer.

Returns:

  • (String)


28
29
30
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 28

def seller_id
  @seller_id
end

#shippingMoneyType

Currency type and monetary value.

Returns:



54
55
56
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 54

def shipping
  @shipping
end

#shipping_timeDetailedShippingTimeType

The time range in which an item will likely be shipped once an order has been placed.



42
43
44
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 42

def shipping_time
  @shipping_time
end

#ships_fromShipsFromType

The state and country from where the item is shipped.

Returns:



58
59
60
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 58

def ships_from
  @ships_from
end

#sub_conditionString

The subcondition of the item. Subcondition values: New, Mint, Very Good, Good, Acceptable, Poor, Club, OEM, Warranty, Refurbished Warranty, Refurbished, Open Box, or Other.

Returns:

  • (String)


24
25
26
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 24

def sub_condition
  @sub_condition
end

#wfs_prime_detailsWfsPrimeDetailsType

Walmart Fulfillment Services prime eligibility information.

Returns:



66
67
68
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 66

def wfs_prime_details
  @wfs_prime_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 147

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  sub_condition = hash.key?('SubCondition') ? hash['SubCondition'] : nil
  shipping_time = DetailedShippingTimeType.from_hash(hash['ShippingTime']) if
    hash['ShippingTime']
  listing_price = MoneyType.from_hash(hash['ListingPrice']) if hash['ListingPrice']
  shipping = MoneyType.from_hash(hash['Shipping']) if hash['Shipping']
  is_fulfilled_by_wfs =
    hash.key?('IsFulfilledByWFS') ? hash['IsFulfilledByWFS'] : nil
  my_offer = hash.key?('MyOffer') ? hash['MyOffer'] : SKIP
  offer_type = hash.key?('offerType') ? hash['offerType'] : SKIP
  seller_id = hash.key?('SellerId') ? hash['SellerId'] : SKIP
  condition_notes =
    hash.key?('ConditionNotes') ? hash['ConditionNotes'] : SKIP
  seller_feedback_rating = SellerFeedbackType.from_hash(hash['SellerFeedbackRating']) if
    hash['SellerFeedbackRating']
  # Parameter is an array, so we need to iterate through it
  quantity_discount_prices = nil
  unless hash['quantityDiscountPrices'].nil?
    quantity_discount_prices = []
    hash['quantityDiscountPrices'].each do |structure|
      quantity_discount_prices << (QuantityDiscountPriceType.from_hash(structure) if structure)
    end
  end

  quantity_discount_prices = SKIP unless hash.key?('quantityDiscountPrices')
  ships_from = ShipsFromType.from_hash(hash['ShipsFrom']) if hash['ShipsFrom']
  wfs_prime_details = WfsPrimeDetailsType.from_hash(hash['WFSPrimeDetails']) if
    hash['WFSPrimeDetails']
  is_buy_box_winner =
    hash.key?('IsBuyBoxWinner') ? hash['IsBuyBoxWinner'] : SKIP
  is_featured_merchant =
    hash.key?('IsFeaturedMerchant') ? hash['IsFeaturedMerchant'] : 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.
  OfferDetail.new(sub_condition: sub_condition,
                  shipping_time: shipping_time,
                  listing_price: listing_price,
                  shipping: shipping,
                  is_fulfilled_by_wfs: is_fulfilled_by_wfs,
                  my_offer: my_offer,
                  offer_type: offer_type,
                  seller_id: seller_id,
                  condition_notes: condition_notes,
                  seller_feedback_rating: seller_feedback_rating,
                  quantity_discount_prices: quantity_discount_prices,
                  ships_from: ships_from,
                  wfs_prime_details: wfs_prime_details,
                  is_buy_box_winner: is_buy_box_winner,
                  is_featured_merchant: is_featured_merchant,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 77

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['my_offer'] = 'MyOffer'
  @_hash['offer_type'] = 'offerType'
  @_hash['sub_condition'] = 'SubCondition'
  @_hash['seller_id'] = 'SellerId'
  @_hash['condition_notes'] = 'ConditionNotes'
  @_hash['seller_feedback_rating'] = 'SellerFeedbackRating'
  @_hash['shipping_time'] = 'ShippingTime'
  @_hash['listing_price'] = 'ListingPrice'
  @_hash['quantity_discount_prices'] = 'quantityDiscountPrices'
  @_hash['shipping'] = 'Shipping'
  @_hash['ships_from'] = 'ShipsFrom'
  @_hash['is_fulfilled_by_wfs'] = 'IsFulfilledByWFS'
  @_hash['wfs_prime_details'] = 'WFSPrimeDetails'
  @_hash['is_buy_box_winner'] = 'IsBuyBoxWinner'
  @_hash['is_featured_merchant'] = 'IsFeaturedMerchant'
  @_hash
end

.nullablesObject

An array for nullable fields



114
115
116
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 114

def self.nullables
  []
end

.optionalsObject

An array for optional fields



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 98

def self.optionals
  %w[
    my_offer
    offer_type
    seller_id
    condition_notes
    seller_feedback_rating
    quantity_discount_prices
    ships_from
    wfs_prime_details
    is_buy_box_winner
    is_featured_merchant
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 223

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} my_offer: #{@my_offer.inspect}, offer_type: #{@offer_type.inspect},"\
  " sub_condition: #{@sub_condition.inspect}, seller_id: #{@seller_id.inspect},"\
  " condition_notes: #{@condition_notes.inspect}, seller_feedback_rating:"\
  " #{@seller_feedback_rating.inspect}, shipping_time: #{@shipping_time.inspect},"\
  " listing_price: #{@listing_price.inspect}, quantity_discount_prices:"\
  " #{@quantity_discount_prices.inspect}, shipping: #{@shipping.inspect}, ships_from:"\
  " #{@ships_from.inspect}, is_fulfilled_by_wfs: #{@is_fulfilled_by_wfs.inspect},"\
  " wfs_prime_details: #{@wfs_prime_details.inspect}, is_buy_box_winner:"\
  " #{@is_buy_box_winner.inspect}, is_featured_merchant: #{@is_featured_merchant.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



210
211
212
213
214
215
216
217
218
219
220
# File 'lib/walmart_ap_is/models/offer_detail.rb', line 210

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} my_offer: #{@my_offer}, offer_type: #{@offer_type}, sub_condition:"\
  " #{@sub_condition}, seller_id: #{@seller_id}, condition_notes: #{@condition_notes},"\
  " seller_feedback_rating: #{@seller_feedback_rating}, shipping_time: #{@shipping_time},"\
  " listing_price: #{@listing_price}, quantity_discount_prices: #{@quantity_discount_prices},"\
  " shipping: #{@shipping}, ships_from: #{@ships_from}, is_fulfilled_by_wfs:"\
  " #{@is_fulfilled_by_wfs}, wfs_prime_details: #{@wfs_prime_details}, is_buy_box_winner:"\
  " #{@is_buy_box_winner}, is_featured_merchant: #{@is_featured_merchant},"\
  " additional_properties: #{@additional_properties}>"
end