algolia 3.0.0.alpha.14 → 3.0.0.alpha.15

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/algolia/api/abtesting_client.rb +4 -4
  5. data/lib/algolia/api/analytics_client.rb +268 -98
  6. data/lib/algolia/api/ingestion_client.rb +4 -4
  7. data/lib/algolia/api/insights_client.rb +4 -4
  8. data/lib/algolia/api/monitoring_client.rb +4 -4
  9. data/lib/algolia/api/personalization_client.rb +4 -4
  10. data/lib/algolia/api/query_suggestions_client.rb +4 -4
  11. data/lib/algolia/api/recommend_client.rb +4 -4
  12. data/lib/algolia/api/search_client.rb +4 -4
  13. data/lib/algolia/models/abtesting/{currencies_value.rb → currency.rb} +3 -3
  14. data/lib/algolia/models/abtesting/variant.rb +2 -5
  15. data/lib/algolia/models/analytics/click_positions_inner.rb +242 -0
  16. data/lib/algolia/models/analytics/currencies_value.rb +208 -0
  17. data/lib/algolia/models/analytics/daily_add_to_cart_rates.rb +265 -0
  18. data/lib/algolia/models/analytics/daily_average_clicks.rb +249 -0
  19. data/lib/algolia/models/analytics/{click_through_rate_event.rb → daily_click_through_rates.rb} +24 -14
  20. data/lib/algolia/models/analytics/daily_conversion_rates.rb +265 -0
  21. data/lib/algolia/models/analytics/{no_click_rate_event.rb → daily_no_click_rates.rb} +21 -7
  22. data/lib/algolia/models/analytics/{no_results_rate_event.rb → daily_no_results_rates.rb} +7 -7
  23. data/lib/algolia/models/analytics/{conversion_rate_event.rb → daily_purchase_rates.rb} +18 -22
  24. data/lib/algolia/models/analytics/{average_click_event.rb → daily_revenue.rb} +15 -25
  25. data/lib/algolia/models/analytics/{search_event.rb → daily_searches.rb} +4 -4
  26. data/lib/algolia/models/analytics/{search_no_result_event.rb → daily_searches_no_clicks.rb} +19 -5
  27. data/lib/algolia/models/analytics/{search_no_click_event.rb → daily_searches_no_results.rb} +19 -5
  28. data/lib/algolia/models/analytics/{user_with_date.rb → daily_users.rb} +5 -5
  29. data/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb +267 -0
  30. data/lib/algolia/models/analytics/get_average_click_position_response.rb +31 -5
  31. data/lib/algolia/models/analytics/get_click_positions_response.rb +6 -6
  32. data/lib/algolia/models/analytics/get_click_through_rate_response.rb +22 -12
  33. data/lib/algolia/models/analytics/get_conversion_rate_response.rb +267 -0
  34. data/lib/algolia/models/analytics/get_no_click_rate_response.rb +19 -5
  35. data/lib/algolia/models/analytics/get_no_results_rate_response.rb +5 -5
  36. data/lib/algolia/models/analytics/{get_conversation_rate_response.rb → get_purchase_rate_response.rb} +19 -23
  37. data/lib/algolia/models/analytics/{click_position.rb → get_revenue.rb} +23 -21
  38. data/lib/algolia/models/analytics/get_searches_count_response.rb +2 -2
  39. data/lib/algolia/models/analytics/get_searches_no_clicks_response.rb +2 -2
  40. data/lib/algolia/models/analytics/get_searches_no_results_response.rb +2 -2
  41. data/lib/algolia/models/analytics/get_status_response.rb +4 -2
  42. data/lib/algolia/models/analytics/get_top_countries_response.rb +1 -1
  43. data/lib/algolia/models/analytics/get_top_filter_attributes_response.rb +1 -1
  44. data/lib/algolia/models/analytics/get_top_filter_for_attribute.rb +23 -2
  45. data/lib/algolia/models/analytics/get_top_filters_no_results_response.rb +4 -2
  46. data/lib/algolia/models/analytics/get_top_filters_no_results_value.rb +23 -2
  47. data/lib/algolia/models/analytics/get_top_hits_response.rb +2 -1
  48. data/lib/algolia/models/analytics/get_top_searches_response.rb +2 -1
  49. data/lib/algolia/models/analytics/get_users_count_response.rb +3 -3
  50. data/lib/algolia/models/analytics/operator.rb +38 -0
  51. data/lib/algolia/models/analytics/top_country.rb +1 -1
  52. data/lib/algolia/models/analytics/top_hit.rb +1 -1
  53. data/lib/algolia/models/analytics/top_hit_with_analytics.rb +60 -21
  54. data/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb +437 -0
  55. data/lib/algolia/models/analytics/top_hits_response.rb +1 -1
  56. data/lib/algolia/models/analytics/top_hits_response_with_analytics.rb +1 -1
  57. data/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb +201 -0
  58. data/lib/algolia/models/analytics/top_search.rb +2 -2
  59. data/lib/algolia/models/analytics/top_search_with_analytics.rb +99 -17
  60. data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +504 -0
  61. data/lib/algolia/models/analytics/top_searches_response.rb +1 -1
  62. data/lib/algolia/models/analytics/top_searches_response_with_analytics.rb +1 -1
  63. data/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb +201 -0
  64. data/lib/algolia/version.rb +1 -1
  65. metadata +26 -14
