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

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -6,28 +6,31 @@ require 'time'
6
6
  module Algolia
7
7
  module Analytics
8
8
  class TopSearchWithAnalytics
9
- # User query.
9
+ # Search query.
10
10
  attr_accessor :search
11
11
 
12
- # Number of tracked _and_ untracked searches (where the `clickAnalytics` parameter isn't `true`).
12
+ # Number of searches.
13
13
  attr_accessor :count
14
14
 
15
- # [Click-through rate (CTR)](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-through-rate).
15
+ # Click-through rate, calculated as number of tracked searches with at least one click event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
16
16
  attr_accessor :click_through_rate
17
17
 
18
- # Average [position](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-position) of clicked search result.
18
+ # Average position of a clicked search result in the list of search results. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
19
19
  attr_accessor :average_click_position
20
20
 
21
- # [Conversion rate (CR)](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#conversion-rate).
21
+ # List of positions in the search results and clicks associated with this search.
22
+ attr_accessor :click_positions
23
+
24
+ # Conversion rate, calculated as number of tracked searches with at least one conversion event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
22
25
  attr_accessor :conversion_rate
23
26
 
24
- # Number of tracked searches. This is the number of search requests where the `clickAnalytics` parameter is `true`.
27
+ # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
25
28
  attr_accessor :tracked_search_count
26
29
 
27
- # Number of click events.
30
+ # Number of clicks associated with this search.
28
31
  attr_accessor :click_count
29
32
 
30
- # Number of converted clicks.
33
+ # Number of conversions from this search.
31
34
  attr_accessor :conversion_count
32
35
 
33
36
  # Number of results (hits).
@@ -40,6 +43,7 @@ module Algolia
40
43
  :count => :count,
41
44
  :click_through_rate => :clickThroughRate,
42
45
  :average_click_position => :averageClickPosition,
46
+ :click_positions => :clickPositions,
43
47
  :conversion_rate => :conversionRate,
44
48
  :tracked_search_count => :trackedSearchCount,
45
49
  :click_count => :clickCount,
@@ -59,7 +63,8 @@ module Algolia
59
63
  :search => :String,
60
64
  :count => :Integer,
61
65
  :click_through_rate => :Float,
62
- :average_click_position => :Integer,
66
+ :average_click_position => :Float,
67
+ :click_positions => :'Array<ClickPositionsInner>',
63
68
  :conversion_rate => :Float,
64
69
  :tracked_search_count => :Integer,
65
70
  :click_count => :Integer,
@@ -71,7 +76,9 @@ module Algolia
71
76
  # List of attributes with nullable: true
72
77
  def self.openapi_nullable
73
78
  Set.new([
74
- :tracked_search_count
79
+ :click_through_rate,
80
+ :average_click_position,
81
+ :conversion_rate
75
82
  ])
76
83
  end
77
84
 
@@ -116,6 +123,14 @@ module Algolia
116
123
  self.average_click_position = nil
117
124
  end
118
125
 
126
+ if attributes.key?(:click_positions)
127
+ if (value = attributes[:click_positions]).is_a?(Array)
128
+ self.click_positions = value
129
+ end
130
+ else
131
+ self.click_positions = nil
132
+ end
133
+
119
134
  if attributes.key?(:conversion_rate)
120
135
  self.conversion_rate = attributes[:conversion_rate]
121
136
  else
@@ -150,21 +165,87 @@ module Algolia
150
165
  # Custom attribute writer method with validation
151
166
  # @param [Object] click_through_rate Value to be assigned
152
167
  def click_through_rate=(click_through_rate)
153
- if click_through_rate.nil?
154
- raise ArgumentError, 'click_through_rate cannot be nil'
155
- end
156
-
157
- if click_through_rate > 1
168
+ if !click_through_rate.nil? && click_through_rate > 1
158
169
  raise ArgumentError, 'invalid value for "click_through_rate", must be smaller than or equal to 1.'
159
170
  end
160
171
 
161
- if click_through_rate < 0
172
+ if !click_through_rate.nil? && click_through_rate < 0
162
173
  raise ArgumentError, 'invalid value for "click_through_rate", must be greater than or equal to 0.'
163
174
  end
164
175
 
165
176
  @click_through_rate = click_through_rate
166
177
  end
167
178
 
