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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/algolia/api/abtesting_client.rb +4 -4
- data/lib/algolia/api/analytics_client.rb +268 -98
- data/lib/algolia/api/ingestion_client.rb +4 -4
- data/lib/algolia/api/insights_client.rb +4 -4
- data/lib/algolia/api/monitoring_client.rb +4 -4
- data/lib/algolia/api/personalization_client.rb +4 -4
- data/lib/algolia/api/query_suggestions_client.rb +4 -4
- data/lib/algolia/api/recommend_client.rb +4 -4
- data/lib/algolia/api/search_client.rb +4 -4
- data/lib/algolia/models/abtesting/{currencies_value.rb → currency.rb} +3 -3
- data/lib/algolia/models/abtesting/variant.rb +2 -5
- data/lib/algolia/models/analytics/click_positions_inner.rb +242 -0
- data/lib/algolia/models/analytics/currencies_value.rb +208 -0
- data/lib/algolia/models/analytics/daily_add_to_cart_rates.rb +265 -0
- data/lib/algolia/models/analytics/daily_average_clicks.rb +249 -0
- data/lib/algolia/models/analytics/{click_through_rate_event.rb → daily_click_through_rates.rb} +24 -14
- data/lib/algolia/models/analytics/daily_conversion_rates.rb +265 -0
- data/lib/algolia/models/analytics/{no_click_rate_event.rb → daily_no_click_rates.rb} +21 -7
- data/lib/algolia/models/analytics/{no_results_rate_event.rb → daily_no_results_rates.rb} +7 -7
- data/lib/algolia/models/analytics/{conversion_rate_event.rb → daily_purchase_rates.rb} +18 -22
- data/lib/algolia/models/analytics/{average_click_event.rb → daily_revenue.rb} +15 -25
- data/lib/algolia/models/analytics/{search_event.rb → daily_searches.rb} +4 -4
- data/lib/algolia/models/analytics/{search_no_result_event.rb → daily_searches_no_clicks.rb} +19 -5
- data/lib/algolia/models/analytics/{search_no_click_event.rb → daily_searches_no_results.rb} +19 -5
- data/lib/algolia/models/analytics/{user_with_date.rb → daily_users.rb} +5 -5
- data/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb +267 -0
- data/lib/algolia/models/analytics/get_average_click_position_response.rb +31 -5
- data/lib/algolia/models/analytics/get_click_positions_response.rb +6 -6
- data/lib/algolia/models/analytics/get_click_through_rate_response.rb +22 -12
- data/lib/algolia/models/analytics/get_conversion_rate_response.rb +267 -0
- data/lib/algolia/models/analytics/get_no_click_rate_response.rb +19 -5
- data/lib/algolia/models/analytics/get_no_results_rate_response.rb +5 -5
- data/lib/algolia/models/analytics/{get_conversation_rate_response.rb → get_purchase_rate_response.rb} +19 -23
- data/lib/algolia/models/analytics/{click_position.rb → get_revenue.rb} +23 -21
- data/lib/algolia/models/analytics/get_searches_count_response.rb +2 -2
- data/lib/algolia/models/analytics/get_searches_no_clicks_response.rb +2 -2
- data/lib/algolia/models/analytics/get_searches_no_results_response.rb +2 -2
- data/lib/algolia/models/analytics/get_status_response.rb +4 -2
- data/lib/algolia/models/analytics/get_top_countries_response.rb +1 -1
- data/lib/algolia/models/analytics/get_top_filter_attributes_response.rb +1 -1
- data/lib/algolia/models/analytics/get_top_filter_for_attribute.rb +23 -2
- data/lib/algolia/models/analytics/get_top_filters_no_results_response.rb +4 -2
- data/lib/algolia/models/analytics/get_top_filters_no_results_value.rb +23 -2
- data/lib/algolia/models/analytics/get_top_hits_response.rb +2 -1
- data/lib/algolia/models/analytics/get_top_searches_response.rb +2 -1
- data/lib/algolia/models/analytics/get_users_count_response.rb +3 -3
- data/lib/algolia/models/analytics/operator.rb +38 -0
- data/lib/algolia/models/analytics/top_country.rb +1 -1
- data/lib/algolia/models/analytics/top_hit.rb +1 -1
- data/lib/algolia/models/analytics/top_hit_with_analytics.rb +60 -21
- data/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb +437 -0
- data/lib/algolia/models/analytics/top_hits_response.rb +1 -1
- data/lib/algolia/models/analytics/top_hits_response_with_analytics.rb +1 -1
- data/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb +201 -0
- data/lib/algolia/models/analytics/top_search.rb +2 -2
- data/lib/algolia/models/analytics/top_search_with_analytics.rb +99 -17
- data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +504 -0
- data/lib/algolia/models/analytics/top_searches_response.rb +1 -1
- data/lib/algolia/models/analytics/top_searches_response_with_analytics.rb +1 -1
- data/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb +201 -0
- data/lib/algolia/version.rb +1 -1
- metadata +26 -14
@@ -0,0 +1,437 @@
|
|
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 TopHitWithRevenueAnalytics
|
9
|
+
# Object ID of a record that's returned as a search result.
|
10
|
+
attr_accessor :hit
|
11
|
+
|
12
|
+
# Number of occurrences.
|
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
|
+
# 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.
|
19
|
+
attr_accessor :conversion_rate
|
20
|
+
|
21
|
+
# Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
|
22
|
+
attr_accessor :tracked_hit_count
|
23
|
+
|
24
|
+
# Number of clicks associated with this search.
|
25
|
+
attr_accessor :click_count
|
26
|
+
|
27
|
+
# Number of conversions from this search.
|
28
|
+
attr_accessor :conversion_count
|
29
|
+
|
30
|
+
# 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.
|
31
|
+
attr_accessor :add_to_cart_rate
|
32
|
+
|
33
|
+
# Number of add-to-cart events from this search.
|
34
|
+
attr_accessor :add_to_cart_count
|
35
|
+
|
36
|
+
# 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.
|
37
|
+
attr_accessor :purchase_rate
|
38
|
+
|
39
|
+
# Number of purchase events from this search.
|
40
|
+
attr_accessor :purchase_count
|
41
|
+
|
42
|
+
# Revenue associated with this search, broken-down by currencies.
|
43
|
+
attr_accessor :currencies
|
44
|
+
|
45
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
46
|
+
def self.attribute_map
|
47
|
+
{
|
48
|
+
:hit => :hit,
|
49
|
+
:count => :count,
|
50
|
+
:click_through_rate => :clickThroughRate,
|
51
|
+
:conversion_rate => :conversionRate,
|
52
|
+
:tracked_hit_count => :trackedHitCount,
|
53
|
+
:click_count => :clickCount,
|
54
|
+
:conversion_count => :conversionCount,
|
55
|
+
:add_to_cart_rate => :addToCartRate,
|
56
|
+
:add_to_cart_count => :addToCartCount,
|
57
|
+
:purchase_rate => :purchaseRate,
|
58
|
+
:purchase_count => :purchaseCount,
|
59
|
+
:currencies => :currencies
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns all the JSON keys this model knows about
|
64
|
+
def self.acceptable_attributes
|
65
|
+
attribute_map.values
|
66
|
+
end
|
67
|
+
|
68
|
+
# Attribute type mapping.
|
69
|
+
def self.types_mapping
|
70
|
+
{
|
71
|
+
:hit => :String,
|
72
|
+
:count => :Integer,
|
73
|
+
:click_through_rate => :Float,
|
74
|
+
:conversion_rate => :Float,
|
75
|
+
:tracked_hit_count => :Integer,
|
76
|
+
:click_count => :Integer,
|
77
|
+
:conversion_count => :Integer,
|
78
|
+
:add_to_cart_rate => :Float,
|
79
|
+
:add_to_cart_count => :Integer,
|
80
|
+
:purchase_rate => :Float,
|
81
|
+
:purchase_count => :Integer,
|
82
|
+
:currencies => :'Hash<String, CurrenciesValue>'
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
# List of attributes with nullable: true
|
87
|
+
def self.openapi_nullable
|
88
|
+
Set.new([
|
89
|
+
:click_through_rate,
|
90
|
+
:conversion_rate,
|
91
|
+
:add_to_cart_rate,
|
92
|
+
:purchase_rate
|
93
|
+
])
|
94
|
+
end
|
95
|
+
|
96
|
+
# Initializes the object
|
97
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
98
|
+
def initialize(attributes = {})
|
99
|
+
unless attributes.is_a?(Hash)
|
100
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TopHitWithRevenueAnalytics` initialize method"
|
101
|
+
end
|
102
|
+
|
103
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
104
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
105
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
106
|
+
raise ArgumentError,
|
107
|
+
"`#{k}` is not a valid attribute in `Algolia::TopHitWithRevenueAnalytics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
108
|
+
end
|
109
|
+
|
110
|
+
h[k.to_sym] = v
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:hit)
|
114
|
+
self.hit = attributes[:hit]
|
115
|
+
else
|
116
|
+
self.hit = nil
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:count)
|
120
|
+
self.count = attributes[:count]
|
121
|
+
else
|
122
|
+
self.count = nil
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:click_through_rate)
|
126
|
+
self.click_through_rate = attributes[:click_through_rate]
|
127
|
+
else
|
128
|
+
self.click_through_rate = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:conversion_rate)
|
132
|
+
self.conversion_rate = attributes[:conversion_rate]
|
133
|
+
else
|
134
|
+
self.conversion_rate = nil
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.key?(:tracked_hit_count)
|
138
|
+
self.tracked_hit_count = attributes[:tracked_hit_count]
|
139
|
+
else
|
140
|
+
self.tracked_hit_count = nil
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:click_count)
|
144
|
+
self.click_count = attributes[:click_count]
|
145
|
+
else
|
146
|
+
self.click_count = nil
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.key?(:conversion_count)
|
150
|
+
self.conversion_count = attributes[:conversion_count]
|
151
|
+
else
|
152
|
+
self.conversion_count = nil
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.key?(:add_to_cart_rate)
|
156
|
+
self.add_to_cart_rate = attributes[:add_to_cart_rate]
|
157
|
+
else
|
158
|
+
self.add_to_cart_rate = nil
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.key?(:add_to_cart_count)
|
162
|
+
self.add_to_cart_count = attributes[:add_to_cart_count]
|
163
|
+
else
|
164
|
+
self.add_to_cart_count = nil
|
165
|
+
end
|
166
|
+
|
167
|
+
if attributes.key?(:purchase_rate)
|
168
|
+
self.purchase_rate = attributes[:purchase_rate]
|
169
|
+
else
|
170
|
+
self.purchase_rate = nil
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.key?(:purchase_count)
|
174
|
+
self.purchase_count = attributes[:purchase_count]
|
175
|
+
else
|
176
|
+
self.purchase_count = nil
|
177
|
+
end
|
178
|
+
|
179
|
+
if attributes.key?(:currencies)
|
180
|
+
if (value = attributes[:currencies]).is_a?(Hash)
|
181
|
+
self.currencies = value
|
182
|
+
end
|
183
|
+
else
|
184
|
+
self.currencies = nil
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Custom attribute writer method with validation
|
189
|
+
# @param [Object] click_through_rate Value to be assigned
|
190
|
+
def click_through_rate=(click_through_rate)
|
191
|
+
if !click_through_rate.nil? && click_through_rate > 1
|
192
|
+
raise ArgumentError, 'invalid value for "click_through_rate", must be smaller than or equal to 1.'
|
193
|
+
end
|
194
|
+
|
195
|
+
if !click_through_rate.nil? && click_through_rate < 0
|
196
|
+
raise ArgumentError, 'invalid value for "click_through_rate", must be greater than or equal to 0.'
|
197
|
+
end
|
198
|
+
|
199
|
+
@click_through_rate = click_through_rate
|
200
|
+
end
|
201
|
+
|
202
|
+
# Custom attribute writer method with validation
|
203
|
+
# @param [Object] conversion_rate Value to be assigned
|
204
|
+
def conversion_rate=(conversion_rate)
|
205
|
+
if !conversion_rate.nil? && conversion_rate > 1
|
206
|
+
raise ArgumentError, 'invalid value for "conversion_rate", must be smaller than or equal to 1.'
|
207
|
+
end
|
208
|
+
|
209
|
+
if !conversion_rate.nil? && conversion_rate < 0
|
210
|
+
raise ArgumentError, 'invalid value for "conversion_rate", must be greater than or equal to 0.'
|
211
|
+
end
|
212
|
+
|
213
|
+
@conversion_rate = conversion_rate
|
214
|
+
end
|
215
|
+
|
216
|
+
# Custom attribute writer method with validation
|
217
|
+
# @param [Object] click_count Value to be assigned
|
218
|
+
def click_count=(click_count)
|
219
|
+
if click_count.nil?
|
220
|
+
raise ArgumentError, 'click_count cannot be nil'
|
221
|
+
end
|
222
|
+
|
223
|
+
if click_count < 0
|
224
|
+
raise ArgumentError, 'invalid value for "click_count", must be greater than or equal to 0.'
|
225
|
+
end
|
226
|
+
|
227
|
+
@click_count = click_count
|
228
|
+
end
|
229
|
+
|
230
|
+
# Custom attribute writer method with validation
|
231
|
+
# @param [Object] conversion_count Value to be assigned
|
232
|
+
def conversion_count=(conversion_count)
|
233
|
+
if conversion_count.nil?
|
234
|
+
raise ArgumentError, 'conversion_count cannot be nil'
|
235
|
+
end
|
236
|
+
|
237
|
+
if conversion_count < 0
|
238
|
+
raise ArgumentError, 'invalid value for "conversion_count", must be greater than or equal to 0.'
|
239
|
+
end
|
240
|
+
|
241
|
+
@conversion_count = conversion_count
|
242
|
+
end
|
243
|
+
|
244
|
+
# Custom attribute writer method with validation
|
245
|
+
# @param [Object] add_to_cart_rate Value to be assigned
|
246
|
+
def add_to_cart_rate=(add_to_cart_rate)
|
247
|
+
if !add_to_cart_rate.nil? && add_to_cart_rate > 1
|
248
|
+
raise ArgumentError, 'invalid value for "add_to_cart_rate", must be smaller than or equal to 1.'
|
249
|
+
end
|
250
|
+
|
251
|
+
if !add_to_cart_rate.nil? && add_to_cart_rate < 0
|
252
|
+
raise ArgumentError, 'invalid value for "add_to_cart_rate", must be greater than or equal to 0.'
|
253
|
+
end
|
254
|
+
|
255
|
+
@add_to_cart_rate = add_to_cart_rate
|
256
|
+
end
|
257
|
+
|
258
|
+
# Custom attribute writer method with validation
|
259
|
+
# @param [Object] add_to_cart_count Value to be assigned
|
260
|
+
def add_to_cart_count=(add_to_cart_count)
|
261
|
+
if add_to_cart_count.nil?
|
262
|
+
raise ArgumentError, 'add_to_cart_count cannot be nil'
|
263
|
+
end
|
264
|
+
|
265
|
+
if add_to_cart_count < 0
|
266
|
+
raise ArgumentError, 'invalid value for "add_to_cart_count", must be greater than or equal to 0.'
|
267
|
+
end
|
268
|
+
|
269
|
+
@add_to_cart_count = add_to_cart_count
|
270
|
+
end
|
271
|
+
|
272
|
+
# Custom attribute writer method with validation
|
273
|
+
# @param [Object] purchase_rate Value to be assigned
|
274
|
+
def purchase_rate=(purchase_rate)
|
275
|
+
if !purchase_rate.nil? && purchase_rate > 1
|
276
|
+
raise ArgumentError, 'invalid value for "purchase_rate", must be smaller than or equal to 1.'
|
277
|
+
end
|
278
|
+
|
279
|
+
if !purchase_rate.nil? && purchase_rate < 0
|
280
|
+
raise ArgumentError, 'invalid value for "purchase_rate", must be greater than or equal to 0.'
|
281
|
+
end
|
282
|
+
|
283
|
+
@purchase_rate = purchase_rate
|
284
|
+
end
|
285
|
+
|
286
|
+
# Checks equality by comparing each attribute.
|
287
|
+
# @param [Object] Object to be compared
|
288
|
+
def ==(other)
|
289
|
+
return true if equal?(other)
|
290
|
+
|
291
|
+
self.class == other.class &&
|
292
|
+
hit == other.hit &&
|
293
|
+
count == other.count &&
|
294
|
+
click_through_rate == other.click_through_rate &&
|
295
|
+
conversion_rate == other.conversion_rate &&
|
296
|
+
tracked_hit_count == other.tracked_hit_count &&
|
297
|
+
click_count == other.click_count &&
|
298
|
+
conversion_count == other.conversion_count &&
|
299
|
+
add_to_cart_rate == other.add_to_cart_rate &&
|
300
|
+
add_to_cart_count == other.add_to_cart_count &&
|
301
|
+
purchase_rate == other.purchase_rate &&
|
302
|
+
purchase_count == other.purchase_count &&
|
303
|
+
currencies == other.currencies
|
304
|
+
end
|
305
|
+
|
306
|
+
# @see the `==` method
|
307
|
+
# @param [Object] Object to be compared
|
308
|
+
def eql?(other)
|
309
|
+
self == other
|
310
|
+
end
|
311
|
+
|
312
|
+
# Calculates hash code according to all attributes.
|
313
|
+
# @return [Integer] Hash code
|
314
|
+
def hash
|
315
|
+
[hit, count, click_through_rate, conversion_rate, tracked_hit_count, click_count, conversion_count, add_to_cart_rate, add_to_cart_count, purchase_rate, purchase_count,
|
316
|
+
currencies].hash
|
317
|
+
end
|
318
|
+
|
319
|
+
# Builds the object from hash
|
320
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
321
|
+
# @return [Object] Returns the model itself
|
322
|
+
def self.build_from_hash(attributes)
|
323
|
+
return nil unless attributes.is_a?(Hash)
|
324
|
+
|
325
|
+
attributes = attributes.transform_keys(&:to_sym)
|
326
|
+
transformed_hash = {}
|
327
|
+
types_mapping.each_pair do |key, type|
|
328
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
329
|
+
transformed_hash[key.to_sym] = nil
|
330
|
+
elsif type =~ /\AArray<(.*)>/i
|
331
|
+
# check to ensure the input is an array given that the attribute
|
332
|
+
# is documented as an array but the input is not
|
333
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
334
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
335
|
+
end
|
336
|
+
elsif !attributes[attribute_map[key]].nil?
|
337
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
338
|
+
end
|
339
|
+
end
|
340
|
+
new(transformed_hash)
|
341
|
+
end
|
342
|
+
|
343
|
+
# Deserializes the data based on type
|
344
|
+
# @param string type Data type
|
345
|
+
# @param string value Value to be deserialized
|
346
|
+
# @return [Object] Deserialized data
|
347
|
+
def self._deserialize(type, value)
|
348
|
+
case type.to_sym
|
349
|
+
when :Time
|
350
|
+
Time.parse(value)
|
351
|
+
when :Date
|
352
|
+
Date.parse(value)
|
353
|
+
when :String
|
354
|
+
value.to_s
|
355
|
+
when :Integer
|
356
|
+
value.to_i
|
357
|
+
when :Float
|
358
|
+
value.to_f
|
359
|
+
when :Boolean
|
360
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
361
|
+
true
|
362
|
+
else
|
363
|
+
false
|
364
|
+
end
|
365
|
+
when :Object
|
366
|
+
# generic object (usually a Hash), return directly
|
367
|
+
value
|
368
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
369
|
+
inner_type = Regexp.last_match[:inner_type]
|
370
|
+
value.map { |v| _deserialize(inner_type, v) }
|
371
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
372
|
+
k_type = Regexp.last_match[:k_type]
|
373
|
+
v_type = Regexp.last_match[:v_type]
|
374
|
+
{}.tap do |hash|
|
375
|
+
value.each do |k, v|
|
376
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
else # model
|
380
|
+
# models (e.g. Pet) or oneOf
|
381
|
+
klass = Algolia::Analytics.const_get(type)
|
382
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
# Returns the string representation of the object
|
387
|
+
# @return [String] String presentation of the object
|
388
|
+
def to_s
|
389
|
+
to_hash.to_s
|
390
|
+
end
|
391
|
+
|
392
|
+
# to_body is an alias to to_hash (backward compatibility)
|
393
|
+
# @return [Hash] Returns the object in the form of hash
|
394
|
+
def to_body
|
395
|
+
to_hash
|
396
|
+
end
|
397
|
+
|
398
|
+
def to_json(*_args)
|
399
|
+
to_hash.to_json
|
400
|
+
end
|
401
|
+
|
402
|
+
# Returns the object in the form of hash
|
403
|
+
# @return [Hash] Returns the object in the form of hash
|
404
|
+
def to_hash
|
405
|
+
hash = {}
|
406
|
+
self.class.attribute_map.each_pair do |attr, param|
|
407
|
+
value = send(attr)
|
408
|
+
if value.nil?
|
409
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
410
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
411
|
+
end
|
412
|
+
|
413
|
+
hash[param] = _to_hash(value)
|
414
|
+
end
|
415
|
+
hash
|
416
|
+
end
|
417
|
+
|
418
|
+
# Outputs non-array value in the form of hash
|
419
|
+
# For object, use to_hash. Otherwise, just return the value
|
420
|
+
# @param [Object] value Any valid value
|
421
|
+
# @return [Hash] Returns the value in the form of hash
|
422
|
+
def _to_hash(value)
|
423
|
+
if value.is_a?(Array)
|
424
|
+
value.compact.map { |v| _to_hash(v) }
|
425
|
+
elsif value.is_a?(Hash)
|
426
|
+
{}.tap do |hash|
|
427
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
428
|
+
end
|
429
|
+
elsif value.respond_to? :to_hash
|
430
|
+
value.to_hash
|
431
|
+
else
|
432
|
+
value
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
@@ -0,0 +1,201 @@
|
|
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 TopHitsResponseWithRevenueAnalytics
|
9
|
+
# Most frequent search results with click, conversion, and revenue metrics.
|
10
|
+
attr_accessor :hits
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
:hits => :hits
|
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
|
+
:hits => :'Array<TopHitWithRevenueAnalytics>'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# List of attributes with nullable: true
|
32
|
+
def self.openapi_nullable
|
33
|
+
Set.new([])
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
unless attributes.is_a?(Hash)
|
40
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TopHitsResponseWithRevenueAnalytics` initialize method"
|
41
|
+
end
|
42
|
+
|
43
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
44
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
45
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
46
|
+
raise ArgumentError,
|
47
|
+
"`#{k}` is not a valid attribute in `Algolia::TopHitsResponseWithRevenueAnalytics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
48
|
+
end
|
49
|
+
|
50
|
+
h[k.to_sym] = v
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes.key?(:hits)
|
54
|
+
if (value = attributes[:hits]).is_a?(Array)
|
55
|
+
self.hits = value
|
56
|
+
end
|
57
|
+
else
|
58
|
+
self.hits = nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks equality by comparing each attribute.
|
63
|
+
# @param [Object] Object to be compared
|
64
|
+
def ==(other)
|
65
|
+
return true if equal?(other)
|
66
|
+
|
67
|
+
self.class == other.class &&
|
68
|
+
hits == other.hits
|
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
|
+
[hits].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
|
+
|
89
|
+
attributes = attributes.transform_keys(&:to_sym)
|
90
|
+
transformed_hash = {}
|
91
|
+
types_mapping.each_pair do |key, type|
|
92
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
93
|
+
transformed_hash[key.to_sym] = nil
|
94
|
+
elsif type =~ /\AArray<(.*)>/i
|
95
|
+
# check to ensure the input is an array given that the attribute
|
96
|
+
# is documented as an array but the input is not
|
97
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
98
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
99
|
+
end
|
100
|
+
elsif !attributes[attribute_map[key]].nil?
|
101
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
new(transformed_hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Deserializes the data based on type
|
108
|
+
# @param string type Data type
|
109
|
+
# @param string value Value to be deserialized
|
110
|
+
# @return [Object] Deserialized data
|
111
|
+
def self._deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :Time
|
114
|
+
Time.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :Boolean
|
124
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
when :Object
|
130
|
+
# generic object (usually a Hash), return directly
|
131
|
+
value
|
132
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
133
|
+
inner_type = Regexp.last_match[:inner_type]
|
134
|
+
value.map { |v| _deserialize(inner_type, v) }
|
135
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
136
|
+
k_type = Regexp.last_match[:k_type]
|
137
|
+
v_type = Regexp.last_match[:v_type]
|
138
|
+
{}.tap do |hash|
|
139
|
+
value.each do |k, v|
|
140
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
else # model
|
144
|
+
# models (e.g. Pet) or oneOf
|
145
|
+
klass = Algolia::Analytics.const_get(type)
|
146
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns the string representation of the object
|
151
|
+
# @return [String] String presentation of the object
|
152
|
+
def to_s
|
153
|
+
to_hash.to_s
|
154
|
+
end
|
155
|
+
|
156
|
+
# to_body is an alias to to_hash (backward compatibility)
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_body
|
159
|
+
to_hash
|
160
|
+
end
|
161
|
+
|
162
|
+
def to_json(*_args)
|
163
|
+
to_hash.to_json
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns the object in the form of hash
|
167
|
+
# @return [Hash] Returns the object in the form of hash
|
168
|
+
def to_hash
|
169
|
+
hash = {}
|
170
|
+
self.class.attribute_map.each_pair do |attr, param|
|
171
|
+
value = send(attr)
|
172
|
+
if value.nil?
|
173
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
174
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
175
|
+
end
|
176
|
+
|
177
|
+
hash[param] = _to_hash(value)
|
178
|
+
end
|
179
|
+
hash
|
180
|
+
end
|
181
|
+
|
182
|
+
# Outputs non-array value in the form of hash
|
183
|
+
# For object, use to_hash. Otherwise, just return the value
|
184
|
+
# @param [Object] value Any valid value
|
185
|
+
# @return [Hash] Returns the value in the form of hash
|
186
|
+
def _to_hash(value)
|
187
|
+
if value.is_a?(Array)
|
188
|
+
value.compact.map { |v| _to_hash(v) }
|
189
|
+
elsif value.is_a?(Hash)
|
190
|
+
{}.tap do |hash|
|
191
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
192
|
+
end
|
193
|
+
elsif value.respond_to? :to_hash
|
194
|
+
value.to_hash
|
195
|
+
else
|
196
|
+
value
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -6,10 +6,10 @@ require 'time'
|
|
6
6
|
module Algolia
|
7
7
|
module Analytics
|
8
8
|
class TopSearch
|
9
|
-
#
|
9
|
+
# Search query.
|
10
10
|
attr_accessor :search
|
11
11
|
|
12
|
-
# Number of
|
12
|
+
# Number of searches.
|
13
13
|
attr_accessor :count
|
14
14
|
|
15
15
|
# Number of results (hits).
|