@@ -229,7 +229,7 @@ module Algolia
229
229
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
230
230
  end
231
231
 
232
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
232
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
233
233
  query_params = {}
234
234
  query_params = query_params.merge(parameters) unless parameters.nil?
235
235
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -272,7 +272,7 @@ module Algolia
272
272
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
273
273
  end
274
274
 
275
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
275
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
276
276
  query_params = {}
277
277
  query_params = query_params.merge(parameters) unless parameters.nil?
278
278
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -316,7 +316,7 @@ module Algolia
316
316
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
317
317
  end
318
318
 
319
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
319
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
320
320
  query_params = {}
321
321
  query_params = query_params.merge(parameters) unless parameters.nil?
322
322
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -361,7 +361,7 @@ module Algolia
361
361
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
362
362
  end
363
363
 
364
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
364
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
365
365
  query_params = {}
366
366
  query_params = query_params.merge(parameters) unless parameters.nil?
367
367
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -45,7 +45,7 @@ module Algolia
45
45
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
46
46
  end
47
47
 
48
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
48
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
49
49
  query_params = {}
50
50
  query_params = query_params.merge(parameters) unless parameters.nil?
51
51
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -88,7 +88,7 @@ module Algolia
88
88
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
89
89
  end
90
90
 
91
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
91
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
92
92
  query_params = {}
93
93
  query_params = query_params.merge(parameters) unless parameters.nil?
94
94
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -132,7 +132,7 @@ module Algolia
132
132
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
133
133
  end
134
134
 
135
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
135
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
136
136
  query_params = {}
137
137
  query_params = query_params.merge(parameters) unless parameters.nil?
138
138
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -177,7 +177,7 @@ module Algolia
177
177
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
178
178
  end
179
179
 
180
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
180
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
181
181
  query_params = {}
182
182
  query_params = query_params.merge(parameters) unless parameters.nil?
183
183
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -36,7 +36,7 @@ module Algolia
36
36
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
37
37
  end
38
38
 
39
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
39
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
40
40
  query_params = {}
41
41
  query_params = query_params.merge(parameters) unless parameters.nil?
42
42
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -79,7 +79,7 @@ module Algolia
79
79
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
80
80
  end
81
81
 
82
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
82
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
83
83
  query_params = {}
84
84
  query_params = query_params.merge(parameters) unless parameters.nil?
85
85
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -123,7 +123,7 @@ module Algolia
123
123
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
124
124
  end
125
125
 
126
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
126
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
127
127
  query_params = {}
128
128
  query_params = query_params.merge(parameters) unless parameters.nil?
129
129
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -168,7 +168,7 @@ module Algolia
168
168
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
169
169
  end
170
170
 
171
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
171
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
172
172
  query_params = {}
173
173
  query_params = query_params.merge(parameters) unless parameters.nil?
174
174
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -45,7 +45,7 @@ module Algolia
45
45
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
46
46
  end
47
47
 
48
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
48
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
49
49
  query_params = {}
50
50
  query_params = query_params.merge(parameters) unless parameters.nil?
51
51
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -88,7 +88,7 @@ module Algolia
88
88
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
89
89
  end
90
90
 
91
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
91
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
92
92
  query_params = {}
93
93
  query_params = query_params.merge(parameters) unless parameters.nil?
94
94
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -132,7 +132,7 @@ module Algolia
132
132
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
133
133
  end
134
134
 
135
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
135
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
136
136
  query_params = {}
137
137
  query_params = query_params.merge(parameters) unless parameters.nil?
138
138
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -177,7 +177,7 @@ module Algolia
177
177
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
178
178
  end
179
179
 
