algolia 3.0.0.beta.10 → 3.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/algolia/api/ingestion_client.rb +912 -359
  5. data/lib/algolia/api/query_suggestions_client.rb +4 -10
  6. data/lib/algolia/api/search_client.rb +4 -4
  7. data/lib/algolia/api/usage_client.rb +4 -4
  8. data/lib/algolia/error.rb +10 -0
  9. data/lib/algolia/logger_helper.rb +11 -2
  10. data/lib/algolia/models/abtesting/{filter_effects_empty_search.rb → empty_search_filter.rb} +3 -3
  11. data/lib/algolia/models/abtesting/filter_effects.rb +2 -2
  12. data/lib/algolia/models/abtesting/{filter_effects_outliers.rb → outliers_filter.rb} +3 -3
  13. data/lib/algolia/models/analytics/{click_positions_inner.rb → click_position.rb} +3 -3
  14. data/lib/algolia/models/analytics/get_click_positions_response.rb +1 -1
  15. data/lib/algolia/models/analytics/top_search_with_analytics.rb +1 -1
  16. data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +1 -1
  17. data/lib/algolia/models/ingestion/action.rb +45 -0
  18. data/lib/algolia/models/{search/search_for_hits_options.rb → ingestion/batch_request.rb} +22 -20
  19. data/lib/algolia/models/ingestion/{source_shopify_base.rb → batch_write_params.rb} +14 -12
  20. data/lib/algolia/models/ingestion/docker_streams_input.rb +1 -0
  21. data/lib/algolia/models/{recommend/recommendations_hits.rb → ingestion/list_tasks_response_v1.rb} +26 -14
  22. data/lib/algolia/models/ingestion/task.rb +30 -9
  23. data/lib/algolia/models/ingestion/task_create.rb +11 -12
  24. data/lib/algolia/models/{search/search_for_facets_options.rb → ingestion/task_create_v1.rb} +86 -51
  25. data/lib/algolia/models/ingestion/task_update.rb +8 -7
  26. data/lib/algolia/models/{search/browse_pagination.rb → ingestion/task_update_v1.rb} +50 -55
  27. data/lib/algolia/models/{recommend/looking_similar.rb → ingestion/task_v1.rb} +147 -30
  28. data/lib/algolia/models/ingestion/{transformation_try_response_error.rb → transformation_error.rb} +3 -3
  29. data/lib/algolia/models/ingestion/transformation_try_response.rb +1 -1
  30. data/lib/algolia/models/monitoring/{incidents_inner.rb → incident_entry.rb} +3 -3
  31. data/lib/algolia/models/monitoring/{indexing_time_response_metrics.rb → indexing_metric.rb} +3 -3
  32. data/lib/algolia/models/monitoring/indexing_time_response.rb +1 -1
  33. data/lib/algolia/models/monitoring/infrastructure_response.rb +1 -1
  34. data/lib/algolia/models/monitoring/{latency_response_metrics.rb → latency_metric.rb} +3 -3
  35. data/lib/algolia/models/monitoring/latency_response.rb +1 -1
  36. data/lib/algolia/models/monitoring/{infrastructure_response_metrics.rb → metrics.rb} +3 -6
  37. data/lib/algolia/models/monitoring/{time_inner.rb → time_entry.rb} +3 -3
  38. data/lib/algolia/models/{recommend/trending_items.rb → query-suggestions/config_status.rb} +46 -58
  39. data/lib/algolia/models/{recommend/related_products.rb → query-suggestions/log_file.rb} +36 -32
  40. data/lib/algolia/models/recommend/around_precision.rb +1 -1
  41. data/lib/algolia/models/recommend/fallback_params.rb +1 -1
  42. data/lib/algolia/models/recommend/{around_precision_from_value_inner.rb → range.rb} +3 -6
  43. data/lib/algolia/models/recommend/recommend_rule.rb +1 -1
  44. data/lib/algolia/models/recommend/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  45. data/lib/algolia/models/recommend/redirect_rule_index_metadata.rb +1 -1
  46. data/lib/algolia/models/recommend/{recommend_rule_metadata.rb → rule_metadata.rb} +3 -3
  47. data/lib/algolia/models/recommend/search_params.rb +1 -1
  48. data/lib/algolia/models/recommend/search_params_object.rb +1 -1
  49. data/lib/algolia/models/search/around_precision.rb +1 -1
  50. data/lib/algolia/models/search/browse_params_object.rb +1 -1
  51. data/lib/algolia/models/search/built_in_operation.rb +1 -2
  52. data/lib/algolia/models/search/built_in_operation_value.rb +105 -0
  53. data/lib/algolia/models/search/consequence_params.rb +1 -1
  54. data/lib/algolia/models/search/dictionary_entry.rb +0 -2
  55. data/lib/algolia/models/search/index_settings.rb +2 -2
  56. data/lib/algolia/models/search/{around_precision_from_value_inner.rb → range.rb} +3 -6
  57. data/lib/algolia/models/search/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  58. data/lib/algolia/models/search/redirect_rule_index_metadata.rb +1 -1
  59. data/lib/algolia/models/search/search_for_facets.rb +1 -1
  60. data/lib/algolia/models/search/search_for_hits.rb +1 -1
  61. data/lib/algolia/models/search/search_params_object.rb +1 -1
  62. data/lib/algolia/models/search/search_params_string.rb +1 -0
  63. data/lib/algolia/models/search/{index_settings_as_search_params.rb → settings_response.rb} +251 -11
  64. data/lib/algolia/models/usage/{get_usage400_response_error_errors_inner.rb → error_item.rb} +3 -3
  65. data/lib/algolia/models/usage/{get_usage400_response_error.rb → forbidden_error.rb} +4 -4
  66. data/lib/algolia/models/usage/{get_usage200_response.rb → index_usage.rb} +4 -4
  67. data/lib/algolia/models/usage/invalid_request_error.rb +231 -0
  68. data/lib/algolia/models/usage/{get_usage200_response_statistics_inner.rb → statistic_entry.rb} +3 -3
  69. data/lib/algolia/transport/transport.rb +8 -2
  70. data/lib/algolia/version.rb +1 -1
  71. metadata +32 -63
  72. data/lib/algolia/models/abtesting/custom_search_params.rb +0 -214
  73. data/lib/algolia/models/abtesting/error_base.rb +0 -212
  74. data/lib/algolia/models/analytics/error_base.rb +0 -212
  75. data/lib/algolia/models/ingestion/error_base.rb +0 -212
  76. data/lib/algolia/models/insights/error_base.rb +0 -212
  77. data/lib/algolia/models/monitoring/error_base.rb +0 -212
  78. data/lib/algolia/models/monitoring/get_servers403_response.rb +0 -211
  79. data/lib/algolia/models/personalization/error_base.rb +0 -212
  80. data/lib/algolia/models/query-suggestions/app_id.rb +0 -209
  81. data/lib/algolia/models/query-suggestions/error_base.rb +0 -212
  82. data/lib/algolia/models/recommend/base_recommend_request.rb +0 -281
  83. data/lib/algolia/models/recommend/base_search_params.rb +0 -635
  84. data/lib/algolia/models/recommend/base_search_params_without_query.rb +0 -616
  85. data/lib/algolia/models/recommend/base_search_response.rb +0 -499
  86. data/lib/algolia/models/recommend/error_base.rb +0 -212
  87. data/lib/algolia/models/recommend/frequently_bought_together.rb +0 -247
  88. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +0 -788
  89. data/lib/algolia/models/recommend/recommended_for_you.rb +0 -244
  90. data/lib/algolia/models/recommend/search_pagination.rb +0 -282
  91. data/lib/algolia/models/recommend/search_params_query.rb +0 -212
  92. data/lib/algolia/models/recommend/trending_facets.rb +0 -258
  93. data/lib/algolia/models/search/base_get_api_key_response.rb +0 -224
  94. data/lib/algolia/models/search/base_index_settings.rb +0 -426
  95. data/lib/algolia/models/search/base_search_params.rb +0 -635
  96. data/lib/algolia/models/search/base_search_params_without_query.rb +0 -616
  97. data/lib/algolia/models/search/base_search_response.rb +0 -499
  98. data/lib/algolia/models/search/cursor.rb +0 -209
  99. data/lib/algolia/models/search/error_base.rb +0 -212
  100. data/lib/algolia/models/search/params.rb +0 -236
  101. data/lib/algolia/models/search/search_hits.rb +0 -240
  102. data/lib/algolia/models/search/search_pagination.rb +0 -282
  103. data/lib/algolia/models/search/search_params_query.rb +0 -212
  104. data/lib/algolia/models/usage/error_base.rb +0 -212
  105. data/lib/algolia/models/usage/get_usage400_response.rb +0 -213
