manticore-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +39 -0
  3. data/.openapi-generator/FILES +149 -0
  4. data/.openapi-generator/VERSION +1 -0
  5. data/.openapi-generator-ignore +5 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +160 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +103 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +136 -0
  12. data/Rakefile +10 -0
  13. data/docs/AggComposite.md +20 -0
  14. data/docs/AggCompositeSource.md +18 -0
  15. data/docs/AggCompositeTerm.md +18 -0
  16. data/docs/AggTerms.md +20 -0
  17. data/docs/Aggregation.md +22 -0
  18. data/docs/AutocompleteRequest.md +22 -0
  19. data/docs/BoolFilter.md +22 -0
  20. data/docs/BulkResponse.md +26 -0
  21. data/docs/DeleteDocumentRequest.md +24 -0
  22. data/docs/DeleteResponse.md +26 -0
  23. data/docs/ErrorResponse.md +20 -0
  24. data/docs/FulltextFilter.md +24 -0
  25. data/docs/GeoDistance.md +24 -0
  26. data/docs/GeoDistanceLocationAnchor.md +20 -0
  27. data/docs/Highlight.md +62 -0
  28. data/docs/HighlightAllOfFields.md +15 -0
  29. data/docs/HighlightFieldOption.md +26 -0
  30. data/docs/HitsHits.md +22 -0
  31. data/docs/IndexApi.md +401 -0
  32. data/docs/InsertDocumentRequest.md +24 -0
  33. data/docs/Join.md +24 -0
  34. data/docs/JoinCond.md +22 -0
  35. data/docs/JoinOn.md +22 -0
  36. data/docs/KnnQuery.md +28 -0
  37. data/docs/Match.md +22 -0
  38. data/docs/MatchAll.md +18 -0
  39. data/docs/PercolateRequest.md +18 -0
  40. data/docs/PercolateRequestQuery.md +18 -0
  41. data/docs/QueryFilter.md +34 -0
  42. data/docs/Range.md +24 -0
  43. data/docs/ReplaceDocumentRequest.md +18 -0
  44. data/docs/ResponseError.md +49 -0
  45. data/docs/ResponseErrorDetails.md +22 -0
  46. data/docs/SearchApi.md +204 -0
  47. data/docs/SearchQuery.md +36 -0
  48. data/docs/SearchRequest.md +46 -0
  49. data/docs/SearchResponse.md +30 -0
  50. data/docs/SearchResponseHits.md +24 -0
  51. data/docs/SourceRules.md +20 -0
  52. data/docs/SqlResponse.md +49 -0
  53. data/docs/SuccessResponse.md +28 -0
  54. data/docs/UpdateDocumentRequest.md +26 -0
  55. data/docs/UpdateResponse.md +24 -0
  56. data/docs/UtilsApi.md +76 -0
  57. data/lib/manticore/client/api/index_api.rb +442 -0
  58. data/lib/manticore/client/api/search_api.rb +232 -0
  59. data/lib/manticore/client/api/utils_api.rb +93 -0
  60. data/lib/manticore/client/api_client.rb +437 -0
  61. data/lib/manticore/client/api_error.rb +58 -0
  62. data/lib/manticore/client/configuration.rb +385 -0
  63. data/lib/manticore/client/models/agg_composite.rb +233 -0
  64. data/lib/manticore/client/models/agg_composite_source.rb +238 -0
  65. data/lib/manticore/client/models/agg_composite_term.rb +239 -0
  66. data/lib/manticore/client/models/agg_terms.rb +249 -0
  67. data/lib/manticore/client/models/aggregation.rb +240 -0
  68. data/lib/manticore/client/models/autocomplete_request.rb +276 -0
  69. data/lib/manticore/client/models/bool_filter.rb +247 -0
  70. data/lib/manticore/client/models/bulk_response.rb +264 -0
  71. data/lib/manticore/client/models/delete_document_request.rb +269 -0
  72. data/lib/manticore/client/models/delete_response.rb +262 -0
  73. data/lib/manticore/client/models/error_response.rb +250 -0
  74. data/lib/manticore/client/models/fulltext_filter.rb +252 -0
  75. data/lib/manticore/client/models/geo_distance.rb +306 -0
  76. data/lib/manticore/client/models/geo_distance_location_anchor.rb +232 -0
  77. data/lib/manticore/client/models/highlight.rb +525 -0
  78. data/lib/manticore/client/models/highlight_all_of_fields.rb +105 -0
  79. data/lib/manticore/client/models/highlight_field_option.rb +262 -0
  80. data/lib/manticore/client/models/hits_hits.rb +242 -0
  81. data/lib/manticore/client/models/insert_document_request.rb +286 -0
  82. data/lib/manticore/client/models/join.rb +327 -0
  83. data/lib/manticore/client/models/join_cond.rb +276 -0
  84. data/lib/manticore/client/models/join_on.rb +272 -0
  85. data/lib/manticore/client/models/knn_query.rb +307 -0
  86. data/lib/manticore/client/models/match.rb +290 -0
  87. data/lib/manticore/client/models/match_all.rb +262 -0
  88. data/lib/manticore/client/models/percolate_request.rb +238 -0
  89. data/lib/manticore/client/models/percolate_request_query.rb +238 -0
  90. data/lib/manticore/client/models/query_filter.rb +307 -0
  91. data/lib/manticore/client/models/range.rb +252 -0
  92. data/lib/manticore/client/models/replace_document_request.rb +239 -0
  93. data/lib/manticore/client/models/response_error.rb +105 -0
  94. data/lib/manticore/client/models/response_error_details.rb +261 -0
  95. data/lib/manticore/client/models/search_query.rb +316 -0
  96. data/lib/manticore/client/models/search_request.rb +382 -0
  97. data/lib/manticore/client/models/search_response.rb +281 -0
  98. data/lib/manticore/client/models/search_response_hits.rb +254 -0
  99. data/lib/manticore/client/models/source_rules.rb +236 -0
  100. data/lib/manticore/client/models/sql_response.rb +106 -0
  101. data/lib/manticore/client/models/success_response.rb +272 -0
  102. data/lib/manticore/client/models/update_document_request.rb +296 -0
  103. data/lib/manticore/client/models/update_response.rb +252 -0
  104. data/lib/manticore/client/version.rb +7 -0
  105. data/lib/manticore/client.rb +32 -0
  106. data/lib/manticore-client.rb +3 -0
  107. data/manticore-client.gemspec +34 -0
  108. data/spec/api/index_api_spec.rb +179 -0
  109. data/spec/api/search_api_spec.rb +94 -0
  110. data/spec/api/utils_api_spec.rb +100 -0
  111. data/spec/spec_helper.rb +92 -0
  112. data/spec/support/manticore_sql_helper.rb +33 -0
  113. metadata +218 -0
