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
@@ -0,0 +1,249 @@
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 DailyAverageClicks
9
+ # 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.
10
+ attr_accessor :average
11
+
12
+ # Number of clicks associated with this search.
13
+ attr_accessor :click_count
14
+
15
+ # Date in the format YYYY-MM-DD.
16
+ attr_accessor :date
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :average => :average,
22
+ :click_count => :clickCount,
23
+ :date => :date
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.types_mapping
34
+ {
35
+ :average => :Float,
36
+ :click_count => :Integer,
37
+ :date => :String
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ :average
45
+ ])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ unless attributes.is_a?(Hash)
52
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DailyAverageClicks` initialize method"
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) do |(k, v), h|
57
+ unless self.class.attribute_map.key?(k.to_sym)
58
+ raise ArgumentError,
59
+ "`#{k}` is not a valid attribute in `Algolia::DailyAverageClicks`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+
62
+ h[k.to_sym] = v
63
+ end
64
+
65
+ if attributes.key?(:average)
66
+ self.average = attributes[:average]
67
+ else
68
+ self.average = nil
69
+ end
70
+
71
+ if attributes.key?(:click_count)
72
+ self.click_count = attributes[:click_count]
73
+ else
74
+ self.click_count = nil
75
+ end
76
+
77
+ if attributes.key?(:date)
78
+ self.date = attributes[:date]
79
+ else
80
+ self.date = nil
81
+ end
82
+ end
83
+
84
+ # Custom attribute writer method with validation
85
+ # @param [Object] average Value to be assigned
86
+ def average=(average)
87
+ if !average.nil? && average < 1
88
+ raise ArgumentError, 'invalid value for "average", must be greater than or equal to 1.'
89
+ end
90
+
91
+ @average = average
92
+ end
93
+
94
+ # Custom attribute writer method with validation
95
+ # @param [Object] click_count Value to be assigned
96
+ def click_count=(click_count)
97
+ if click_count.nil?
98
+ raise ArgumentError, 'click_count cannot be nil'
99
+ end
100
+
101
+ if click_count < 0
102
+ raise ArgumentError, 'invalid value for "click_count", must be greater than or equal to 0.'
103
+ end
104
+
105
+ @click_count = click_count
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(other)
111
+ return true if equal?(other)
112
+
113
+ self.class == other.class &&
114
+ average == other.average &&
115
+ click_count == other.click_count &&
116
+ date == other.date
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(other)
122
+ self == other
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [average, click_count, date].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+
137
+ attributes = attributes.transform_keys(&:to_sym)
138
+ transformed_hash = {}
139
+ types_mapping.each_pair do |key, type|
140
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
141
+ transformed_hash[key.to_sym] = nil
142
+ elsif type =~ /\AArray<(.*)>/i
143
+ # check to ensure the input is an array given that the attribute
144
+ # is documented as an array but the input is not
145
+ if attributes[attribute_map[key]].is_a?(Array)
146
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
147
+ end
148
+ elsif !attributes[attribute_map[key]].nil?
149
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
150
+ end
151
+ end
152
+ new(transformed_hash)
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def self._deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Algolia::Analytics.const_get(type)
194
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ def to_json(*_args)
211
+ to_hash.to_json
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+ end
248
+ end
249
+ end
@@ -5,17 +5,17 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Analytics
8
- class ClickThroughRateEvent
9
- # [Click-through rate (CTR)](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-through-rate).
8
+ class DailyClickThroughRates
9
+ # 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.
10
10
  attr_accessor :rate
11
11
 
12
- # Number of click events.
12
+ # Number of clicks associated with this search.
13
13
  attr_accessor :click_count
14
14
 
15
- # Number of tracked searches. This is the number of search requests where the `clickAnalytics` parameter is `true`.
15
+ # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
16
16
  attr_accessor :tracked_search_count
17
17
 
18
- # Date of the event in the format YYYY-MM-DD.
18
+ # Date in the format YYYY-MM-DD.
19
19
  attr_accessor :date
20
20
 
21
21
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -46,7 +46,7 @@ module Algolia
46
46
  # List of attributes with nullable: true
47
47
  def self.openapi_nullable
48
48
  Set.new([
49
- :tracked_search_count
49
+ :rate
50
50
  ])
51
51
  end
52
52
 
@@ -54,14 +54,14 @@ module Algolia
54
54
  # @param [Hash] attributes Model attributes in the form of hash
55
55
  def initialize(attributes = {})
56
56
  unless attributes.is_a?(Hash)
57
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::ClickThroughRateEvent` initialize method"
57
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DailyClickThroughRates` initialize method"
58
58
  end
59
59
 
60
60
  # check to see if the attribute exists and convert string to symbol for hash key
61
61
  attributes = attributes.each_with_object({}) do |(k, v), h|
62
62
  unless self.class.attribute_map.key?(k.to_sym)
63
63
  raise ArgumentError,
64
- "`#{k}` is not a valid attribute in `Algolia::ClickThroughRateEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ "`#{k}` is not a valid attribute in `Algolia::DailyClickThroughRates`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
65
  end