@@ -1,499 +0,0 @@
1
- # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
-
3
- require "date"
4
- require "time"
5
-
6
- module Algolia
7
- module Search
8
- class BaseSearchResponse
9
- # A/B test ID. This is only included in the response for indices that are part of an A/B test.
10
- attr_accessor :ab_test_id
11
-
12
- # Variant ID. This is only included in the response for indices that are part of an A/B test.
13
- attr_accessor :ab_test_variant_id
14
-
15
- # Computed geographical location.
16
- attr_accessor :around_lat_lng
17
-
18
- # Distance from a central coordinate provided by `aroundLatLng`.
19
- attr_accessor :automatic_radius
20
-
21
- attr_accessor :exhaustive
22
-
23
- # See the `facetsCount` field of the `exhaustive` object in the response.
24
- attr_accessor :exhaustive_facets_count
25
-
26
- # See the `nbHits` field of the `exhaustive` object in the response.
27
- attr_accessor :exhaustive_nb_hits
28
-
29
- # See the `typo` field of the `exhaustive` object in the response.
30
- attr_accessor :exhaustive_typo
31
-
32
- # Facet counts.
33
- attr_accessor :facets
34
-
35
- # Statistics for numerical facets.
36
- attr_accessor :facets_stats
37
-
38
- # Index name used for the query.
39
- attr_accessor :index
40
-
41
- # Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query.
42
- attr_accessor :index_used
43
-
44
- # Warnings about the query.
45
- attr_accessor :message
46
-
47
- # Number of hits selected and sorted by the relevant sort algorithm.
48
- attr_accessor :nb_sorted_hits
49
-
50
- # Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) query string that will be searched.
51
- attr_accessor :parsed_query
52
-
53
- # Time the server took to process the request, in milliseconds.
54
- attr_accessor :processing_time_ms
55
-
56
- # Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate performance issues.
57
- attr_accessor :processing_timings_ms
58
-
59
- # Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set.
60
- attr_accessor :query_after_removal
61
-
62
- attr_accessor :redirect
63
-
64
- attr_accessor :rendering_content
65
-
66
- # Time the server took to process the request, in milliseconds.
67
- attr_accessor :server_time_ms
68
-
69
- # Host name of the server that processed the request.
70
- attr_accessor :server_used
71
-
72
- # An object with custom data. You can store up to 32kB as custom data.
73
- attr_accessor :user_data
74
-
75
- # Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
76
- attr_accessor :query_id
77
-
78
- attr_accessor :additional_properties
79
-
80
- # Attribute mapping from ruby-style variable name to JSON key.
81
- def self.attribute_map
82
- {
83
- :ab_test_id => :abTestID,
84
- :ab_test_variant_id => :abTestVariantID,
85
- :around_lat_lng => :aroundLatLng,
86
- :automatic_radius => :automaticRadius,
87
- :exhaustive => :exhaustive,
88
- :exhaustive_facets_count => :exhaustiveFacetsCount,
89
- :exhaustive_nb_hits => :exhaustiveNbHits,
90
- :exhaustive_typo => :exhaustiveTypo,
91
- :facets => :facets,
92
- :facets_stats => :facets_stats,
93
- :index => :index,
94
- :index_used => :indexUsed,
95
- :message => :message,
96
- :nb_sorted_hits => :nbSortedHits,
97
- :parsed_query => :parsedQuery,
98
- :processing_time_ms => :processingTimeMS,
99
- :processing_timings_ms => :processingTimingsMS,
100
- :query_after_removal => :queryAfterRemoval,
101
- :redirect => :redirect,
102
- :rendering_content => :renderingContent,
103
- :server_time_ms => :serverTimeMS,
104
- :server_used => :serverUsed,
105
- :user_data => :userData,
106
- :query_id => :queryID
107
- }
108
- end
109
-
110
- # Returns all the JSON keys this model knows about
111
- def self.acceptable_attributes
112
- attribute_map.values
113
- end
114
-
115
- # Attribute type mapping.
116
- def self.types_mapping
117
- {
118
- :ab_test_id => :"Integer",
119
- :ab_test_variant_id => :"Integer",
120
- :around_lat_lng => :"String",
121
- :automatic_radius => :"String",
122
- :exhaustive => :"Exhaustive",
123
- :exhaustive_facets_count => :"Boolean",
124
- :exhaustive_nb_hits => :"Boolean",
125
- :exhaustive_typo => :"Boolean",
126
- :facets => :"Hash<String, Hash<String, Integer>>",
127
- :facets_stats => :"Hash<String, FacetsStats>",
128
- :index => :"String",
129
- :index_used => :"String",
130
- :message => :"String",
131
- :nb_sorted_hits => :"Integer",
132
- :parsed_query => :"String",
133
- :processing_time_ms => :"Integer",
134
- :processing_timings_ms => :"Object",
135
- :query_after_removal => :"String",
136
- :redirect => :"Redirect",
137
- :rendering_content => :"RenderingContent",
138
- :server_time_ms => :"Integer",
139
- :server_used => :"String",
140
- :user_data => :"Object",
141
- :query_id => :"String"
142
- }
143
- end
144
-
145
- # List of attributes with nullable: true
146
- def self.openapi_nullable
147
- Set.new(
148
- []
149
- )
150
- end
151
-
152
- # Initializes the object
153
- # @param [Hash] attributes Model attributes in the form of hash
154
- def initialize(attributes = {})
155
- if (!attributes.is_a?(Hash))
156
- raise(
157
- ArgumentError,
158
- "The input argument (attributes) must be a hash in `Algolia::BaseSearchResponse` initialize method"
159
- )
160
- end
161
-
162
- if attributes.key?(:ab_test_id)
163
- self.ab_test_id = attributes[:ab_test_id]
164
- end
165
-
166
- if attributes.key?(:ab_test_variant_id)
167
- self.ab_test_variant_id = attributes[:ab_test_variant_id]
168
- end
169
-
170
- if attributes.key?(:around_lat_lng)
171
- self.around_lat_lng = attributes[:around_lat_lng]
172
- end
173
-
174
- if attributes.key?(:automatic_radius)
175
- self.automatic_radius = attributes[:automatic_radius]
176
- end
177
-
178
- if attributes.key?(:exhaustive)
179
- self.exhaustive = attributes[:exhaustive]
180
- end
181
-
182
- if attributes.key?(:exhaustive_facets_count)
183
- self.exhaustive_facets_count = attributes[:exhaustive_facets_count]
184
- end
185
-
186
- if attributes.key?(:exhaustive_nb_hits)
187
- self.exhaustive_nb_hits = attributes[:exhaustive_nb_hits]
188
- end
189
-
190
- if attributes.key?(:exhaustive_typo)
191
- self.exhaustive_typo = attributes[:exhaustive_typo]
192
- end
193
-
194
- if attributes.key?(:facets)
195
- if (value = attributes[:facets]).is_a?(Hash)
196
- self.facets = value
197
- end
198
- end
199
-
200
- if attributes.key?(:facets_stats)
201
- if (value = attributes[:facets_stats]).is_a?(Hash)
202
- self.facets_stats = value
203
- end
204
- end
205
-
206
- if attributes.key?(:index)
207
- self.index = attributes[:index]
208
- end
209
-
210
- if attributes.key?(:index_used)
211
- self.index_used = attributes[:index_used]
212
- end
213
-
214
- if attributes.key?(:message)
215
- self.message = attributes[:message]
216
- end
217
-
218
- if attributes.key?(:nb_sorted_hits)
219
- self.nb_sorted_hits = attributes[:nb_sorted_hits]
220
- end
221
-
222
- if attributes.key?(:parsed_query)
223
- self.parsed_query = attributes[:parsed_query]
224
- end
225
-
226
- if attributes.key?(:processing_time_ms)
227
- self.processing_time_ms = attributes[:processing_time_ms]
228
- else
229
- self.processing_time_ms = nil
230
- end
231
-
232
- if attributes.key?(:processing_timings_ms)
233
- self.processing_timings_ms = attributes[:processing_timings_ms]
234
- end
235
-
236
- if attributes.key?(:query_after_removal)
237
- self.query_after_removal = attributes[:query_after_removal]
238
- end
239
-
240
- if attributes.key?(:redirect)
241
- self.redirect = attributes[:redirect]
242
- end
243
-
244
- if attributes.key?(:rendering_content)
245
- self.rendering_content = attributes[:rendering_content]
246
- end
247
-
248
- if attributes.key?(:server_time_ms)
249
- self.server_time_ms = attributes[:server_time_ms]
250
- end
251
-
252
- if attributes.key?(:server_used)
253
- self.server_used = attributes[:server_used]
254
- end
255
-
256
- if attributes.key?(:user_data)
257
- self.user_data = attributes[:user_data]
258
- end
259
-
260
- if attributes.key?(:query_id)
261
- self.query_id = attributes[:query_id]
262
- end
263
-
264
- # add extra attribute to additional_properties
265
- self.additional_properties ||= {}
266
- self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
267
- end
268
-
269
- # Custom attribute writer method with validation
270
- # @param [Object] ab_test_variant_id Value to be assigned
271
- def ab_test_variant_id=(ab_test_variant_id)
272
- if ab_test_variant_id.nil?
273
- raise ArgumentError, "ab_test_variant_id cannot be nil"
274
- end
275
-
276
- if ab_test_variant_id < 1
277
- raise ArgumentError, "invalid value for \"ab_test_variant_id\", must be greater than or equal to 1."
278
- end
279
-
280
- @ab_test_variant_id = ab_test_variant_id
281
- end
282
-
283
- # Custom attribute writer method with validation
284
- # @param [Object] around_lat_lng Value to be assigned
285
- def around_lat_lng=(around_lat_lng)
286
- if around_lat_lng.nil?
287
- raise ArgumentError, "around_lat_lng cannot be nil"
288
- end
289
-
290
- pattern = /^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$/
291
- if around_lat_lng !~ pattern
292
- raise ArgumentError, "invalid value for \"around_lat_lng\", must conform to the pattern #{pattern}."
293
- end
294
-
295
- @around_lat_lng = around_lat_lng
296
- end
297
-
298
- # Checks equality by comparing each attribute.
299
- # @param [Object] Object to be compared
300
- def ==(other)
301
- return true if self.equal?(other)
302
- self.class == other.class &&
303
- ab_test_id == other.ab_test_id &&
304
- ab_test_variant_id == other.ab_test_variant_id &&
305
- around_lat_lng == other.around_lat_lng &&
306
- automatic_radius == other.automatic_radius &&
307
- exhaustive == other.exhaustive &&
308
- exhaustive_facets_count == other.exhaustive_facets_count &&
309
- exhaustive_nb_hits == other.exhaustive_nb_hits &&
310
- exhaustive_typo == other.exhaustive_typo &&
311
- facets == other.facets &&
312
- facets_stats == other.facets_stats &&
313
- index == other.index &&
314
- index_used == other.index_used &&
315
- message == other.message &&
316
- nb_sorted_hits == other.nb_sorted_hits &&
317
- parsed_query == other.parsed_query &&
318
- processing_time_ms == other.processing_time_ms &&
319
- processing_timings_ms == other.processing_timings_ms &&
320
- query_after_removal == other.query_after_removal &&
321
- redirect == other.redirect &&
322
- rendering_content == other.rendering_content &&
323
- server_time_ms == other.server_time_ms &&
324
- server_used == other.server_used &&
325
- user_data == other.user_data &&
326
- query_id == other.query_id
327
- end
328
-
329
- # @see the `==` method
330
- # @param [Object] Object to be compared
331
- def eql?(other)
332
- self == other
333
- end
334
-
335
- # Calculates hash code according to all attributes.
336
- # @return [Integer] Hash code
337
- def hash
338
- [
339
- ab_test_id,
340
- ab_test_variant_id,
341
- around_lat_lng,
342
- automatic_radius,
343
- exhaustive,
344
- exhaustive_facets_count,
345
- exhaustive_nb_hits,
346
- exhaustive_typo,
347
- facets,
348
- facets_stats,
349
- index,
350
- index_used,
351
- message,
352
- nb_sorted_hits,
353
- parsed_query,
354
- processing_time_ms,
355
- processing_timings_ms,
356
- query_after_removal,
357
- redirect,
358
- rendering_content,
359
- server_time_ms,
360
- server_used,
361
- user_data,
362
- query_id
363
- ].hash
364
- end
365
-
366
- # Builds the object from hash
367
- # @param [Hash] attributes Model attributes in the form of hash
368
- # @return [Object] Returns the model itself
369
- def self.build_from_hash(attributes)
370
- return nil unless attributes.is_a?(Hash)
371
- attributes = attributes.transform_keys(&:to_sym)
372
- transformed_hash = {}
373
- types_mapping.each_pair do |key, type|
374
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
375
- transformed_hash[key.to_sym] = nil
376
- elsif type =~ /\AArray<(.*)>/i
377
- # check to ensure the input is an array given that the attribute
378
- # is documented as an array but the input is not
379
- if attributes[attribute_map[key]].is_a?(Array)
380
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
381
- _deserialize(::Regexp.last_match(1), v)
382
- }
383
- end
384
- elsif !attributes[attribute_map[key]].nil?
385
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
386
- end
387
- end
388
-
389
- # add extra attribute to transformed_hash
390
- transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
391
- new(transformed_hash)
392
- end
393
-
394
- # Deserializes the data based on type
395
- # @param string type Data type
396
- # @param string value Value to be deserialized
397
- # @return [Object] Deserialized data
398
- def self._deserialize(type, value)
399
- case type.to_sym
400
- when :Time
401
- Time.parse(value)
402
- when :Date
403
- Date.parse(value)
404
- when :String
405
- value.to_s
406
- when :Integer
407
- value.to_i
408
- when :Float
409
- value.to_f
410
- when :Boolean
411
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
412
- true
413
- else
414
- false
415
- end
416
-
417
- when :Object
418
- # generic object (usually a Hash), return directly
419
- value
420
- when /\AArray<(?<inner_type>.+)>\z/
421
- inner_type = Regexp.last_match[:inner_type]
422
- value.map { |v| _deserialize(inner_type, v) }
423
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
424
- k_type = Regexp.last_match[:k_type]
425
- v_type = Regexp.last_match[:v_type]
426
- {}.tap do |hash|
427
- value.each do |k, v|
428
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
429
- end
430
- end
431
- # model
432
- else
433
- # models (e.g. Pet) or oneOf
434
- klass = Algolia::Search.const_get(type)
435
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
436
- .build_from_hash(value)
437
- end
438
- end
439
-
440
- # Returns the string representation of the object
441
- # @return [String] String presentation of the object
442
- def to_s
443
- to_hash.to_s
444
- end
445
-
446
- # to_body is an alias to to_hash (backward compatibility)
447
- # @return [Hash] Returns the object in the form of hash
448
- def to_body
449
- to_hash
450
- end
451
-
452
- def to_json(*_args)
453
- to_hash.to_json
454
- end
455
-
456
- # Returns the object in the form of hash
457
- # @return [Hash] Returns the object in the form of hash
458
- def to_hash
459
- hash = {}
460
- self.class.attribute_map.each_pair do |attr, param|
461
- value = send(attr)
462
- if value.nil?
463
- is_nullable = self.class.openapi_nullable.include?(attr)
464
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
465
- end
466
-
467
- hash[param] = _to_hash(value)
468
- end
469
-
470
- # also add attributes from additional_properties to hash
471
- self.additional_properties&.each_pair do |k, v|
472
- hash[k.to_sym] = _to_hash(v)
473
- end
474
-
475
- hash
476
- end
477
-
478
- # Outputs non-array value in the form of hash
479
- # For object, use to_hash. Otherwise, just return the value
480
- # @param [Object] value Any valid value
481
- # @return [Hash] Returns the value in the form of hash
482
- def _to_hash(value)
483
- if value.is_a?(Array)
484
- value.compact.map { |v| _to_hash(v) }
485
- elsif value.is_a?(Hash)
486
- {}.tap do |hash|
487
- value.each { |k, v| hash[k] = _to_hash(v) }
488
- end
489
- elsif value.respond_to?(:to_hash)
490
- value.to_hash
491
- else
492
- value
493
- end
494
- end
495
-
496
- end
497
-
498
- end
499
- end
@@ -1,209 +0,0 @@
1
- # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
-
3
- require "date"
4
- require "time"
5
-
6
- module Algolia
7
- module Search
8
- class Cursor
9
- # Cursor to get the next page of the response. The parameter must match the value returned in the response of a previous request. The last page of the response does not return a `cursor` attribute.
10
- attr_accessor :cursor
11
-
12
- # Attribute mapping from ruby-style variable name to JSON key.
13
- def self.attribute_map
14
- {
15
- :cursor => :cursor
16
- }
17
- end
18
-
19
- # Returns all the JSON keys this model knows about
20
- def self.acceptable_attributes
21
- attribute_map.values
22
- end
23
-
24
- # Attribute type mapping.
25
- def self.types_mapping
26
- {
27
- :cursor => :"String"
28
- }
29
- end
30
-
31
- # List of attributes with nullable: true
32
- def self.openapi_nullable
33
- Set.new(
34
- []
35
- )
36
- end
37
-
38
- # Initializes the object
39
- # @param [Hash] attributes Model attributes in the form of hash
40
- def initialize(attributes = {})
41
- if (!attributes.is_a?(Hash))
42
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Cursor` initialize method"
43
- end
44
-
45
- # check to see if the attribute exists and convert string to symbol for hash key
46
- attributes = attributes.each_with_object({}) { |(k, v), h|
47
- if (!self.class.attribute_map.key?(k.to_sym))
48
- raise(
49
- ArgumentError,
50
- "`#{k}` is not a valid attribute in `Algolia::Cursor`. Please check the name to make sure it's valid. List of attributes: " +
51
- self.class.attribute_map.keys.inspect
52
- )
53
- end
54
-
55
- h[k.to_sym] = v
56
- }
57
-
58
- if attributes.key?(:cursor)
59
- self.cursor = attributes[:cursor]
60
- end
61
- end
62
-
63
- # Checks equality by comparing each attribute.
64
- # @param [Object] Object to be compared
65
- def ==(other)
66
- return true if self.equal?(other)
67
- self.class == other.class &&
68
- cursor == other.cursor
69
- end
70
-
71
- # @see the `==` method
72
- # @param [Object] Object to be compared
73
- def eql?(other)
74
- self == other
75
- end
76
-
77
- # Calculates hash code according to all attributes.
78
- # @return [Integer] Hash code
79
- def hash
80
- [cursor].hash
81
- end
82
-
83
- # Builds the object from hash
84
- # @param [Hash] attributes Model attributes in the form of hash
85
- # @return [Object] Returns the model itself
86
- def self.build_from_hash(attributes)
87
- return nil unless attributes.is_a?(Hash)
88
- attributes = attributes.transform_keys(&:to_sym)
89
- transformed_hash = {}
90
- types_mapping.each_pair do |key, type|
91
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
92
- transformed_hash[key.to_sym] = nil
93
- elsif type =~ /\AArray<(.*)>/i
94
- # check to ensure the input is an array given that the attribute
95
- # is documented as an array but the input is not
96
- if attributes[attribute_map[key]].is_a?(Array)
97
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
98
- _deserialize(::Regexp.last_match(1), v)
99
- }
100
- end
101
- elsif !attributes[attribute_map[key]].nil?
102
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
103
- end
104
- end
105
-
106
- new(transformed_hash)
107
- end
108
-
109
- # Deserializes the data based on type
110
- # @param string type Data type
111
- # @param string value Value to be deserialized
112
- # @return [Object] Deserialized data
113
- def self._deserialize(type, value)
114
- case type.to_sym
115
- when :Time
116
- Time.parse(value)
117
- when :Date
118
- Date.parse(value)
119
- when :String
120
- value.to_s
121
- when :Integer
122
- value.to_i
123
- when :Float
124
- value.to_f
125
- when :Boolean
126
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
127
- true
128
- else
129
- false
130
- end
131
-
132
- when :Object
133
- # generic object (usually a Hash), return directly
134
- value
135
- when /\AArray<(?<inner_type>.+)>\z/
136
- inner_type = Regexp.last_match[:inner_type]
137
- value.map { |v| _deserialize(inner_type, v) }
138
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
139
- k_type = Regexp.last_match[:k_type]
140
- v_type = Regexp.last_match[:v_type]
141
- {}.tap do |hash|
142
- value.each do |k, v|
143
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
144
- end
145
- end
146
- # model
147
- else
148
- # models (e.g. Pet) or oneOf
149
- klass = Algolia::Search.const_get(type)
150
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
151
- .build_from_hash(value)
152
- end
153
- end
154
-
155
- # Returns the string representation of the object
156
- # @return [String] String presentation of the object
157
- def to_s
158
- to_hash.to_s
159
- end
160
-
161
- # to_body is an alias to to_hash (backward compatibility)
162
- # @return [Hash] Returns the object in the form of hash
163
- def to_body
164
- to_hash
165
- end
166
-
167
- def to_json(*_args)
168
- to_hash.to_json
169
- end
170
-
171
- # Returns the object in the form of hash
172
- # @return [Hash] Returns the object in the form of hash
173
- def to_hash
174
- hash = {}
175
- self.class.attribute_map.each_pair do |attr, param|
176
- value = send(attr)
177
- if value.nil?
178
- is_nullable = self.class.openapi_nullable.include?(attr)
179
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
180
- end
181
-
182
- hash[param] = _to_hash(value)
183
- end
184
-
185
- hash
186
- end
187
-
188
- # Outputs non-array value in the form of hash
189
- # For object, use to_hash. Otherwise, just return the value
190
- # @param [Object] value Any valid value
191
- # @return [Hash] Returns the value in the form of hash
192
- def _to_hash(value)
193
- if value.is_a?(Array)
194
- value.compact.map { |v| _to_hash(v) }
195
- elsif value.is_a?(Hash)
196
- {}.tap do |hash|
197
- value.each { |k, v| hash[k] = _to_hash(v) }
198
- end
199
- elsif value.respond_to?(:to_hash)
200
- value.to_hash
201
- else
202
- value
203
- end
204
- end
205
-
206
- end
207
-
208
- end
209
- end