179
+ # Custom attribute writer method with validation
180
+ # @param [Object] average_click_position Value to be assigned
181
+ def average_click_position=(average_click_position)
182
+ if !average_click_position.nil? && average_click_position < 1
183
+ raise ArgumentError, 'invalid value for "average_click_position", must be greater than or equal to 1.'
184
+ end
185
+
186
+ @average_click_position = average_click_position
187
+ end
188
+
189
+ # Custom attribute writer method with validation
190
+ # @param [Object] click_positions Value to be assigned
191
+ def click_positions=(click_positions)
192
+ if click_positions.nil?
193
+ raise ArgumentError, 'click_positions cannot be nil'
194
+ end
195
+
196
+ if click_positions.length > 12
197
+ raise ArgumentError, 'invalid value for "click_positions", number of items must be less than or equal to 12.'
198
+ end
199
+
200
+ if click_positions.length < 12
201
+ raise ArgumentError, 'invalid value for "click_positions", number of items must be greater than or equal to 12.'
202
+ end
203
+
204
+ @click_positions = click_positions
205
+ end
206
+
207
+ # Custom attribute writer method with validation
208
+ # @param [Object] conversion_rate Value to be assigned
209
+ def conversion_rate=(conversion_rate)
210
+ if !conversion_rate.nil? && conversion_rate > 1
211
+ raise ArgumentError, 'invalid value for "conversion_rate", must be smaller than or equal to 1.'
212
+ end
213
+
214
+ if !conversion_rate.nil? && conversion_rate < 0
215
+ raise ArgumentError, 'invalid value for "conversion_rate", must be greater than or equal to 0.'
216
+ end
217
+
218
+ @conversion_rate = conversion_rate
219
+ end
220
+
221
+ # Custom attribute writer method with validation
222
+ # @param [Object] click_count Value to be assigned
223
+ def click_count=(click_count)
224
+ if click_count.nil?
225
+ raise ArgumentError, 'click_count cannot be nil'
226
+ end
227
+
228
+ if click_count < 0
229
+ raise ArgumentError, 'invalid value for "click_count", must be greater than or equal to 0.'
230
+ end
231
+
232
+ @click_count = click_count
233
+ end
234
+
235
+ # Custom attribute writer method with validation
236
+ # @param [Object] conversion_count Value to be assigned
237
+ def conversion_count=(conversion_count)
238
+ if conversion_count.nil?
239
+ raise ArgumentError, 'conversion_count cannot be nil'
240
+ end
241
+
242
+ if conversion_count < 0
243
+ raise ArgumentError, 'invalid value for "conversion_count", must be greater than or equal to 0.'
244
+ end
245
+
246
+ @conversion_count = conversion_count
247
+ end
248
+
168
249
  # Checks equality by comparing each attribute.
169
250
  # @param [Object] Object to be compared
170
251
  def ==(other)
@@ -175,6 +256,7 @@ module Algolia
175
256
  count == other.count &&
176
257
  click_through_rate == other.click_through_rate &&
177
258
  average_click_position == other.average_click_position &&
259
+ click_positions == other.click_positions &&
178
260
  conversion_rate == other.conversion_rate &&
179
261
  tracked_search_count == other.tracked_search_count &&
180
262
  click_count == other.click_count &&
@@ -191,7 +273,7 @@ module Algolia
191
273
  # Calculates hash code according to all attributes.
192
274
  # @return [Integer] Hash code
193
275
  def hash
194
- [search, count, click_through_rate, average_click_position, conversion_rate, tracked_search_count, click_count, conversion_count, nb_hits].hash
276
+ [search, count, click_through_rate, average_click_position, click_positions, conversion_rate, tracked_search_count, click_count, conversion_count, nb_hits].hash
195
277
  end
196
278
 
197
279
  # Builds the object from hash