66
66
 
67
67
  h[k.to_sym] = v
@@ -95,21 +95,31 @@ module Algolia
95
95
  # Custom attribute writer method with validation
96
96
  # @param [Object] rate Value to be assigned
97
97
  def rate=(rate)
98
- if rate.nil?
99
- raise ArgumentError, 'rate cannot be nil'
100
- end
101
-
102
- if rate > 1
98
+ if !rate.nil? && rate > 1
103
99
  raise ArgumentError, 'invalid value for "rate", must be smaller than or equal to 1.'
104
100
  end
105
101
 
106
- if rate < 0
102
+ if !rate.nil? && rate < 0
107
103
  raise ArgumentError, 'invalid value for "rate", must be greater than or equal to 0.'
108
104
  end
109
105
 
110
106
  @rate = rate
111
107
  end
112
108
 
109
+ # Custom attribute writer method with validation
110
+ # @param [Object] click_count Value to be assigned
111
+ def click_count=(click_count)
112
+ if click_count.nil?
113
+ raise ArgumentError, 'click_count cannot be nil'
114
+ end
115
+
116
+ if click_count < 0
117
+ raise ArgumentError, 'invalid value for "click_count", must be greater than or equal to 0.'
118
+ end
119
+
120
+ @click_count = click_count
121
+ end
122
+
113
123
  # Checks equality by comparing each attribute.
114
124
  # @param [Object] Object to be compared
115
125
  def ==(other)
