Class: WalmartApIs::Query
- Defined in:
- lib/walmart_ap_is/models/query.rb
Overview
Query Model.
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
TODO: Write general description for this method.
-
#data_documents ⇒ Array[DocumentSummary]
Present only when processingStatus is DONE.
-
#pagination ⇒ Pagination3
Present only when processingStatus is DONE.
-
#processing_status ⇒ ProcessingStatus
TODO: Write general description for this method.
-
#query ⇒ String
TODO: Write general description for this method.
-
#query_id ⇒ String
TODO: Write general description for this method.
-
#updated_at ⇒ DateTime
TODO: Write general description for this method.
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(query_id:, processing_status:, query: SKIP, created_at: SKIP, updated_at: SKIP, data_documents: SKIP, pagination: SKIP, additional_properties: nil) ⇒ Query
constructor
A new instance of Query.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ 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(query_id:, processing_status:, query: SKIP, created_at: SKIP, updated_at: SKIP, data_documents: SKIP, pagination: SKIP, additional_properties: nil) ⇒ Query
Returns a new instance of Query.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/walmart_ap_is/models/query.rb', line 70 def initialize(query_id:, processing_status:, query: SKIP, created_at: SKIP, updated_at: SKIP, data_documents: SKIP, pagination: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @query_id = query_id @query = query unless query == SKIP @processing_status = processing_status @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @data_documents = data_documents unless data_documents == SKIP @pagination = pagination unless pagination == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#created_at ⇒ DateTime
TODO: Write general description for this method
27 28 29 |
# File 'lib/walmart_ap_is/models/query.rb', line 27 def created_at @created_at end |
#data_documents ⇒ Array[DocumentSummary]
Present only when processingStatus is DONE
35 36 37 |
# File 'lib/walmart_ap_is/models/query.rb', line 35 def data_documents @data_documents end |
#pagination ⇒ Pagination3
Present only when processingStatus is DONE
39 40 41 |
# File 'lib/walmart_ap_is/models/query.rb', line 39 def pagination @pagination end |
#processing_status ⇒ ProcessingStatus
TODO: Write general description for this method
23 24 25 |
# File 'lib/walmart_ap_is/models/query.rb', line 23 def processing_status @processing_status end |
#query ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/walmart_ap_is/models/query.rb', line 19 def query @query end |
#query_id ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/walmart_ap_is/models/query.rb', line 15 def query_id @query_id end |
#updated_at ⇒ DateTime
TODO: Write general description for this method
31 32 33 |
# File 'lib/walmart_ap_is/models/query.rb', line 31 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
87 88 89 90 91 92 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 125 126 127 128 129 130 131 132 133 |
# File 'lib/walmart_ap_is/models/query.rb', line 87 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. query_id = hash.key?('queryId') ? hash['queryId'] : nil processing_status = hash.key?('processingStatus') ? hash['processingStatus'] : nil query = hash.key?('query') ? hash['query'] : SKIP created_at = if hash.key?('createdAt') (DateTimeHelper.from_rfc3339(hash['createdAt']) if hash['createdAt']) else SKIP end updated_at = if hash.key?('updatedAt') (DateTimeHelper.from_rfc3339(hash['updatedAt']) if hash['updatedAt']) else SKIP end # Parameter is an array, so we need to iterate through it data_documents = nil unless hash['dataDocuments'].nil? data_documents = [] hash['dataDocuments'].each do |structure| data_documents << (DocumentSummary.from_hash(structure) if structure) end end data_documents = SKIP unless hash.key?('dataDocuments') pagination = Pagination3.from_hash(hash['pagination']) if hash['pagination'] # 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. Query.new(query_id: query_id, processing_status: processing_status, query: query, created_at: created_at, updated_at: updated_at, data_documents: data_documents, pagination: pagination, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/walmart_ap_is/models/query.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['query_id'] = 'queryId' @_hash['query'] = 'query' @_hash['processing_status'] = 'processingStatus' @_hash['created_at'] = 'createdAt' @_hash['updated_at'] = 'updatedAt' @_hash['data_documents'] = 'dataDocuments' @_hash['pagination'] = 'pagination' @_hash end |
.nullables ⇒ Object
An array for nullable fields
66 67 68 |
# File 'lib/walmart_ap_is/models/query.rb', line 66 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 61 62 63 |
# File 'lib/walmart_ap_is/models/query.rb', line 55 def self.optionals %w[ query created_at updated_at data_documents pagination ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
153 154 155 156 157 158 159 |
# File 'lib/walmart_ap_is/models/query.rb', line 153 def inspect class_name = self.class.name.split('::').last "<#{class_name} query_id: #{@query_id.inspect}, query: #{@query.inspect},"\ " processing_status: #{@processing_status.inspect}, created_at: #{@created_at.inspect},"\ " updated_at: #{@updated_at.inspect}, data_documents: #{@data_documents.inspect},"\ " pagination: #{@pagination.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_created_at ⇒ Object
135 136 137 |
# File 'lib/walmart_ap_is/models/query.rb', line 135 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
139 140 141 |
# File 'lib/walmart_ap_is/models/query.rb', line 139 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
144 145 146 147 148 149 150 |
# File 'lib/walmart_ap_is/models/query.rb', line 144 def to_s class_name = self.class.name.split('::').last "<#{class_name} query_id: #{@query_id}, query: #{@query}, processing_status:"\ " #{@processing_status}, created_at: #{@created_at}, updated_at: #{@updated_at},"\ " data_documents: #{@data_documents}, pagination: #{@pagination}, additional_properties:"\ " #{@additional_properties}>" end |