@@ -0,0 +1,504 @@
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
+ class TopSearchWithRevenueAnalytics
9
+ # Search query.
10
+ attr_accessor :search
11
+
12
+ # Number of searches.
13
+ attr_accessor :count
14
+
15
+ # Click-through rate, calculated as number of tracked searches with at least one click event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
16
+ attr_accessor :click_through_rate
17
+
18
+ # Average position of a clicked search result in the list of search results. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
19
+ attr_accessor :average_click_position
20
+
21
+ # List of positions in the search results and clicks associated with this search.
22
+ attr_accessor :click_positions
23
+
24
+ # Conversion rate, calculated as number of tracked searches with at least one conversion event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
25
+ attr_accessor :conversion_rate
26
+
27
+ # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
28
+ attr_accessor :tracked_search_count
29
+
30
+ # Number of clicks associated with this search.
31
+ attr_accessor :click_count
32
+
33
+ # Number of conversions from this search.
34
+ attr_accessor :conversion_count
35
+
36
+ # Number of results (hits).
37
+ attr_accessor :nb_hits
38
+
39
+ # Revenue associated with this search, broken-down by currencies.
40
+ attr_accessor :currencies
41
+
42
+ # Add-to-cart rate, calculated as number of tracked searches with at least one add-to-cart event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
43
+ attr_accessor :add_to_cart_rate
44
+
45
+ # Number of add-to-cart events from this search.
46
+ attr_accessor :add_to_cart_count
47
+
48
+ # Purchase rate, calculated as number of tracked searches with at least one purchase event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
49
+ attr_accessor :purchase_rate
50
+
51
+ # Number of purchase events from this search.
52
+ attr_accessor :purchase_count
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :search => :search,
58
+ :count => :count,
59
+ :click_through_rate => :clickThroughRate,
60
+ :average_click_position => :averageClickPosition,
61
+ :click_positions => :clickPositions,
62
+ :conversion_rate => :conversionRate,
63
+ :tracked_search_count => :trackedSearchCount,
64
+ :click_count => :clickCount,
65
+ :conversion_count => :conversionCount,
66
+ :nb_hits => :nbHits,
67
+ :currencies => :currencies,
68
+ :add_to_cart_rate => :addToCartRate,
69
+ :add_to_cart_count => :addToCartCount,
70
+ :purchase_rate => :purchaseRate,
71
+ :purchase_count => :purchaseCount
72
+ }
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.types_mapping
82
+ {
83
+ :search => :String,
84
+ :count => :Integer,
85
+ :click_through_rate => :Float,
86
+ :average_click_position => :Float,
87
+ :click_positions => :'Array<ClickPositionsInner>',
88
+ :conversion_rate => :Float,
89
+ :tracked_search_count => :Integer,
90
+ :click_count => :Integer,
91
+ :conversion_count => :Integer,
92
+ :nb_hits => :Integer,
93
+ :currencies => :'Hash<String, CurrenciesValue>',
94
+ :add_to_cart_rate => :Float,
95
+ :add_to_cart_count => :Integer,
96
+ :purchase_rate => :Float,
97
+ :purchase_count => :Integer
98
+ }
99
+ end
100
+
101
+ # List of attributes with nullable: true
102
+ def self.openapi_nullable
103
+ Set.new([
104
+ :click_through_rate,
105
+ :average_click_position,
106
+ :conversion_rate,
107
+ :add_to_cart_rate,
108
+ :purchase_rate
109
+ ])
110
+ end
111
+
112
+ # Initializes the object
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ def initialize(attributes = {})
115
+ unless attributes.is_a?(Hash)
116
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TopSearchWithRevenueAnalytics` initialize method"
117
+ end
118
+
119
+ # check to see if the attribute exists and convert string to symbol for hash key
120
+ attributes = attributes.each_with_object({}) do |(k, v), h|
121
+ unless self.class.attribute_map.key?(k.to_sym)
122
+ raise ArgumentError,
123
+ "`#{k}` is not a valid attribute in `Algolia::TopSearchWithRevenueAnalytics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
124
+ end
125
+
126
+ h[k.to_sym] = v
127
+ end
128
+
129
+ if attributes.key?(:search)
130
+ self.search = attributes[:search]
131
+ else
132
+ self.search = nil
133
+ end
134
+
135
+ if attributes.key?(:count)
136
+ self.count = attributes[:count]
137
+ else
138
+ self.count = nil
139
+ end
140
+
141
+ if attributes.key?(:click_through_rate)
142
+ self.click_through_rate = attributes[:click_through_rate]
143
+ else
144
+ self.click_through_rate = nil
145
+ end
146
+
147
+ if attributes.key?(:average_click_position)
148
+ self.average_click_position = attributes[:average_click_position]
149
+ else
150
+ self.average_click_position = nil
151
+ end
152
+
153
+ if attributes.key?(:click_positions)
154
+ if (value = attributes[:click_positions]).is_a?(Array)
155
+ self.click_positions = value
156
+ end
157
+ else
158
+ self.click_positions = nil
159
+ end
160
+
161
+ if attributes.key?(:conversion_rate)
162
+ self.conversion_rate = attributes[:conversion_rate]
163
+ else
164
+ self.conversion_rate = nil
165
+ end
166
+
167
+ if attributes.key?(:tracked_search_count)
168
+ self.tracked_search_count = attributes[:tracked_search_count]
169
+ else
170
+ self.tracked_search_count = nil
171
+ end
172
+
173
+ if attributes.key?(:click_count)
174
+ self.click_count = attributes[:click_count]
175
+ else
176
+ self.click_count = nil
177
+ end
178
+
179
+ if attributes.key?(:conversion_count)
180
+ self.conversion_count = attributes[:conversion_count]
181
+ else
182
+ self.conversion_count = nil
183
+ end
184
+
185
+ if attributes.key?(:nb_hits)
186
+ self.nb_hits = attributes[:nb_hits]
187
+ else
188
+ self.nb_hits = nil
189
+ end
190
+
191
+ if attributes.key?(:currencies)
192
+ if (value = attributes[:currencies]).is_a?(Hash)
193
+ self.currencies = value
194
+ end
195
+ else
196
+ self.currencies = nil
197
+ end
198
+
199
+ if attributes.key?(:add_to_cart_rate)
200
+ self.add_to_cart_rate = attributes[:add_to_cart_rate]
201
+ else
202
+ self.add_to_cart_rate = nil
203
+ end
204
+
205
+ if attributes.key?(:add_to_cart_count)
206
+ self.add_to_cart_count = attributes[:add_to_cart_count]
207
+ else
208
+ self.add_to_cart_count = nil
209
+ end
210
+
211
+ if attributes.key?(:purchase_rate)
212
+ self.purchase_rate = attributes[:purchase_rate]
213
+ else
214
+ self.purchase_rate = nil
215
+ end
216
+
217
+ if attributes.key?(:purchase_count)
218
+ self.purchase_count = attributes[:purchase_count]
219
+ else
220
+ self.purchase_count = nil
221
+ end
222
+ end
223
+
224
+ # Custom attribute writer method with validation
225
+ # @param [Object] click_through_rate Value to be assigned
226
+ def click_through_rate=(click_through_rate)
227
+ if !click_through_rate.nil? && click_through_rate > 1
228
+ raise ArgumentError, 'invalid value for "click_through_rate", must be smaller than or equal to 1.'
229
+ end
230
+
231
+ if !click_through_rate.nil? && click_through_rate < 0
232
+ raise ArgumentError, 'invalid value for "click_through_rate", must be greater than or equal to 0.'
233
+ end
234
+
235
+ @click_through_rate = click_through_rate
236
+ end
237
+
238
+ # Custom attribute writer method with validation
239
+ # @param [Object] average_click_position Value to be assigned
240
+ def average_click_position=(average_click_position)
241
+ if !average_click_position.nil? && average_click_position < 1
242
+ raise ArgumentError, 'invalid value for "average_click_position", must be greater than or equal to 1.'
243
+ end
244
+
245
+ @average_click_position = average_click_position
246
+ end
247
+
248
+ # Custom attribute writer method with validation
249
+ # @param [Object] click_positions Value to be assigned
250
+ def click_positions=(click_positions)
251
+ if click_positions.nil?
252
+ raise ArgumentError, 'click_positions cannot be nil'
253
+ end
254
+
255
+ if click_positions.length > 12
256
+ raise ArgumentError, 'invalid value for "click_positions", number of items must be less than or equal to 12.'
257
+ end
258
+
259
+ if click_positions.length < 12
260
+ raise ArgumentError, 'invalid value for "click_positions", number of items must be greater than or equal to 12.'
261
+ end
262
+
263
+ @click_positions = click_positions
264
+ end
265
+
266
+ # Custom attribute writer method with validation
267
+ # @param [Object] conversion_rate Value to be assigned
268
+ def conversion_rate=(conversion_rate)
269
+ if !conversion_rate.nil? && conversion_rate > 1
270
+ raise ArgumentError, 'invalid value for "conversion_rate", must be smaller than or equal to 1.'
271
+ end
272
+
273
+ if !conversion_rate.nil? && conversion_rate < 0
274
+ raise ArgumentError, 'invalid value for "conversion_rate", must be greater than or equal to 0.'
275
+ end
276
+
277
+ @conversion_rate = conversion_rate
278
+ end
279
+
280
+ # Custom attribute writer method with validation
281
+ # @param [Object] click_count Value to be assigned
282
+ def click_count=(click_count)
283
+ if click_count.nil?
284
+ raise ArgumentError, 'click_count cannot be nil'
285
+ end
286
+
287
+ if click_count < 0
288
+ raise ArgumentError, 'invalid value for "click_count", must be greater than or equal to 0.'
289
+ end
290
+
291
+ @click_count = click_count
292
+ end
293
+
294
+ # Custom attribute writer method with validation
295
+ # @param [Object] conversion_count Value to be assigned
296
+ def conversion_count=(conversion_count)
297
+ if conversion_count.nil?
298
+ raise ArgumentError, 'conversion_count cannot be nil'
299
+ end
300
+
301
+ if conversion_count < 0
302
+ raise ArgumentError, 'invalid value for "conversion_count", must be greater than or equal to 0.'
303
+ end
304
+
305
+ @conversion_count = conversion_count
306
+ end
307
+
308
+ # Custom attribute writer method with validation
309
+ # @param [Object] add_to_cart_rate Value to be assigned
310
+ def add_to_cart_rate=(add_to_cart_rate)
311
+ if !add_to_cart_rate.nil? && add_to_cart_rate > 1
312
+ raise ArgumentError, 'invalid value for "add_to_cart_rate", must be smaller than or equal to 1.'
313
+ end
314
+
315
+ if !add_to_cart_rate.nil? && add_to_cart_rate < 0
316
+ raise ArgumentError, 'invalid value for "add_to_cart_rate", must be greater than or equal to 0.'
317
+ end
318
+
319
+ @add_to_cart_rate = add_to_cart_rate
320
+ end
321
+
322
+ # Custom attribute writer method with validation
323
+ # @param [Object] add_to_cart_count Value to be assigned
324
+ def add_to_cart_count=(add_to_cart_count)
325
+ if add_to_cart_count.nil?
326
+ raise ArgumentError, 'add_to_cart_count cannot be nil'
327
+ end
328
+
329
+ if add_to_cart_count < 0
330
+ raise ArgumentError, 'invalid value for "add_to_cart_count", must be greater than or equal to 0.'
331
+ end
332
+
333
+ @add_to_cart_count = add_to_cart_count
334
+ end
335
+
336
+ # Custom attribute writer method with validation
337
+ # @param [Object] purchase_rate Value to be assigned
338
+ def purchase_rate=(purchase_rate)
339
+ if !purchase_rate.nil? && purchase_rate > 1
340
+ raise ArgumentError, 'invalid value for "purchase_rate", must be smaller than or equal to 1.'
341
+ end
342
+
343
+ if !purchase_rate.nil? && purchase_rate < 0
344
+ raise ArgumentError, 'invalid value for "purchase_rate", must be greater than or equal to 0.'
345
+ end
346
+
347
+ @purchase_rate = purchase_rate
348
+ end
349
+
350
+ # Checks equality by comparing each attribute.
351
+ # @param [Object] Object to be compared
352
+ def ==(other)
353
+ return true if equal?(other)
354
+
355
+ self.class == other.class &&
356
+ search == other.search &&
357
+ count == other.count &&
358
+ click_through_rate == other.click_through_rate &&
359
+ average_click_position == other.average_click_position &&
360
+ click_positions == other.click_positions &&
361
+ conversion_rate == other.conversion_rate &&
362
+ tracked_search_count == other.tracked_search_count &&
363
+ click_count == other.click_count &&
364
+ conversion_count == other.conversion_count &&
365
+ nb_hits == other.nb_hits &&
366
+ currencies == other.currencies &&
367
+ add_to_cart_rate == other.add_to_cart_rate &&
368
+ add_to_cart_count == other.add_to_cart_count &&
369
+ purchase_rate == other.purchase_rate &&
370
+ purchase_count == other.purchase_count
371
+ end
372
+
373
+ # @see the `==` method
374
+ # @param [Object] Object to be compared
375
+ def eql?(other)
376
+ self == other
377
+ end
378
+
379
+ # Calculates hash code according to all attributes.
380
+ # @return [Integer] Hash code
381
+ def hash
382
+ [search, count, click_through_rate, average_click_position, click_positions, conversion_rate, tracked_search_count, click_count, conversion_count, nb_hits, currencies,
383
+ add_to_cart_rate, add_to_cart_count, purchase_rate, purchase_count].hash
384
+ end
385
+
386
+ # Builds the object from hash
387
+ # @param [Hash] attributes Model attributes in the form of hash
388
+ # @return [Object] Returns the model itself
389
+ def self.build_from_hash(attributes)
390
+ return nil unless attributes.is_a?(Hash)
391
+
392
+ attributes = attributes.transform_keys(&:to_sym)
393
+ transformed_hash = {}
394
+ types_mapping.each_pair do |key, type|
395
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
396
+ transformed_hash[key.to_sym] = nil
397
+ elsif type =~ /\AArray<(.*)>/i
398
+ # check to ensure the input is an array given that the attribute
399
+ # is documented as an array but the input is not
400
+ if attributes[attribute_map[key]].is_a?(Array)
401
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
402
+ end
403
+ elsif !attributes[attribute_map[key]].nil?
404
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
405
+ end
406
+ end
407
+ new(transformed_hash)
408
+ end
409
+
410
+ # Deserializes the data based on type
411
+ # @param string type Data type
412
+ # @param string value Value to be deserialized
413
+ # @return [Object] Deserialized data
414
+ def self._deserialize(type, value)
415
+ case type.to_sym
416
+ when :Time
417
+ Time.parse(value)
418
+ when :Date
419
+ Date.parse(value)
420
+ when :String
421
+ value.to_s
422
+ when :Integer
423
+ value.to_i
424
+ when :Float
425
+ value.to_f
426
+ when :Boolean
427
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
428
+ true
429
+ else
430
+ false
431
+ end
432
+ when :Object
433
+ # generic object (usually a Hash), return directly
434
+ value
435
+ when /\AArray<(?<inner_type>.+)>\z/
436
+ inner_type = Regexp.last_match[:inner_type]
437
+ value.map { |v| _deserialize(inner_type, v) }
438
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
439
+ k_type = Regexp.last_match[:k_type]
440
+ v_type = Regexp.last_match[:v_type]
441
+ {}.tap do |hash|
442
+ value.each do |k, v|
443
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
444
+ end
445
+ end
446
+ else # model
447
+ # models (e.g. Pet) or oneOf
448
+ klass = Algolia::Analytics.const_get(type)
449
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
450
+ end
451
+ end
452
+
453
+ # Returns the string representation of the object
454
+ # @return [String] String presentation of the object
455
+ def to_s
456
+ to_hash.to_s
457
+ end
458
+
459
+ # to_body is an alias to to_hash (backward compatibility)
460
+ # @return [Hash] Returns the object in the form of hash
461
+ def to_body
462
+ to_hash
463
+ end
464
+
465
+ def to_json(*_args)
466
+ to_hash.to_json
467
+ end
468
+
469
+ # Returns the object in the form of hash
470
+ # @return [Hash] Returns the object in the form of hash
471
+ def to_hash
472
+ hash = {}
473
+ self.class.attribute_map.each_pair do |attr, param|
474
+ value = send(attr)
475
+ if value.nil?
476
+ is_nullable = self.class.openapi_nullable.include?(attr)
477
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
478
+ end
479
+
480
+ hash[param] = _to_hash(value)
481
+ end
482
+ hash
483
+ end
484
+
485
+ # Outputs non-array value in the form of hash
486
+ # For object, use to_hash. Otherwise, just return the value
487
+ # @param [Object] value Any valid value
488
+ # @return [Hash] Returns the value in the form of hash
489
+ def _to_hash(value)
490
+ if value.is_a?(Array)
491
+ value.compact.map { |v| _to_hash(v) }
492
+ elsif value.is_a?(Hash)
493
+ {}.tap do |hash|
494
+ value.each { |k, v| hash[k] = _to_hash(v) }
495
+ end
496
+ elsif value.respond_to? :to_hash
497
+ value.to_hash
498
+ else
499
+ value
500
+ end
501
+ end
502
+ end
503
+ end
504
+ end