algolia 3.42.2 → 3.43.0

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/do-not-edit-this-repository.yml +1 -1
  3. data/.github/workflows/issue.yml +1 -1
  4. data/.github/workflows/release.yml +4 -4
  5. data/CHANGELOG.md +14 -0
  6. data/Gemfile.lock +2 -2
  7. data/lib/algolia/api/analytics_client.rb +221 -0
  8. data/lib/algolia/api/search_client.rb +16 -0
  9. data/lib/algolia/api_client.rb +4 -0
  10. data/lib/algolia/models/abtesting-v3/ab_test.rb +14 -4
  11. data/lib/algolia/models/abtesting-v3/decision.rb +219 -0
  12. data/lib/algolia/models/analytics/bin_edge.rb +109 -0
  13. data/lib/algolia/models/analytics/catalog.rb +208 -0
  14. data/lib/algolia/models/analytics/catalog_entry.rb +249 -0
  15. data/lib/algolia/models/analytics/distribution_definition.rb +243 -0
  16. data/lib/algolia/models/analytics/distribution_payload.rb +247 -0
  17. data/lib/algolia/models/analytics/domain_catalog.rb +253 -0
  18. data/lib/algolia/models/analytics/field_reference.rb +219 -0
  19. data/lib/algolia/models/analytics/filter_definition.rb +238 -0
  20. data/lib/algolia/models/analytics/order_definition.rb +230 -0
  21. data/lib/algolia/models/analytics/order_direction.rb +34 -0
  22. data/lib/algolia/models/analytics/parameter_definition.rb +230 -0
  23. data/lib/algolia/models/analytics/parameter_reference.rb +219 -0
  24. data/lib/algolia/models/analytics/parameter_value.rb +111 -0
  25. data/lib/algolia/models/analytics/scalar_payload.rb +247 -0
  26. data/lib/algolia/models/analytics/series.rb +234 -0
  27. data/lib/algolia/models/analytics/series_date.rb +223 -0
  28. data/lib/algolia/models/analytics/table_payload.rb +292 -0
  29. data/lib/algolia/models/analytics/table_response.rb +211 -0
  30. data/lib/algolia/models/analytics/timeseries_payload.rb +279 -0
  31. data/lib/algolia/models/analytics/timeseries_response.rb +213 -0
  32. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
  33. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
  34. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
  35. data/lib/algolia/models/insights/events_items.rb +1 -0
  36. data/lib/algolia/models/insights/instantsearch.rb +269 -0
  37. data/lib/algolia/models/insights/instantsearch_event.rb +33 -0
  38. data/lib/algolia/models/recommend/facet_filters.rb +109 -0
  39. data/lib/algolia/models/recommend/fallback_params.rb +14 -4
  40. data/lib/algolia/version.rb +1 -1
  41. metadata +26 -2
