Class: WalmartApIs::Summary
- Defined in:
- lib/walmart_ap_is/models/summary.rb
Overview
Contains price information about the product, including LowestPrices, BuyBoxPrices, and NumberOfOffers.
Instance Attribute Summary collapse
-
#buy_box_eligible_offers ⇒ Array[OfferCountType]
A list of the total number of offers eligible for the Buy Box, by condition and fulfillment channel.
-
#buy_box_prices ⇒ Array[BuyBoxPriceType]
A list of the Buy Box prices.
-
#competitive_price_threshold ⇒ MoneyType
Currency type and monetary value.
-
#list_price ⇒ MoneyType
Currency type and monetary value.
-
#lowest_prices ⇒ Array[LowestPriceType]
A list of the lowest prices.
-
#number_of_offers ⇒ Array[OfferCountType]
A list of the total number of offers, by condition and fulfillment channel.
-
#offers_available_time ⇒ DateTime
When the status is ActiveButTooSoonForProcessing, the time when offers will be available for processing.
-
#sales_rankings ⇒ Array[SalesRankType]
A list of sales rank information for the item, by category.
-
#suggested_lower_price_plus_shipping ⇒ MoneyType
Currency type and monetary value.
-
#total_offer_count ⇒ Integer
The number of unique offers contained in NumberOfOffers.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(total_offer_count:, number_of_offers: SKIP, lowest_prices: SKIP, buy_box_prices: SKIP, list_price: SKIP, competitive_price_threshold: SKIP, suggested_lower_price_plus_shipping: SKIP, sales_rankings: SKIP, buy_box_eligible_offers: SKIP, offers_available_time: SKIP, additional_properties: nil) ⇒ Summary
constructor
A new instance of Summary.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_offers_available_time ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(total_offer_count:, number_of_offers: SKIP, lowest_prices: SKIP, buy_box_prices: SKIP, list_price: SKIP, competitive_price_threshold: SKIP, suggested_lower_price_plus_shipping: SKIP, sales_rankings: SKIP, buy_box_eligible_offers: SKIP, offers_available_time: SKIP, additional_properties: nil) ⇒ Summary
Returns a new instance of Summary.
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 |
# File 'lib/walmart_ap_is/models/summary.rb', line 94 def initialize(total_offer_count:, number_of_offers: SKIP, lowest_prices: SKIP, buy_box_prices: SKIP, list_price: SKIP, competitive_price_threshold: SKIP, suggested_lower_price_plus_shipping: SKIP, sales_rankings: SKIP, buy_box_eligible_offers: SKIP, offers_available_time: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @total_offer_count = total_offer_count @number_of_offers = number_of_offers unless number_of_offers == SKIP @lowest_prices = lowest_prices unless lowest_prices == SKIP @buy_box_prices = buy_box_prices unless buy_box_prices == SKIP @list_price = list_price unless list_price == SKIP unless competitive_price_threshold == SKIP @competitive_price_threshold = competitive_price_threshold end unless suggested_lower_price_plus_shipping == SKIP @suggested_lower_price_plus_shipping = suggested_lower_price_plus_shipping end @sales_rankings = sales_rankings unless sales_rankings == SKIP @buy_box_eligible_offers = buy_box_eligible_offers unless buy_box_eligible_offers == SKIP @offers_available_time = offers_available_time unless offers_available_time == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#buy_box_eligible_offers ⇒ Array[OfferCountType]
A list of the total number of offers eligible for the Buy Box, by condition and fulfillment channel.
50 51 52 |
# File 'lib/walmart_ap_is/models/summary.rb', line 50 def buy_box_eligible_offers @buy_box_eligible_offers end |
#buy_box_prices ⇒ Array[BuyBoxPriceType]
A list of the Buy Box prices.
29 30 31 |
# File 'lib/walmart_ap_is/models/summary.rb', line 29 def buy_box_prices @buy_box_prices end |
#competitive_price_threshold ⇒ MoneyType
Currency type and monetary value.
37 38 39 |
# File 'lib/walmart_ap_is/models/summary.rb', line 37 def competitive_price_threshold @competitive_price_threshold end |
#list_price ⇒ MoneyType
Currency type and monetary value.
33 34 35 |
# File 'lib/walmart_ap_is/models/summary.rb', line 33 def list_price @list_price end |
#lowest_prices ⇒ Array[LowestPriceType]
A list of the lowest prices.
25 26 27 |
# File 'lib/walmart_ap_is/models/summary.rb', line 25 def lowest_prices @lowest_prices end |
#number_of_offers ⇒ Array[OfferCountType]
A list of the total number of offers, by condition and fulfillment channel.
21 22 23 |
# File 'lib/walmart_ap_is/models/summary.rb', line 21 def number_of_offers @number_of_offers end |
#offers_available_time ⇒ DateTime
When the status is ActiveButTooSoonForProcessing, the time when offers will be available for processing.
55 56 57 |
# File 'lib/walmart_ap_is/models/summary.rb', line 55 def offers_available_time @offers_available_time end |
#sales_rankings ⇒ Array[SalesRankType]
A list of sales rank information for the item, by category.
45 46 47 |
# File 'lib/walmart_ap_is/models/summary.rb', line 45 def sales_rankings @sales_rankings end |
#suggested_lower_price_plus_shipping ⇒ MoneyType
Currency type and monetary value.
41 42 43 |
# File 'lib/walmart_ap_is/models/summary.rb', line 41 def suggested_lower_price_plus_shipping @suggested_lower_price_plus_shipping end |
#total_offer_count ⇒ Integer
The number of unique offers contained in NumberOfOffers.
16 17 18 |
# File 'lib/walmart_ap_is/models/summary.rb', line 16 def total_offer_count @total_offer_count end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 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 208 209 210 |
# File 'lib/walmart_ap_is/models/summary.rb', line 123 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. total_offer_count = hash.key?('TotalOfferCount') ? hash['TotalOfferCount'] : nil # Parameter is an array, so we need to iterate through it number_of_offers = nil unless hash['NumberOfOffers'].nil? number_of_offers = [] hash['NumberOfOffers'].each do |structure| number_of_offers << (OfferCountType.from_hash(structure) if structure) end end number_of_offers = SKIP unless hash.key?('NumberOfOffers') # Parameter is an array, so we need to iterate through it lowest_prices = nil unless hash['LowestPrices'].nil? lowest_prices = [] hash['LowestPrices'].each do |structure| lowest_prices << (LowestPriceType.from_hash(structure) if structure) end end lowest_prices = SKIP unless hash.key?('LowestPrices') # Parameter is an array, so we need to iterate through it buy_box_prices = nil unless hash['BuyBoxPrices'].nil? buy_box_prices = [] hash['BuyBoxPrices'].each do |structure| buy_box_prices << (BuyBoxPriceType.from_hash(structure) if structure) end end buy_box_prices = SKIP unless hash.key?('BuyBoxPrices') list_price = MoneyType.from_hash(hash['ListPrice']) if hash['ListPrice'] competitive_price_threshold = MoneyType.from_hash(hash['CompetitivePriceThreshold']) if hash['CompetitivePriceThreshold'] if hash['SuggestedLowerPricePlusShipping'] suggested_lower_price_plus_shipping = MoneyType.from_hash(hash['SuggestedLowerPricePlusShipping']) end # Parameter is an array, so we need to iterate through it sales_rankings = nil unless hash['SalesRankings'].nil? sales_rankings = [] hash['SalesRankings'].each do |structure| sales_rankings << (SalesRankType.from_hash(structure) if structure) end end sales_rankings = SKIP unless hash.key?('SalesRankings') # Parameter is an array, so we need to iterate through it buy_box_eligible_offers = nil unless hash['BuyBoxEligibleOffers'].nil? buy_box_eligible_offers = [] hash['BuyBoxEligibleOffers'].each do |structure| buy_box_eligible_offers << (OfferCountType.from_hash(structure) if structure) end end buy_box_eligible_offers = SKIP unless hash.key?('BuyBoxEligibleOffers') offers_available_time = if hash.key?('OffersAvailableTime') (DateTimeHelper.from_rfc3339(hash['OffersAvailableTime']) if hash['OffersAvailableTime']) else SKIP end # 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. Summary.new(total_offer_count: total_offer_count, number_of_offers: number_of_offers, lowest_prices: lowest_prices, buy_box_prices: buy_box_prices, list_price: list_price, competitive_price_threshold: competitive_price_threshold, suggested_lower_price_plus_shipping: suggested_lower_price_plus_shipping, sales_rankings: sales_rankings, buy_box_eligible_offers: buy_box_eligible_offers, offers_available_time: offers_available_time, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/walmart_ap_is/models/summary.rb', line 58 def self.names @_hash = {} if @_hash.nil? @_hash['total_offer_count'] = 'TotalOfferCount' @_hash['number_of_offers'] = 'NumberOfOffers' @_hash['lowest_prices'] = 'LowestPrices' @_hash['buy_box_prices'] = 'BuyBoxPrices' @_hash['list_price'] = 'ListPrice' @_hash['competitive_price_threshold'] = 'CompetitivePriceThreshold' @_hash['suggested_lower_price_plus_shipping'] = 'SuggestedLowerPricePlusShipping' @_hash['sales_rankings'] = 'SalesRankings' @_hash['buy_box_eligible_offers'] = 'BuyBoxEligibleOffers' @_hash['offers_available_time'] = 'OffersAvailableTime' @_hash end |
.nullables ⇒ Object
An array for nullable fields
90 91 92 |
# File 'lib/walmart_ap_is/models/summary.rb', line 90 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/walmart_ap_is/models/summary.rb', line 75 def self.optionals %w[ number_of_offers lowest_prices buy_box_prices list_price competitive_price_threshold suggested_lower_price_plus_shipping sales_rankings buy_box_eligible_offers offers_available_time ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/walmart_ap_is/models/summary.rb', line 229 def inspect class_name = self.class.name.split('::').last "<#{class_name} total_offer_count: #{@total_offer_count.inspect}, number_of_offers:"\ " #{@number_of_offers.inspect}, lowest_prices: #{@lowest_prices.inspect}, buy_box_prices:"\ " #{@buy_box_prices.inspect}, list_price: #{@list_price.inspect},"\ " competitive_price_threshold: #{@competitive_price_threshold.inspect},"\ " suggested_lower_price_plus_shipping: #{@suggested_lower_price_plus_shipping.inspect},"\ " sales_rankings: #{@sales_rankings.inspect}, buy_box_eligible_offers:"\ " #{@buy_box_eligible_offers.inspect}, offers_available_time:"\ " #{@offers_available_time.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_offers_available_time ⇒ Object
212 213 214 |
# File 'lib/walmart_ap_is/models/summary.rb', line 212 def to_custom_offers_available_time DateTimeHelper.to_rfc3339(offers_available_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
217 218 219 220 221 222 223 224 225 226 |
# File 'lib/walmart_ap_is/models/summary.rb', line 217 def to_s class_name = self.class.name.split('::').last "<#{class_name} total_offer_count: #{@total_offer_count}, number_of_offers:"\ " #{@number_of_offers}, lowest_prices: #{@lowest_prices}, buy_box_prices:"\ " #{@buy_box_prices}, list_price: #{@list_price}, competitive_price_threshold:"\ " #{@competitive_price_threshold}, suggested_lower_price_plus_shipping:"\ " #{@suggested_lower_price_plus_shipping}, sales_rankings: #{@sales_rankings},"\ " buy_box_eligible_offers: #{@buy_box_eligible_offers}, offers_available_time:"\ " #{@offers_available_time}, additional_properties: #{@additional_properties}>" end |