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,111 @@
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
+ # Literal value. Its JSON type depends on `kind` (array of strings for `indices`, string for dates, tags, and country, number for numeric operands, and so on).
11
+ module ParameterValue
12
+ class << self
13
+ # List of class defined in oneOf (OpenAPI v3)
14
+ def openapi_one_of
15
+ [
16
+ :"Array<String>",
17
+ :"Boolean",
18
+ :"Float",
19
+ :"String"
20
+ ]
21
+ end
22
+
23
+ # Builds the object
24
+ # @param [Mixed] Data to be matched against the list of oneOf items
25
+ # @return [Object] Returns the model or the data itself
26
+ def build(data)
27
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
28
+ # Note:
29
+ # - We do not attempt to check whether exactly one item matches.
30
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
31
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
32
+ # - TODO: scalar values are de facto behaving as if they were nullable.
33
+ # - TODO: logging when debugging is set.
34
+ openapi_one_of.each do |klass|
35
+ begin
36
+ # "nullable: true"
37
+ next if klass == :AnyType
38
+ typed_data = find_and_cast_into_type(klass, data)
39
+ return typed_data if typed_data
40
+ # rescue all errors so we keep iterating even if the current item lookup raises
41
+ rescue
42
+ end
43
+ end
44
+
45
+ openapi_one_of.include?(:AnyType) ? data : nil
46
+ end
47
+
48
+ private
49
+
50
+ SchemaMismatchError = Class.new(StandardError)
51
+
52
+ def find_and_cast_into_type(klass, data)
53
+ return if data.nil?
54
+
55
+ case klass.to_s
56
+ when "Boolean"
57
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
58
+ when "Float"
59
+ return data if data.instance_of?(Float)
60
+ when "Integer"
61
+ return data if data.instance_of?(Integer)
62
+ when "Time"
63
+ return Time.parse(data)
64
+ when "Date"
65
+ return Date.parse(data)
66
+ when "String"
67
+ return data if data.instance_of?(String)
68
+ # "type: object"
69
+ when "Object"
70
+ return data if data.instance_of?(Hash)
71
+ # "type: array"
72
+ when /\AArray<(?<sub_type>.+)>\z/
73
+ if data.instance_of?(Array)
74
+ sub_type = Regexp.last_match[:sub_type]
75
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
76
+ end
77
+ # "type: object" with "additionalProperties: { ... }"
78
+ when /\AHash<String, (?<sub_type>.+)>\z/
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ # model
84
+ else
85
+ const = Algolia::Analytics.const_get(klass)
86
+ if const
87
+ if const.respond_to?(:openapi_one_of)
88
+ # nested oneOf model
89
+ model = const.build(data)
90
+ elsif const.respond_to?(:discriminator_attributes)
91
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
92
+ model = const.build_from_hash(data)
93
+ end
94
+ else
95
+ # maybe it's an enum, or doens't have discriminators
96
+ model = const.build_from_hash(data)
97
+ end
98
+
99
+ return model if model
100
+ end
101
+ end
102
+
103
+ # if no match by now, raise
104
+ raise
105
+ rescue
106
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,247 @@
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 ScalarPayload
11
+ # Default domain propagated to entries that omit their own.
12
+ attr_accessor :domain
13
+
14
+ # Fields to aggregate.
15
+ attr_accessor :metrics
16
+
17
+ # Filter conditions.
18
+ attr_accessor :filters
19
+
20
+ # Literal values referenced by the query.
21
+ attr_accessor :parameters
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :domain => :domain,
27
+ :metrics => :metrics,
28
+ :filters => :filters,
29
+ :parameters => :parameters
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :domain => :"String",
37
+ :metrics => :"Array<FieldReference>",
38
+ :filters => :"Array<FilterDefinition>",
39
+ :parameters => :"Array<ParameterDefinition>"
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new(
46
+ []
47
+ )
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ raise(
55
+ ArgumentError,
56
+ "The input argument (attributes) must be a hash in `Algolia::ScalarPayload` initialize method"
57
+ )
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({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ raise(
64
+ ArgumentError,
65
+ "`#{k}` is not a valid attribute in `Algolia::ScalarPayload`. Please check the name to make sure it's valid. List of attributes: " +
66
+ self.class.attribute_map.keys.inspect
67
+ )
68
+ end
69
+
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:domain)
74
+ self.domain = attributes[:domain]
75
+ end
76
+
77
+ if attributes.key?(:metrics)
78
+ if (value = attributes[:metrics]).is_a?(Array)
79
+ self.metrics = value
80
+ end
81
+ else
82
+ self.metrics = nil
83
+ end
84
+
85
+ if attributes.key?(:filters)
86
+ if (value = attributes[:filters]).is_a?(Array)
87
+ self.filters = value
88
+ end
89
+ end
90
+
91
+ if attributes.key?(:parameters)
92
+ if (value = attributes[:parameters]).is_a?(Array)
93
+ self.parameters = value
94
+ end
95
+ else
96
+ self.parameters = nil
97
+ end
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(other)
103
+ return true if self.equal?(other)
104
+ self.class == other.class &&
105
+ domain == other.domain &&
106
+ metrics == other.metrics &&
107
+ filters == other.filters &&
108
+ parameters == other.parameters
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(other)
114
+ self == other
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [domain, metrics, filters, parameters].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ types_mapping.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash[key.to_sym] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
138
+ _deserialize(::Regexp.last_match(1), v)
139
+ }
140
+ end
141
+ elsif !attributes[attribute_map[key]].nil?
142
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
143
+ end
144
+ end
145
+
146
+ new(transformed_hash)
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def self._deserialize(type, value)
154
+ case type.to_sym
155
+ when :Time
156
+ Time.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ # model
187
+ else
188
+ # models (e.g. Pet) or oneOf
189
+ klass = Algolia::Analytics.const_get(type)
190
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
191
+ .build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ def to_json(*_args)
208
+ to_hash.to_json
209
+ end
210
+
211
+ # Returns the object in the form of hash
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_hash
214
+ hash = {}
215
+ self.class.attribute_map.each_pair do |attr, param|
216
+ value = send(attr)
217
+ if value.nil?
218
+ is_nullable = self.class.openapi_nullable.include?(attr)
219
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
220
+ end
221
+
222
+ hash[param] = _to_hash(value)
223
+ end
224
+
225
+ hash
226
+ end
227
+
228
+ # Outputs non-array value in the form of hash
229
+ # For object, use to_hash. Otherwise, just return the value
230
+ # @param [Object] value Any valid value
231
+ # @return [Hash] Returns the value in the form of hash
232
+ def _to_hash(value)
233
+ if value.is_a?(Array)
234
+ value.map { |v| _to_hash(v) }
235
+ elsif value.is_a?(Hash)
236
+ {}.tap do |hash|
237
+ value.each { |k, v| hash[k] = _to_hash(v) }
238
+ end
239
+ elsif value.respond_to?(:to_hash)
240
+ value.to_hash
241
+ else
242
+ value
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
@@ -0,0 +1,234 @@
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 Series
11
+ # The `groupBy` values identifying this series. Absent when the query has no `groupBy`.
12
+ attr_accessor :key
13
+
14
+ # Metric totals over the whole period.
15
+ attr_accessor :totals
16
+
17
+ # Per-day metric breakdown.
18
+ attr_accessor :dates
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :key => :key,
24
+ :totals => :totals,
25
+ :dates => :dates
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.types_mapping
31
+ {
32
+ :key => :"Hash<String, Object>",
33
+ :totals => :"Hash<String, Object>",
34
+ :dates => :"Array<SeriesDate>"
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new(
41
+ []
42
+ )
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Series` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ raise(
56
+ ArgumentError,
57
+ "`#{k}` is not a valid attribute in `Algolia::Series`. Please check the name to make sure it's valid. List of attributes: " +
58
+ self.class.attribute_map.keys.inspect
59
+ )
60
+ end
61
+
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:key)
66
+ if (value = attributes[:key]).is_a?(Hash)
67
+ self.key = value
68
+ end
69
+ end
70
+
71
+ if attributes.key?(:totals)
72
+ if (value = attributes[:totals]).is_a?(Hash)
73
+ self.totals = value
74
+ end
75
+ else
76
+ self.totals = nil
77
+ end
78
+
79
+ if attributes.key?(:dates)
80
+ if (value = attributes[:dates]).is_a?(Array)
81
+ self.dates = value
82
+ end
83
+ else
84
+ self.dates = nil
85
+ end
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(other)
91
+ return true if self.equal?(other)
92
+ self.class == other.class &&
93
+ key == other.key &&
94
+ totals == other.totals &&
95
+ dates == other.dates
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(other)
101
+ self == other
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Integer] Hash code
106
+ def hash
107
+ [key, totals, dates].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def self.build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ attributes = attributes.transform_keys(&:to_sym)
116
+ transformed_hash = {}
117
+ types_mapping.each_pair do |key, type|
118
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
119
+ transformed_hash[key.to_sym] = nil
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[attribute_map[key]].is_a?(Array)
124
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
125
+ _deserialize(::Regexp.last_match(1), v)
126
+ }
127
+ end
128
+ elsif !attributes[attribute_map[key]].nil?
129
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
130
+ end
131
+ end
132
+
133
+ new(transformed_hash)
134
+ end
135
+
136
+ # Deserializes the data based on type
137
+ # @param string type Data type
138
+ # @param string value Value to be deserialized
139
+ # @return [Object] Deserialized data
140
+ def self._deserialize(type, value)
141
+ case type.to_sym
142
+ when :Time
143
+ Time.parse(value)
144
+ when :Date
145
+ Date.parse(value)
146
+ when :String
147
+ value.to_s
148
+ when :Integer
149
+ value.to_i
150
+ when :Float
151
+ value.to_f
152
+ when :Boolean
153
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154
+ true
155
+ else
156
+ false
157
+ end
158
+
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ # model
174
+ else
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Algolia::Analytics.const_get(type)
177
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
178
+ .build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ def to_json(*_args)
195
+ to_hash.to_json
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = send(attr)
204
+ if value.nil?
205
+ is_nullable = self.class.openapi_nullable.include?(attr)
206
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
207
+ end
208
+
209
+ hash[param] = _to_hash(value)
210
+ end
211
+
212
+ hash
213
+ end
214
+
215
+ # Outputs non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ # @param [Object] value Any valid value
218
+ # @return [Hash] Returns the value in the form of hash
219
+ def _to_hash(value)
220
+ if value.is_a?(Array)
221
+ value.map { |v| _to_hash(v) }
222
+ elsif value.is_a?(Hash)
223
+ {}.tap do |hash|
224
+ value.each { |k, v| hash[k] = _to_hash(v) }
225
+ end
226
+ elsif value.respond_to?(:to_hash)
227
+ value.to_hash
228
+ else
229
+ value
230
+ end
231
+ end
232
+ end
233
+ end
234
+ end