@@ -0,0 +1,272 @@
1
+ =begin
2
+ #Manticore Search Client
3
+
4
+ #Сlient for Manticore Search.
5
+
6
+ The version of the OpenAPI document: 5.0.0
7
+ Contact: info@manticoresearch.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Manticore::Client
17
+ # Response object indicating the success of an operation, such as inserting or updating a document
18
+ class SuccessResponse
19
+ # Name of the document table
20
+ attr_accessor :table
21
+
22
+ # ID of the document affected by the request operation
23
+ attr_accessor :id
24
+
25
+ # Indicates whether the document was created as a result of the operation
26
+ attr_accessor :created
27
+
28
+ # Result of the operation, typically 'created', 'updated', or 'deleted'
29
+ attr_accessor :result
30
+
31
+ # Indicates whether the document was found in the table
32
+ attr_accessor :found
33
+
34
+ # HTTP status code representing the result of the operation
35
+ attr_accessor :status
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'table' => :'table',
41
+ :'id' => :'id',
42
+ :'created' => :'created',
43
+ :'result' => :'result',
44
+ :'found' => :'found',
45
+ :'status' => :'status'
46
+ }
47
+ end
48
+
49
+ # Returns attribute mapping this model knows about
50
+ def self.acceptable_attribute_map
51
+ attribute_map
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ acceptable_attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'table' => :'String',
63
+ :'id' => :'Integer',
64
+ :'created' => :'Boolean',
65
+ :'result' => :'String',
66
+ :'found' => :'Boolean',
67
+ :'status' => :'Integer'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Manticore::Client::SuccessResponse` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ acceptable_attribute_map = self.class.acceptable_attribute_map
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!acceptable_attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Manticore::Client::SuccessResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'table')
94
+ self.table = attributes[:'table']
95
+ end
96
+
97
+ if attributes.key?(:'id')
98
+ self.id = attributes[:'id']
99
+ end
100
+
101
+ if attributes.key?(:'created')
102
+ self.created = attributes[:'created']
103
+ end
104
+
105
+ if attributes.key?(:'result')
106
+ self.result = attributes[:'result']
107
+ end
108
+
109
+ if attributes.key?(:'found')
110
+ self.found = attributes[:'found']
111
+ end
112
+
113
+ if attributes.key?(:'status')
114
+ self.status = attributes[:'status']
115
+ end
116
+ end
117
+
118
+ # Show invalid properties with the reasons. Usually used together with valid?
119
+ # @return Array for valid properties with the reasons
120
+ def list_invalid_properties
121
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
122
+ invalid_properties = Array.new
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ warn '[DEPRECATED] the `valid?` method is obsolete'
130
+ true
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ table == o.table &&
139
+ id == o.id &&
140
+ created == o.created &&
141
+ result == o.result &&
142
+ found == o.found &&
143
+ status == o.status
144
+ end
145
+
146
+ # @see the `==` method
147
+ # @param [Object] Object to be compared
148
+ def eql?(o)
149
+ self == o
150
+ end
151
+
152
+ # Calculates hash code according to all attributes.
153
+ # @return [Integer] Hash code
154
+ def hash
155
+ [table, id, created, result, found, status].hash
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def self.build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ attributes = attributes.transform_keys(&:to_sym)
164
+ transformed_hash = {}
165
+ openapi_types.each_pair do |key, type|
166
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
167
+ transformed_hash["#{key}"] = nil
168
+ elsif type =~ /\AArray<(.*)>/i
169
+ # check to ensure the input is an array given that the attribute
170
+ # is documented as an array but the input is not
171
+ if attributes[attribute_map[key]].is_a?(Array)
172
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
173
+ end
174
+ elsif !attributes[attribute_map[key]].nil?
175
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
176
+ end
177
+ end
178
+ new(transformed_hash)
179
+ end
180
+
181
+ # Deserializes the data based on type
182
+ # @param string type Data type
183
+ # @param string value Value to be deserialized
184
+ # @return [Object] Deserialized data
185
+ def self._deserialize(type, value)
186
+ case type.to_sym
187
+ when :Time
188
+ Time.parse(value)
189
+ when :Date
190
+ Date.parse(value)
191
+ when :String
192
+ value.to_s
193
+ when :Integer
194
+ value.to_i
195
+ when :Float
196
+ value.to_f
197
+ when :Boolean
198
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
199
+ true
200
+ else
201
+ false
202
+ end
203
+ when :Object
204
+ # generic object (usually a Hash), return directly
205
+ value
206
+ when /\AArray<(?<inner_type>.+)>\z/
207
+ inner_type = Regexp.last_match[:inner_type]
208
+ value.map { |v| _deserialize(inner_type, v) }
209
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
210
+ k_type = Regexp.last_match[:k_type]
211
+ v_type = Regexp.last_match[:v_type]
212
+ {}.tap do |hash|
213
+ value.each do |k, v|
214
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
215
+ end
216
+ end
217
+ else # model
218
+ # models (e.g. Pet) or oneOf
219
+ klass = Manticore::Client.const_get(type)
220
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
221
+ end
222
+ end
223
+
224
+ # Returns the string representation of the object
225
+ # @return [String] String presentation of the object
226
+ def to_s
227
+ to_hash.to_s
228
+ end
229
+
230
+ # to_body is an alias to to_hash (backward compatibility)
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_body
233
+ to_hash
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = self.send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+
270
+ end
271
+
272
+ end
@@ -0,0 +1,296 @@
1
+ =begin
2
+ #Manticore Search Client
3
+
4
+ #Сlient for Manticore Search.
5
+
6
+ The version of the OpenAPI document: 5.0.0
7
+ Contact: info@manticoresearch.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Manticore::Client
17
+ # Payload for updating a document or multiple documents in a table
18
+ class UpdateDocumentRequest
19
+ # Name of the document table
20
+ attr_accessor :table
21
+
22
+ # Name of the document cluster
23
+ attr_accessor :cluster
24
+
25
+ # Object containing the document fields to update
26
+ attr_accessor :doc
27
+
28
+ # Document ID
29
+ attr_accessor :id
30
+
31
+ attr_accessor :query
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'table' => :'table',
37
+ :'cluster' => :'cluster',
38
+ :'doc' => :'doc',
39
+ :'id' => :'id',
40
+ :'query' => :'query'
41
+ }
42
+ end
43
+
44
+ # Returns attribute mapping this model knows about
45
+ def self.acceptable_attribute_map
46
+ attribute_map
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ acceptable_attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'table' => :'String',
58
+ :'cluster' => :'String',
59
+ :'doc' => :'Object',
60
+ :'id' => :'Integer',
61
+ :'query' => :'QueryFilter'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ :'query'
69
+ ])
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ if (!attributes.is_a?(Hash))
76
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Manticore::Client::UpdateDocumentRequest` initialize method"
77
+ end
78
+
79
+ # check to see if the attribute exists and convert string to symbol for hash key
80
+ acceptable_attribute_map = self.class.acceptable_attribute_map
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!acceptable_attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Manticore::Client::UpdateDocumentRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'table')
89
+ self.table = attributes[:'table']
90
+ else
91
+ self.table = nil
92
+ end
93
+
94
+ if attributes.key?(:'cluster')
95
+ self.cluster = attributes[:'cluster']
96
+ end
97
+
98
+ if attributes.key?(:'doc')
99
+ self.doc = attributes[:'doc']
100
+ else
101
+ self.doc = nil
102
+ end
103
+
104
+ if attributes.key?(:'id')
105
+ self.id = attributes[:'id']
106
+ end
107
+
108
+ if attributes.key?(:'query')
109
+ self.query = attributes[:'query']
110
+ end
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
117
+ invalid_properties = Array.new
118
+ if @table.nil?
119
+ invalid_properties.push('invalid value for "table", table cannot be nil.')
120
+ end
121
+
122
+ if @doc.nil?
123
+ invalid_properties.push('invalid value for "doc", doc cannot be nil.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ warn '[DEPRECATED] the `valid?` method is obsolete'
133
+ return false if @table.nil?
134
+ return false if @doc.nil?
135
+ true
136
+ end
137
+
138
+ # Custom attribute writer method with validation
139
+ # @param [Object] table Value to be assigned
140
+ def table=(table)
141
+ if table.nil?
142
+ fail ArgumentError, 'table cannot be nil'
143
+ end
144
+
145
+ @table = table
146
+ end
147
+
148
+ # Custom attribute writer method with validation
149
+ # @param [Object] doc Value to be assigned
150
+ def doc=(doc)
151
+ if doc.nil?
152
+ fail ArgumentError, 'doc cannot be nil'
153
+ end
154
+
155
+ @doc = doc
156
+ end
157
+
158
+ # Checks equality by comparing each attribute.
159
+ # @param [Object] Object to be compared
160
+ def ==(o)
161
+ return true if self.equal?(o)
162
+ self.class == o.class &&
163
+ table == o.table &&
164
+ cluster == o.cluster &&
165
+ doc == o.doc &&
166
+ id == o.id &&
167
+ query == o.query
168
+ end
169
+
170
+ # @see the `==` method
171
+ # @param [Object] Object to be compared
172
+ def eql?(o)
173
+ self == o
174
+ end
175
+
176
+ # Calculates hash code according to all attributes.
177
+ # @return [Integer] Hash code
178
+ def hash
179
+ [table, cluster, doc, id, query].hash
180
+ end
181
+
182
+ # Builds the object from hash
183
+ # @param [Hash] attributes Model attributes in the form of hash
184
+ # @return [Object] Returns the model itself
185
+ def self.build_from_hash(attributes)
186
+ return nil unless attributes.is_a?(Hash)
187
+ attributes = attributes.transform_keys(&:to_sym)
188
+ transformed_hash = {}
189
+ openapi_types.each_pair do |key, type|
190
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
191
+ transformed_hash["#{key}"] = nil
192
+ elsif type =~ /\AArray<(.*)>/i
193
+ # check to ensure the input is an array given that the attribute
194
+ # is documented as an array but the input is not
195
+ if attributes[attribute_map[key]].is_a?(Array)
196
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
197
+ end
198
+ elsif !attributes[attribute_map[key]].nil?
199
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
200
+ end
201
+ end
202
+ new(transformed_hash)
203
+ end
204
+
205
+ # Deserializes the data based on type
206
+ # @param string type Data type
207
+ # @param string value Value to be deserialized
208
+ # @return [Object] Deserialized data
209
+ def self._deserialize(type, value)
210
+ case type.to_sym
211
+ when :Time
212
+ Time.parse(value)
213
+ when :Date
214
+ Date.parse(value)
215
+ when :String
216
+ value.to_s
217
+ when :Integer
218
+ value.to_i
219
+ when :Float
220
+ value.to_f
221
+ when :Boolean
222
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
223
+ true
224
+ else
225
+ false
226
+ end
227
+ when :Object
228
+ # generic object (usually a Hash), return directly
229
+ value
230
+ when /\AArray<(?<inner_type>.+)>\z/
231
+ inner_type = Regexp.last_match[:inner_type]
232
+ value.map { |v| _deserialize(inner_type, v) }
233
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
234
+ k_type = Regexp.last_match[:k_type]
235
+ v_type = Regexp.last_match[:v_type]
236
+ {}.tap do |hash|
237
+ value.each do |k, v|
238
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
239
+ end
240
+ end
241
+ else # model
242
+ # models (e.g. Pet) or oneOf
243
+ klass = Manticore::Client.const_get(type)
244
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
245
+ end
246
+ end
247
+
248
+ # Returns the string representation of the object
249
+ # @return [String] String presentation of the object
250
+ def to_s
251
+ to_hash.to_s
252
+ end
253
+
254
+ # to_body is an alias to to_hash (backward compatibility)
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_body
257
+ to_hash
258
+ end
259
+
260
+ # Returns the object in the form of hash
261
+ # @return [Hash] Returns the object in the form of hash
262
+ def to_hash
263
+ hash = {}
264
+ self.class.attribute_map.each_pair do |attr, param|
265
+ value = self.send(attr)
266
+ if value.nil?
267
+ is_nullable = self.class.openapi_nullable.include?(attr)
268
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
269
+ end
270
+
271
+ hash[param] = _to_hash(value)
272
+ end
273
+ hash
274
+ end
275
+
276
+ # Outputs non-array value in the form of hash
277
+ # For object, use to_hash. Otherwise, just return the value
278
+ # @param [Object] value Any valid value
279
+ # @return [Hash] Returns the value in the form of hash
280
+ def _to_hash(value)
281
+ if value.is_a?(Array)
282
+ value.compact.map { |v| _to_hash(v) }
283
+ elsif value.is_a?(Hash)
284
+ {}.tap do |hash|
285
+ value.each { |k, v| hash[k] = _to_hash(v) }
286
+ end
287
+ elsif value.respond_to? :to_hash
288
+ value.to_hash
289
+ else
290
+ value
291
+ end
292
+ end
293
+
294
+ end
295
+
296
+ end