Class: WalmartApIs::LowestPriceType

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

Overview

Schema for an individual lowest 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:, fulfillment_channel:, listing_price:, offer_type: SKIP, quantity_tier: SKIP, quantity_discount_type: SKIP, landed_price: SKIP, shipping: SKIP, additional_properties: nil) ⇒ LowestPriceType

Returns a new instance of LowestPriceType.



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

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

  @condition = condition
  @fulfillment_channel = fulfillment_channel
  @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 unless landed_price == SKIP
  @listing_price = listing_price
  @shipping = shipping unless shipping == 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/lowest_price_type.rb', line 15

def condition
  @condition
end

#fulfillment_channelFulfillmentChannel1

Indicates whether the item is fulfilled by WFS or the seller.

Returns:



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

def fulfillment_channel
  @fulfillment_channel
end

#landed_priceMoneyType

Currency type and monetary value.

Returns:



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

def landed_price
  @landed_price
end

#listing_priceMoneyType

Currency type and monetary value.

Returns:



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

def listing_price
  @listing_price
end

#offer_typeOfferType

Indicates whether the offer is a B2B or B2C offer.

Returns:



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

def offer_type
  @offer_type
end

#quantity_discount_typeQuantityDiscountType

Indicates the type of quantity discount this price applies to.



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

def quantity_discount_type
  @quantity_discount_type
end

#quantity_tierInteger

Indicates at what quantity this price becomes active.

Returns:

  • (Integer)


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

def quantity_tier
  @quantity_tier
end

#shippingMoneyType

Currency type and monetary value.

Returns:



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

def shipping
  @shipping
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  condition = hash.key?('condition') ? hash['condition'] : nil
  fulfillment_channel =
    hash.key?('fulfillmentChannel') ? hash['fulfillmentChannel'] : nil
  listing_price = MoneyType.from_hash(hash['ListingPrice']) if hash['ListingPrice']
  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
  landed_price = MoneyType.from_hash(hash['LandedPrice']) if hash['LandedPrice']
  shipping = MoneyType.from_hash(hash['Shipping']) if hash['Shipping']

  # 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.
  LowestPriceType.new(condition: condition,
                      fulfillment_channel: fulfillment_channel,
                      listing_price: listing_price,
                      offer_type: offer_type,
                      quantity_tier: quantity_tier,
                      quantity_discount_type: quantity_discount_type,
                      landed_price: landed_price,
                      shipping: shipping,
                      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/lowest_price_type.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['condition'] = 'condition'
  @_hash['fulfillment_channel'] = 'fulfillmentChannel'
  @_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
end

.nullablesObject

An array for nullable fields



71
72
73
# File 'lib/walmart_ap_is/models/lowest_price_type.rb', line 71

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



139
140
141
142
143
144
145
146
# File 'lib/walmart_ap_is/models/lowest_price_type.rb', line 139

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} condition: #{@condition.inspect}, fulfillment_channel:"\
  " #{@fulfillment_channel.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}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



129
130
131
132
133
134
135
136
# File 'lib/walmart_ap_is/models/lowest_price_type.rb', line 129

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