Class: WalmartApIs::OfferType1

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

Overview

Schema for an individual offer.

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(buying_price:, regular_price:, fulfillment_channel:, item_condition:, item_sub_condition:, seller_sku:, offer_type: SKIP, business_price: SKIP, quantity_discount_prices: SKIP, additional_properties: nil) ⇒ OfferType1

Returns a new instance of OfferType1.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 81

def initialize(buying_price:, regular_price:, fulfillment_channel:,
               item_condition:, item_sub_condition:, seller_sku:,
               offer_type: SKIP, business_price: SKIP,
               quantity_discount_prices: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @offer_type = offer_type unless offer_type == SKIP
  @buying_price = buying_price
  @regular_price = regular_price
  @business_price = business_price unless business_price == SKIP
  @quantity_discount_prices = quantity_discount_prices unless quantity_discount_prices == SKIP
  @fulfillment_channel = fulfillment_channel
  @item_condition = item_condition
  @item_sub_condition = item_sub_condition
  @seller_sku = seller_sku
  @additional_properties = additional_properties
end

Instance Attribute Details

#business_priceMoneyType

Currency type and monetary value.

Returns:



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

def business_price
  @business_price
end

#buying_pricePriceType

Item price information. LandedPrice = ListingPrice + Shipping. Walmart does not have a seller-configurable per-offer loyalty points mechanism; the Points field from the SP-API reference spec is omitted. See ADR-030.

Returns:



20
21
22
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 20

def buying_price
  @buying_price
end

#fulfillment_channelFulfillmentChannel

The fulfillment channel for the offer listing. Possible values: WFS, SELLER.

Returns:



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

def fulfillment_channel
  @fulfillment_channel
end

#item_conditionString

The item condition for the offer listing. Possible values: New, Used, Collectible, Refurbished, or Club.

Returns:

  • (String)


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

def item_condition
  @item_condition
end

#item_sub_conditionString

The item subcondition for the offer listing.

Returns:

  • (String)


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

def item_sub_condition
  @item_sub_condition
end

#offer_typeOfferType

Indicates whether the offer is a B2B or B2C offer.

Returns:



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

def offer_type
  @offer_type
end

#quantity_discount_pricesArray[QuantityDiscountPriceType]

Item pricing information when buying in bulk.

Returns:



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

def quantity_discount_prices
  @quantity_discount_prices
end

#regular_priceMoneyType

Currency type and monetary value.

Returns:



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

def regular_price
  @regular_price
end

#seller_skuString

The seller stock keeping unit (SKU) of the item.

Returns:

  • (String)


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

def seller_sku
  @seller_sku
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 101

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  buying_price = PriceType.from_hash(hash['BuyingPrice']) if hash['BuyingPrice']
  regular_price = MoneyType.from_hash(hash['RegularPrice']) if hash['RegularPrice']
  fulfillment_channel =
    hash.key?('FulfillmentChannel') ? hash['FulfillmentChannel'] : nil
  item_condition = hash.key?('ItemCondition') ? hash['ItemCondition'] : nil
  item_sub_condition =
    hash.key?('ItemSubCondition') ? hash['ItemSubCondition'] : nil
  seller_sku = hash.key?('SellerSKU') ? hash['SellerSKU'] : nil
  offer_type = hash.key?('offerType') ? hash['offerType'] : SKIP
  business_price = MoneyType.from_hash(hash['businessPrice']) if hash['businessPrice']
  # 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')

  # 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.
  OfferType1.new(buying_price: buying_price,
                 regular_price: regular_price,
                 fulfillment_channel: fulfillment_channel,
                 item_condition: item_condition,
                 item_sub_condition: item_sub_condition,
                 seller_sku: seller_sku,
                 offer_type: offer_type,
                 business_price: business_price,
                 quantity_discount_prices: quantity_discount_prices,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['offer_type'] = 'offerType'
  @_hash['buying_price'] = 'BuyingPrice'
  @_hash['regular_price'] = 'RegularPrice'
  @_hash['business_price'] = 'businessPrice'
  @_hash['quantity_discount_prices'] = 'quantityDiscountPrices'
  @_hash['fulfillment_channel'] = 'FulfillmentChannel'
  @_hash['item_condition'] = 'ItemCondition'
  @_hash['item_sub_condition'] = 'ItemSubCondition'
  @_hash['seller_sku'] = 'SellerSKU'
  @_hash
end

.nullablesObject

An array for nullable fields



77
78
79
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 77

def self.nullables
  []
end

.optionalsObject

An array for optional fields



68
69
70
71
72
73
74
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 68

def self.optionals
  %w[
    offer_type
    business_price
    quantity_discount_prices
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



157
158
159
160
161
162
163
164
165
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 157

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} offer_type: #{@offer_type.inspect}, buying_price: #{@buying_price.inspect},"\
  " regular_price: #{@regular_price.inspect}, business_price: #{@business_price.inspect},"\
  " quantity_discount_prices: #{@quantity_discount_prices.inspect}, fulfillment_channel:"\
  " #{@fulfillment_channel.inspect}, item_condition: #{@item_condition.inspect},"\
  " item_sub_condition: #{@item_sub_condition.inspect}, seller_sku: #{@seller_sku.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



147
148
149
150
151
152
153
154
# File 'lib/walmart_ap_is/models/offer_type1.rb', line 147

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} offer_type: #{@offer_type}, buying_price: #{@buying_price}, regular_price:"\
  " #{@regular_price}, business_price: #{@business_price}, quantity_discount_prices:"\
  " #{@quantity_discount_prices}, fulfillment_channel: #{@fulfillment_channel},"\
  " item_condition: #{@item_condition}, item_sub_condition: #{@item_sub_condition},"\
  " seller_sku: #{@seller_sku}, additional_properties: #{@additional_properties}>"
end