@@ -0,0 +1,223 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 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.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Analytics
10
+ class SeriesDate
11
+ # Day, formatted as YYYY-MM-DD.
12
+ attr_accessor :date
13
+
14
+ # Metric values for the day.
15
+ attr_accessor :metrics
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :date => :date,
21
+ :metrics => :metrics
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.types_mapping
27
+ {
28
+ :date => :"String",
29
+ :metrics => :"Hash<String, Object>"
30
+ }
31
+ end
32
+
33
+ # List of attributes with nullable: true
34
+ def self.openapi_nullable
35
+ Set.new(
36
+ []
37
+ )
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ raise(
45
+ ArgumentError,
46
+ "The input argument (attributes) must be a hash in `Algolia::SeriesDate` initialize method"
47
+ )
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h|
52
+ if (!self.class.attribute_map.key?(k.to_sym))
53
+ raise(
54
+ ArgumentError,
55
+ "`#{k}` is not a valid attribute in `Algolia::SeriesDate`. Please check the name to make sure it's valid. List of attributes: " +
56
+ self.class.attribute_map.keys.inspect
57
+ )
58
+ end
59
+
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:date)
64
+ self.date = attributes[:date]
65
+ else
66
+ self.date = nil
67
+ end
68
+
69
+ if attributes.key?(:metrics)
70
+ if (value = attributes[:metrics]).is_a?(Hash)
71
+ self.metrics = value
72
+ end
73
+ else
74
+ self.metrics = nil
75
+ end
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(other)
81
+ return true if self.equal?(other)
82
+ self.class == other.class &&
83
+ date == other.date &&
84
+ metrics == other.metrics
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(other)
90
+ self == other
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [date, metrics].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ return nil unless attributes.is_a?(Hash)
104
+ attributes = attributes.transform_keys(&:to_sym)
105
+ transformed_hash = {}
106
+ types_mapping.each_pair do |key, type|
107
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
108
+ transformed_hash[key.to_sym] = nil
109
+ elsif type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[attribute_map[key]].is_a?(Array)
113
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
114
+ _deserialize(::Regexp.last_match(1), v)
115
+ }
116
+ end
117
+ elsif !attributes[attribute_map[key]].nil?
118
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
119
+ end
120
+ end
121
+
122
+ new(transformed_hash)
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def self._deserialize(type, value)
130
+ case type.to_sym
131
+ when :Time
132
+ Time.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :Boolean
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ # model
163
+ else
164
+ # models (e.g. Pet) or oneOf
165
+ klass = Algolia::Analytics.const_get(type)
166
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
167
+ .build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ def to_json(*_args)
184
+ to_hash.to_json
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = send(attr)
193
+ if value.nil?
194
+ is_nullable = self.class.openapi_nullable.include?(attr)
195
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
196
+ end
197
+
198
+ hash[param] = _to_hash(value)
199
+ end
200
+
201
+ hash
202
+ end
203
+
204
+ # Outputs non-array value in the form of hash
205
+ # For object, use to_hash. Otherwise, just return the value
206
+ # @param [Object] value Any valid value
207
+ # @return [Hash] Returns the value in the form of hash
208
+ def _to_hash(value)
209
+ if value.is_a?(Array)
210
+ value.map { |v| _to_hash(v) }
211
+ elsif value.is_a?(Hash)
212
+ {}.tap do |hash|
213
+ value.each { |k, v| hash[k] = _to_hash(v) }
214
+ end
215
+ elsif value.respond_to?(:to_hash)
216
+ value.to_hash
217
+ else
218
+ value
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,292 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 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.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Analytics
10
+ # When `groupBy` is set, `orderBy` is required.
11
+ class TablePayload
12
+ # Default domain propagated to entries that omit their own.
13
+ attr_accessor :domain
14
+
15
+ # Fields to aggregate.
16
+ attr_accessor :metrics
17
+
18
+ # Fields to split rows by.
19
+ attr_accessor :group_by
20
+
21
+ # Filter conditions.
22
+ attr_accessor :filters
23
+
24
+ # Literal values referenced by the query.
25
+ attr_accessor :parameters
26
+
27
+ # Sort specification. Required when `groupBy` is set.
28
+ attr_accessor :order_by
29
+
30
+ # Maximum number of rows to return.
31
+ attr_accessor :limit
32
+
33
+ # Number of rows to skip.
34
+ attr_accessor :offset
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :domain => :domain,
40
+ :metrics => :metrics,
41
+ :group_by => :groupBy,
42
+ :filters => :filters,
43
+ :parameters => :parameters,
44
+ :order_by => :orderBy,
45
+ :limit => :limit,
46
+ :offset => :offset
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.types_mapping
52
+ {
53
+ :domain => :"String",
54
+ :metrics => :"Array<FieldReference>",
55
+ :group_by => :"Array<FieldReference>",
56
+ :filters => :"Array<FilterDefinition>",
57
+ :parameters => :"Array<ParameterDefinition>",
58
+ :order_by => :"Array<OrderDefinition>",
59
+ :limit => :"Integer",
60
+ :offset => :"Integer"
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new(
67
+ []
68
+ )
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ raise(
76
+ ArgumentError,
77
+ "The input argument (attributes) must be a hash in `Algolia::TablePayload` initialize method"
78
+ )
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ raise(
85
+ ArgumentError,
86
+ "`#{k}` is not a valid attribute in `Algolia::TablePayload`. Please check the name to make sure it's valid. List of attributes: " +
87
+ self.class.attribute_map.keys.inspect
88
+ )
89
+ end
90
+
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:domain)
95
+ self.domain = attributes[:domain]
96
+ end
97
+
98
+ if attributes.key?(:metrics)
99
+ if (value = attributes[:metrics]).is_a?(Array)
100
+ self.metrics = value
101
+ end
102
+ else
103
+ self.metrics = nil
104
+ end
105
+
106
+ if attributes.key?(:group_by)
107
+ if (value = attributes[:group_by]).is_a?(Array)
108
+ self.group_by = value
109
+ end
110
+ end
111
+
112
+ if attributes.key?(:filters)
113
+ if (value = attributes[:filters]).is_a?(Array)
114
+ self.filters = value
115
+ end
116
+ end
117
+
118
+ if attributes.key?(:parameters)
119
+ if (value = attributes[:parameters]).is_a?(Array)
120
+ self.parameters = value
121
+ end
122
+ else
123
+ self.parameters = nil
124
+ end
125
+
126
+ if attributes.key?(:order_by)
127
+ if (value = attributes[:order_by]).is_a?(Array)
128
+ self.order_by = value
129
+ end
130
+ end
131
+
132
+ if attributes.key?(:limit)
133
+ self.limit = attributes[:limit]
134
+ end
135
+
136
+ if attributes.key?(:offset)
137
+ self.offset = attributes[:offset]
138
+ end
139
+ end
140
+
141
+ # Checks equality by comparing each attribute.
142
+ # @param [Object] Object to be compared
143
+ def ==(other)
144
+ return true if self.equal?(other)
145
+ self.class == other.class &&
146
+ domain == other.domain &&
147
+ metrics == other.metrics &&
148
+ group_by == other.group_by &&
149
+ filters == other.filters &&
150
+ parameters == other.parameters &&
151
+ order_by == other.order_by &&
152
+ limit == other.limit &&
153
+ offset == other.offset
154
+ end
155
+
156
+ # @see the `==` method
157
+ # @param [Object] Object to be compared
158
+ def eql?(other)
159
+ self == other
160
+ end
161
+
162
+ # Calculates hash code according to all attributes.
163
+ # @return [Integer] Hash code
164
+ def hash
165
+ [domain, metrics, group_by, filters, parameters, order_by, limit, offset].hash
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def self.build_from_hash(attributes)
172
+ return nil unless attributes.is_a?(Hash)
173
+ attributes = attributes.transform_keys(&:to_sym)
174
+ transformed_hash = {}
175
+ types_mapping.each_pair do |key, type|
176
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
177
+ transformed_hash[key.to_sym] = nil
178
+ elsif type =~ /\AArray<(.*)>/i
179
+ # check to ensure the input is an array given that the attribute
180
+ # is documented as an array but the input is not
181
+ if attributes[attribute_map[key]].is_a?(Array)
182
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
183
+ _deserialize(::Regexp.last_match(1), v)
184
+ }
185
+ end
186
+ elsif !attributes[attribute_map[key]].nil?
187
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
188
+ end
189
+ end
190
+
191
+ new(transformed_hash)
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def self._deserialize(type, value)
199
+ case type.to_sym
200
+ when :Time
201
+ Time.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :Boolean
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+
217
+ when :Object
218
+ # generic object (usually a Hash), return directly
219
+ value
220
+ when /\AArray<(?<inner_type>.+)>\z/
221
+ inner_type = Regexp.last_match[:inner_type]
222
+ value.map { |v| _deserialize(inner_type, v) }
223
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
224
+ k_type = Regexp.last_match[:k_type]
225
+ v_type = Regexp.last_match[:v_type]
226
+ {}.tap do |hash|
227
+ value.each do |k, v|
228
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
229
+ end
230
+ end
231
+ # model
232
+ else
233
+ # models (e.g. Pet) or oneOf
234
+ klass = Algolia::Analytics.const_get(type)
235
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
236
+ .build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ def to_json(*_args)
253
+ to_hash.to_json
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+
270
+ hash
271
+ end
272
+
273
+ # Outputs non-array value in the form of hash
274
+ # For object, use to_hash. Otherwise, just return the value
275
+ # @param [Object] value Any valid value
276
+ # @return [Hash] Returns the value in the form of hash
277
+ def _to_hash(value)
278
+ if value.is_a?(Array)
279
+ value.map { |v| _to_hash(v) }
280
+ elsif value.is_a?(Hash)
281
+ {}.tap do |hash|
282
+ value.each { |k, v| hash[k] = _to_hash(v) }
283
+ end
284
+ elsif value.respond_to?(:to_hash)
285
+ value.to_hash
286
+ else
287
+ value
288
+ end
289
+ end
290
+ end
291
+ end
292
+ end