Class: WalmartApIs::BuyBoxPriceType

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

Overview

Schema for an individual Buy Box price.

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(condition:, landed_price:, listing_price:, shipping:, offer_type: SKIP, quantity_tier: SKIP, quantity_discount_type: SKIP, seller_id: SKIP, additional_properties: nil) ⇒ BuyBoxPriceType

Returns a new instance of BuyBoxPriceType.



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

def initialize(condition:, landed_price:, listing_price:, shipping:,
               offer_type: SKIP, quantity_tier: SKIP,
               quantity_discount_type: SKIP, seller_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @condition = condition
  @offer_type = offer_type unless offer_type == SKIP
  @quantity_tier = quantity_tier unless quantity_tier == SKIP
  @quantity_discount_type = quantity_discount_type unless quantity_discount_type == SKIP
  @landed_price = landed_price
  @listing_price = listing_price
  @shipping = shipping
  @seller_id = seller_id unless seller_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#conditionString

Indicates the condition of the item. For example: New, Used, Collectible, Refurbished, or Club.

Returns:

  • (String)


15
16
17
# File 'lib/walmart_ap_is/models/buy_box_price_type.rb', line 15

def condition
  @condition
end

#landed_priceMoneyType

Currency type and monetary value.

Returns:



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

def landed_price
  @landed_price
end

#listing_priceMoneyType

Currency type and monetary value.

Returns:



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

def listing_price
  @listing_price
end

#offer_typeOfferType

Indicates whether the offer is a B2B or B2C offer.

Returns:



19
20
21
# File 'lib/walmart_ap_is/models/buy_box_price_type.rb', line 19

def offer_type
  @offer_type
end

#quantity_discount_typeQuantityDiscountType

Indicates the type of quantity discount this price applies to.



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

def quantity_discount_type
  @quantity_discount_type
end

#quantity_tierInteger

Indicates at what quantity this price becomes active.

Returns:

  • (Integer)


23
24
25
# File 'lib/walmart_ap_is/models/buy_box_price_type.rb', line 23

def quantity_tier
  @quantity_tier
end

#seller_idString

The seller identifier for the offer.

Returns:

  • (String)


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

def seller_id
  @seller_id
end

#shippingMoneyType

Currency type and monetary value.

Returns:



39
40
41
# File 'lib/walmart_ap_is/models/buy_box_price_type.rb', line 39

def shipping
  @shipping
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  condition = hash.key?('condition') ? hash['condition'] : nil
  landed_price = MoneyType.from_hash(hash['LandedPrice']) if hash['LandedPrice']
  listing_price = MoneyType.from_hash(hash['ListingPrice']) if hash['ListingPrice']
  shipping = MoneyType.from_hash(hash['Shipping']) if hash['Shipping']
  offer_type = hash.key?('offerType') ? hash['offerType'] : SKIP
  quantity_tier = hash.key?('quantityTier') ? hash['quantityTier'] : SKIP
  quantity_discount_type =
    hash.key?('quantityDiscountType') ? hash['quantityDiscountType'] : SKIP
  seller_id = hash.key?('sellerId') ? hash['sellerId'] : 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.
  BuyBoxPriceType.new(condition: condition,
                      landed_price: landed_price,
                      listing_price: listing_price,
                      shipping: shipping,
                      offer_type: offer_type,
                      quantity_tier: quantity_tier,
                      quantity_discount_type: quantity_discount_type,
                      seller_id: seller_id,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['condition'] = 'condition'
  @_hash['offer_type'] = 'offerType'
  @_hash['quantity_tier'] = 'quantityTier'
  @_hash['quantity_discount_type'] = 'quantityDiscountType'
  @_hash['landed_price'] = 'LandedPrice'
  @_hash['listing_price'] = 'ListingPrice'
  @_hash['shipping'] = 'Shipping'
  @_hash['seller_id'] = 'sellerId'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    offer_type
    quantity_tier
    quantity_discount_type
    seller_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



136
137
138
139
140
141
142
143
# File 'lib/walmart_ap_is/models/buy_box_price_type.rb', line 136

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} condition: #{@condition.inspect}, offer_type: #{@offer_type.inspect},"\
  " quantity_tier: #{@quantity_tier.inspect}, quantity_discount_type:"\
  " #{@quantity_discount_type.inspect}, landed_price: #{@landed_price.inspect}, listing_price:"\
  " #{@listing_price.inspect}, shipping: #{@shipping.inspect}, seller_id:"\
  " #{@seller_id.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



127
128
129
130
131
132
133
# File 'lib/walmart_ap_is/models/buy_box_price_type.rb', line 127

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} condition: #{@condition}, offer_type: #{@offer_type}, quantity_tier:"\
  " #{@quantity_tier}, quantity_discount_type: #{@quantity_discount_type}, landed_price:"\
  " #{@landed_price}, listing_price: #{@listing_price}, shipping: #{@shipping}, seller_id:"\
  " #{@seller_id}, additional_properties: #{@additional_properties}>"
end