@@ -0,0 +1,265 @@
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 DailyConversionRates
9
+ # 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.
10
+ attr_accessor :rate
11
+
12
+ # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
13
+ attr_accessor :tracked_search_count
14
+
15
+ # Number of conversions from this search.
16
+ attr_accessor :conversion_count
17
+
18
+ # Date in the format YYYY-MM-DD.
19
+ attr_accessor :date
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :rate => :rate,
25
+ :tracked_search_count => :trackedSearchCount,
26
+ :conversion_count => :conversionCount,
27
+ :date => :date
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.types_mapping
38
+ {
39
+ :rate => :Float,
40
+ :tracked_search_count => :Integer,
41
+ :conversion_count => :Integer,
42
+ :date => :String
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ :rate
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ unless attributes.is_a?(Hash)
57
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DailyConversionRates` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) do |(k, v), h|
62
+ unless self.class.attribute_map.key?(k.to_sym)
63
+ raise ArgumentError,
64
+ "`#{k}` is not a valid attribute in `Algolia::DailyConversionRates`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+
67
+ h[k.to_sym] = v
68
+ end
69
+
70
+ if attributes.key?(:rate)
71
+ self.rate = attributes[:rate]
72
+ else
73
+ self.rate = nil
74
+ end
75
+
76
+ if attributes.key?(:tracked_search_count)
77
+ self.tracked_search_count = attributes[:tracked_search_count]
78
+ else
79
+ self.tracked_search_count = nil
80
+ end
81
+
82
+ if attributes.key?(:conversion_count)
83
+ self.conversion_count = attributes[:conversion_count]
84
+ else
85
+ self.conversion_count = nil
86
+ end
87
+
88
+ if attributes.key?(:date)
89
+ self.date = attributes[:date]
90
+ else
91
+ self.date = nil
92
+ end
93
+ end
94
+
95
+ # Custom attribute writer method with validation
96
+ # @param [Object] rate Value to be assigned
97
+ def rate=(rate)
98
+ if !rate.nil? && rate > 1
99
+ raise ArgumentError, 'invalid value for "rate", must be smaller than or equal to 1.'
100
+ end
101
+
102
+ if !rate.nil? && rate < 0
103
+ raise ArgumentError, 'invalid value for "rate", must be greater than or equal to 0.'
104
+ end
105
+
106
+ @rate = rate
107
+ end
108
+
109
+ # Custom attribute writer method with validation
110
+ # @param [Object] conversion_count Value to be assigned
111
+ def conversion_count=(conversion_count)
112
+ if conversion_count.nil?
113
+ raise ArgumentError, 'conversion_count cannot be nil'
114
+ end
115
+
116
+ if conversion_count < 0
117
+ raise ArgumentError, 'invalid value for "conversion_count", must be greater than or equal to 0.'
118
+ end
119
+
120
+ @conversion_count = conversion_count
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(other)
126
+ return true if equal?(other)
127
+
128
+ self.class == other.class &&
129
+ rate == other.rate &&
130
+ tracked_search_count == other.tracked_search_count &&
131
+ conversion_count == other.conversion_count &&
132
+ date == other.date
133
+ end
134
+
135
+ # @see the `==` method
136
+ # @param [Object] Object to be compared
137
+ def eql?(other)
138
+ self == other
139
+ end
140
+
141
+ # Calculates hash code according to all attributes.
142
+ # @return [Integer] Hash code
143
+ def hash
144
+ [rate, tracked_search_count, conversion_count, date].hash
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def self.build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+
153
+ attributes = attributes.transform_keys(&:to_sym)
154
+ transformed_hash = {}
155
+ types_mapping.each_pair do |key, type|
156
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
157
+ transformed_hash[key.to_sym] = nil
158
+ elsif type =~ /\AArray<(.*)>/i
159
+ # check to ensure the input is an array given that the attribute
160
+ # is documented as an array but the input is not
161
+ if attributes[attribute_map[key]].is_a?(Array)
162
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
163
+ end
164
+ elsif !attributes[attribute_map[key]].nil?
165
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
166
+ end
167
+ end
168
+ new(transformed_hash)
169
+ end
170
+
171
+ # Deserializes the data based on type
172
+ # @param string type Data type
173
+ # @param string value Value to be deserialized
174
+ # @return [Object] Deserialized data
175
+ def self._deserialize(type, value)
176
+ case type.to_sym
177
+ when :Time
178
+ Time.parse(value)
179
+ when :Date
180
+ Date.parse(value)
181
+ when :String
182
+ value.to_s
183
+ when :Integer
184
+ value.to_i
185
+ when :Float
186
+ value.to_f
187
+ when :Boolean
188
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
+ true
190
+ else
191
+ false
192
+ end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
196
+ when /\AArray<(?<inner_type>.+)>\z/
197
+ inner_type = Regexp.last_match[:inner_type]
198
+ value.map { |v| _deserialize(inner_type, v) }
199
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
+ k_type = Regexp.last_match[:k_type]
201
+ v_type = Regexp.last_match[:v_type]
202
+ {}.tap do |hash|
203
+ value.each do |k, v|
204
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
+ end
206
+ end
207
+ else # model
208
+ # models (e.g. Pet) or oneOf
209
+ klass = Algolia::Analytics.const_get(type)
210
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
211
+ end
212
+ end
213
+
214
+ # Returns the string representation of the object
215
+ # @return [String] String presentation of the object
216
+ def to_s
217
+ to_hash.to_s
218
+ end
219
+
220
+ # to_body is an alias to to_hash (backward compatibility)
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_body
223
+ to_hash
224
+ end
225
+
226
+ def to_json(*_args)
227
+ to_hash.to_json
228
+ end
229
+
230
+ # Returns the object in the form of hash
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_hash
233
+ hash = {}
234
+ self.class.attribute_map.each_pair do |attr, param|
235
+ value = send(attr)
236
+ if value.nil?
237
+ is_nullable = self.class.openapi_nullable.include?(attr)
238
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
239
+ end
240
+
241
+ hash[param] = _to_hash(value)
242
+ end
243
+ hash
244
+ end
245
+
246
+ # Outputs non-array value in the form of hash
247
+ # For object, use to_hash. Otherwise, just return the value
248
+ # @param [Object] value Any valid value
249
+ # @return [Hash] Returns the value in the form of hash
250
+ def _to_hash(value)
251
+ if value.is_a?(Array)
252
+ value.compact.map { |v| _to_hash(v) }
253
+ elsif value.is_a?(Hash)
254
+ {}.tap do |hash|
255
+ value.each { |k, v| hash[k] = _to_hash(v) }
256
+ end
257
+ elsif value.respond_to? :to_hash
258
+ value.to_hash
259
+ else
260
+ value
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
@@ -5,17 +5,17 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Analytics
8
- class NoClickRateEvent
9
- # [Click-through rate (CTR)](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-through-rate).
8
+ class DailyNoClickRates
9
+ # No click rate, calculated as number of tracked searches without any click divided by the number of tracked searches.
10
10
  attr_accessor :rate
11
11
 
12
- # Number of tracked _and_ untracked searches (where the `clickAnalytics` parameter isn't `true`).
12
+ # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
13
13
  attr_accessor :count
14
14
 
15
- # Number of click events.
15
+ # Number of times this search was returned as a result without any click.
16
16
  attr_accessor :no_click_count
17
17
 
18
- # Date of the event in the format YYYY-MM-DD.
18
+ # Date in the format YYYY-MM-DD.
19
19
  attr_accessor :date
20
20
 
21
21
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -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::NoClickRateEvent` initialize method"
55
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DailyNoClickRates` 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::NoClickRateEvent`. 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::DailyNoClickRates`. 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
@@ -108,6 +108,20 @@ module Algolia
108
108
  @rate = rate
109
109
  end
110
110
 
111
+ # Custom attribute writer method with validation
112
+ # @param [Object] no_click_count Value to be assigned
113
+ def no_click_count=(no_click_count)
114
+ if no_click_count.nil?
115
+ raise ArgumentError, 'no_click_count cannot be nil'
116
+ end
117
+
118
+ if no_click_count < 1
119
+ raise ArgumentError, 'invalid value for "no_click_count", must be greater than or equal to 1.'
120
+ end
121
+
122
+ @no_click_count = no_click_count
123
+ end
124
+
111
125
  # Checks equality by comparing each attribute.
112
126
  # @param [Object] Object to be compared
113
127
  def ==(other)