180
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
180
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
181
181
  query_params = {}
182
182
  query_params = query_params.merge(parameters) unless parameters.nil?
183
183
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -89,7 +89,7 @@ module Algolia
89
89
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
90
90
  end
91
91
 
92
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
92
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
93
93
  query_params = {}
94
94
  query_params = query_params.merge(parameters) unless parameters.nil?
95
95
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -132,7 +132,7 @@ module Algolia
132
132
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
133
133
  end
134
134
 
135
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
135
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
136
136
  query_params = {}
137
137
  query_params = query_params.merge(parameters) unless parameters.nil?
138
138
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -176,7 +176,7 @@ module Algolia
176
176
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
177
177
  end
178
178
 
179
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
179
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
180
180
  query_params = {}
181
181
  query_params = query_params.merge(parameters) unless parameters.nil?
182
182
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -221,7 +221,7 @@ module Algolia
221
221
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
222
222
  end
223
223
 
224
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
224
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
225
225
  query_params = {}
226
226
  query_params = query_params.merge(parameters) unless parameters.nil?
227
227
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -41,7 +41,7 @@ module Algolia
41
41
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
42
42
  end
43
43
 
44
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
44
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
45
45
  query_params = {}
46
46
  query_params = query_params.merge(parameters) unless parameters.nil?
47
47
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -84,7 +84,7 @@ module Algolia
84
84
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
85
85
  end
86
86
 
87
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
87
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
88
88
  query_params = {}
89
89
  query_params = query_params.merge(parameters) unless parameters.nil?
90
90
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -128,7 +128,7 @@ module Algolia
128
128
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
129
129
  end
130
130
 
131
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
131
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
132
132
  query_params = {}
133
133
  query_params = query_params.merge(parameters) unless parameters.nil?
134
134
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -173,7 +173,7 @@ module Algolia
173
173
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
174
174
  end
175
175
 
176
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
176
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
177
177
  query_params = {}
178
178
  query_params = query_params.merge(parameters) unless parameters.nil?
179
179
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -580,7 +580,7 @@ module Algolia
580
580
  raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
581
581
  end
582
582
 
583
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
583
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
584
584
  query_params = {}
585
585
  query_params = query_params.merge(parameters) unless parameters.nil?
586
586
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -623,7 +623,7 @@ module Algolia
623
623
  raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
624
624
  end
625
625
 
626
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
626
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
627
627
  query_params = {}
628
628
  query_params = query_params.merge(parameters) unless parameters.nil?
629
629
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -667,7 +667,7 @@ module Algolia
667
667
  raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
668
668
  end
669
669
 
670
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
670
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
671
671
  query_params = {}
672
672
  query_params = query_params.merge(parameters) unless parameters.nil?
673
673
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -712,7 +712,7 @@ module Algolia
712
712
  raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
713
713
  end
714
714
 
715
- path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
715
+ path = '/{path}'.sub('{' + 'path' + '}', path.to_s)
716
716
  query_params = {}
717
717
  query_params = query_params.merge(parameters) unless parameters.nil?
718
718
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
@@ -5,7 +5,7 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Abtesting
8
- class CurrenciesValue
8
+ class Currency
9
9
  # Currency code.
10
10
  attr_accessor :currency
11
11
 
@@ -52,14 +52,14 @@ module Algolia
52
52
  # @param [Hash] attributes Model attributes in the form of hash
53
53
  def initialize(attributes = {})
54
54
  unless attributes.is_a?(Hash)
55
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::CurrenciesValue` initialize method"
55
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Currency` initialize method"
56
56
  end
57
57
 
58
58
  # check to see if the attribute exists and convert string to symbol for hash key
59
59
  attributes = attributes.each_with_object({}) do |(k, v), h|
60
60
  unless self.class.attribute_map.key?(k.to_sym)
61
61
  raise ArgumentError,
62
- "`#{k}` is not a valid attribute in `Algolia::CurrenciesValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ "`#{k}` is not a valid attribute in `Algolia::Currency`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
63
  end
64
64
 
65
65
  h[k.to_sym] = v
@@ -53,7 +53,7 @@ module Algolia
53
53
  # Number of searches carried out during the A/B test.
54
54
  attr_accessor :search_count
55
55
 
56
- # Number of tracked searches. This is the number of search requests where the `clickAnalytics` parameter is `true`.
56
+ # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
57
57
  attr_accessor :tracked_search_count
58
58
 
59
59
  # A/B test traffic percentage.
