Class: WalmartApIs::ItemSearchResults
- Defined in:
- lib/walmart_ap_is/models/item_search_results.rb
Overview
ItemSearchResults Model.
Instance Attribute Summary collapse
-
#items ⇒ Array[Item]
Total number of matching catalog items.
-
#number_of_results ⇒ Integer
Total number of matching catalog items.
-
#pagination ⇒ Pagination
Total number of matching catalog items.
-
#refinements ⇒ Refinements
Total number of matching catalog items.
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(number_of_results: SKIP, pagination: SKIP, refinements: SKIP, items: SKIP, additional_properties: nil) ⇒ ItemSearchResults
constructor
A new instance of ItemSearchResults.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(number_of_results: SKIP, pagination: SKIP, refinements: SKIP, items: SKIP, additional_properties: nil) ⇒ ItemSearchResults
Returns a new instance of ItemSearchResults.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 53 def initialize(number_of_results: SKIP, pagination: SKIP, refinements: SKIP, items: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @number_of_results = number_of_results unless number_of_results == SKIP @pagination = pagination unless pagination == SKIP @refinements = refinements unless refinements == SKIP @items = items unless items == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#items ⇒ Array[Item]
Total number of matching catalog items
26 27 28 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 26 def items @items end |
#number_of_results ⇒ Integer
Total number of matching catalog items
14 15 16 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 14 def number_of_results @number_of_results end |
#pagination ⇒ Pagination
Total number of matching catalog items
18 19 20 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 18 def pagination @pagination end |
#refinements ⇒ Refinements
Total number of matching catalog items
22 23 24 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 22 def refinements @refinements end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 66 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. number_of_results = hash.key?('numberOfResults') ? hash['numberOfResults'] : SKIP pagination = Pagination.from_hash(hash['pagination']) if hash['pagination'] refinements = Refinements.from_hash(hash['refinements']) if hash['refinements'] # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (Item.from_hash(structure) if structure) end end items = SKIP unless hash.key?('items') # 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. ItemSearchResults.new(number_of_results: number_of_results, pagination: pagination, refinements: refinements, items: items, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['number_of_results'] = 'numberOfResults' @_hash['pagination'] = 'pagination' @_hash['refinements'] = 'refinements' @_hash['items'] = 'items' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 45 46 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 39 def self.optionals %w[ number_of_results pagination refinements items ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
109 110 111 112 113 114 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 109 def inspect class_name = self.class.name.split('::').last "<#{class_name} number_of_results: #{@number_of_results.inspect}, pagination:"\ " #{@pagination.inspect}, refinements: #{@refinements.inspect}, items: #{@items.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
101 102 103 104 105 106 |
# File 'lib/walmart_ap_is/models/item_search_results.rb', line 101 def to_s class_name = self.class.name.split('::').last "<#{class_name} number_of_results: #{@number_of_results}, pagination: #{@pagination},"\ " refinements: #{@refinements}, items: #{@items}, additional_properties:"\ " #{@additional_properties}>" end |