@@ -106,7 +106,7 @@ module Algolia
106
106
  :click_through_rate => :Float,
107
107
  :conversion_count => :Integer,
108
108
  :conversion_rate => :Float,
109
- :currencies => :'Hash<String, CurrenciesValue>',
109
+ :currencies => :'Hash<String, Currency>',
110
110
  :description => :String,
111
111
  :estimated_sample_size => :Integer,
112
112
  :filter_effects => :FilterEffects,
@@ -132,7 +132,6 @@ module Algolia
132
132
  :no_result_count,
133
133
  :purchase_rate,
134
134
  :search_count,
135
- :tracked_search_count,
136
135
  :user_count,
137
136
  :tracked_user_count
138
137
  ])
@@ -249,8 +248,6 @@ module Algolia
249
248
 
250
249
  if attributes.key?(:tracked_search_count)
251
250
  self.tracked_search_count = attributes[:tracked_search_count]
252
- else
253
- self.tracked_search_count = nil
254
251
  end
255
252
 
256
253
  if attributes.key?(:traffic_percentage)
@@ -0,0 +1,242 @@
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 Analytics
8
+ # Click position.
9
+ class ClickPositionsInner
10
+ # Range of positions in the search results, using the pattern `[start,end]`. For positions 11 and up, click events are summed over the specified range. `-1` indicates the end of the list of search results.
11
+ attr_accessor :position
12
+
13
+ # Number of times this search has been clicked at that position.
14
+ attr_accessor :click_count
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :position => :position,
20
+ :click_count => :clickCount
21
+ }
22
+ end
23
+
24
+ # Returns all the JSON keys this model knows about
25
+ def self.acceptable_attributes
26
+ attribute_map.values
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.types_mapping
31
+ {
32
+ :position => :'Array<Integer>',
33
+ :click_count => :Integer
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new([])
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ unless attributes.is_a?(Hash)
46
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::ClickPositionsInner` initialize method"
47
+ end
48
+
49
+ # check to see if the attribute exists and convert string to symbol for hash key
50
+ attributes = attributes.each_with_object({}) do |(k, v), h|
51
+ unless self.class.attribute_map.key?(k.to_sym)
52
+ raise ArgumentError,
53
+ "`#{k}` is not a valid attribute in `Algolia::ClickPositionsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
+ end
55
+
56
+ h[k.to_sym] = v
57
+ end
58
+
59
+ if attributes.key?(:position)
60
+ if (value = attributes[:position]).is_a?(Array)
61
+ self.position = value
62
+ end
63
+ end
64
+
65
+ if attributes.key?(:click_count)
66
+ self.click_count = attributes[:click_count]
67
+ end
68
+ end
69
+
70
+ # Custom attribute writer method with validation
71
+ # @param [Object] position Value to be assigned
72
+ def position=(position)
73
+ if position.nil?
74
+ raise ArgumentError, 'position cannot be nil'
75
+ end
76
+
77
+ if position.length > 2
78
+ raise ArgumentError, 'invalid value for "position", number of items must be less than or equal to 2.'
79
+ end
80
+
81
+ if position.length < 2
82
+ raise ArgumentError, 'invalid value for "position", number of items must be greater than or equal to 2.'
83
+ end
84
+
85
+ @position = position
86
+ end
87
+
88
+ # Custom attribute writer method with validation
89
+ # @param [Object] click_count Value to be assigned
90
+ def click_count=(click_count)
91
+ if click_count.nil?
92
+ raise ArgumentError, 'click_count cannot be nil'
93
+ end
94
+
95
+ if click_count < 0
96
+ raise ArgumentError, 'invalid value for "click_count", must be greater than or equal to 0.'
97
+ end
98
+
99
+ @click_count = click_count
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(other)
105
+ return true if equal?(other)
106
+
107
+ self.class == other.class &&
108
+ position == other.position &&
109
+ click_count == other.click_count
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(other)
115
+ self == other
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Integer] Hash code
120
+ def hash
121
+ [position, click_count].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def self.build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ transformed_hash = {}
132
+ types_mapping.each_pair do |key, type|
133
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
134
+ transformed_hash[key.to_sym] = nil
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[attribute_map[key]].is_a?(Array)
139
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
140
+ end
141
+ elsif !attributes[attribute_map[key]].nil?
142
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
143
+ end
144
+ end
145
+ new(transformed_hash)
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def self._deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = Algolia::Analytics.const_get(type)
187
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ def to_json(*_args)
204
+ to_hash.to_json
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+ end
241
+ end
242
+ end