algolia 3.42.3 → 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 (37) 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 +9 -0
  6. data/Gemfile.lock +2 -2
  7. data/lib/algolia/api/analytics_client.rb +221 -0
  8. data/lib/algolia/models/abtesting-v3/ab_test.rb +14 -4
  9. data/lib/algolia/models/abtesting-v3/decision.rb +219 -0
  10. data/lib/algolia/models/analytics/bin_edge.rb +109 -0
  11. data/lib/algolia/models/analytics/catalog.rb +208 -0
  12. data/lib/algolia/models/analytics/catalog_entry.rb +249 -0
  13. data/lib/algolia/models/analytics/distribution_definition.rb +243 -0
  14. data/lib/algolia/models/analytics/distribution_payload.rb +247 -0
  15. data/lib/algolia/models/analytics/domain_catalog.rb +253 -0
  16. data/lib/algolia/models/analytics/field_reference.rb +219 -0
  17. data/lib/algolia/models/analytics/filter_definition.rb +238 -0
  18. data/lib/algolia/models/analytics/order_definition.rb +230 -0
  19. data/lib/algolia/models/analytics/order_direction.rb +34 -0
  20. data/lib/algolia/models/analytics/parameter_definition.rb +230 -0
  21. data/lib/algolia/models/analytics/parameter_reference.rb +219 -0
  22. data/lib/algolia/models/analytics/parameter_value.rb +111 -0
  23. data/lib/algolia/models/analytics/scalar_payload.rb +247 -0
  24. data/lib/algolia/models/analytics/series.rb +234 -0
  25. data/lib/algolia/models/analytics/series_date.rb +223 -0
  26. data/lib/algolia/models/analytics/table_payload.rb +292 -0
  27. data/lib/algolia/models/analytics/table_response.rb +211 -0
  28. data/lib/algolia/models/analytics/timeseries_payload.rb +279 -0
  29. data/lib/algolia/models/analytics/timeseries_response.rb +213 -0
  30. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
  31. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
  32. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
  33. data/lib/algolia/models/insights/events_items.rb +1 -0
  34. data/lib/algolia/models/insights/instantsearch.rb +269 -0
  35. data/lib/algolia/models/insights/instantsearch_event.rb +33 -0
  36. data/lib/algolia/version.rb +1 -1
  37. metadata +25 -2
@@ -0,0 +1,109 @@
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
+ # A histogram bin edge. Use integers for discrete distributions and floating-point values for continuous ones.
11
+ module BinEdge
12
+ class << self
13
+ # List of class defined in oneOf (OpenAPI v3)
14
+ def openapi_one_of
15
+ [
16
+ :"Float",
17
+ :"Integer"
18
+ ]
19
+ end
20
+
21
+ # Builds the object
22
+ # @param [Mixed] Data to be matched against the list of oneOf items
23
+ # @return [Object] Returns the model or the data itself
24
+ def build(data)
25
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
26
+ # Note:
27
+ # - We do not attempt to check whether exactly one item matches.
28
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
29
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
30
+ # - TODO: scalar values are de facto behaving as if they were nullable.
31
+ # - TODO: logging when debugging is set.
32
+ openapi_one_of.each do |klass|
33
+ begin
34
+ # "nullable: true"
35
+ next if klass == :AnyType
36
+ typed_data = find_and_cast_into_type(klass, data)
37
+ return typed_data if typed_data
38
+ # rescue all errors so we keep iterating even if the current item lookup raises
39
+ rescue
40
+ end
41
+ end
42
+
43
+ openapi_one_of.include?(:AnyType) ? data : nil
44
+ end
45
+
46
+ private
47
+
48
+ SchemaMismatchError = Class.new(StandardError)
49
+
50
+ def find_and_cast_into_type(klass, data)
51
+ return if data.nil?
52
+
53
+ case klass.to_s
54
+ when "Boolean"
55
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
56
+ when "Float"
57
+ return data if data.instance_of?(Float)
58
+ when "Integer"
59
+ return data if data.instance_of?(Integer)
60
+ when "Time"
61
+ return Time.parse(data)
62
+ when "Date"
63
+ return Date.parse(data)
64
+ when "String"
65
+ return data if data.instance_of?(String)
66
+ # "type: object"
67
+ when "Object"
68
+ return data if data.instance_of?(Hash)
69
+ # "type: array"
70
+ when /\AArray<(?<sub_type>.+)>\z/
71
+ if data.instance_of?(Array)
72
+ sub_type = Regexp.last_match[:sub_type]
73
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
74
+ end
75
+ # "type: object" with "additionalProperties: { ... }"
76
+ when /\AHash<String, (?<sub_type>.+)>\z/
77
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
78
+ sub_type = Regexp.last_match[:sub_type]
79
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
80
+ end
81
+ # model
82
+ else
83
+ const = Algolia::Analytics.const_get(klass)
84
+ if const
85
+ if const.respond_to?(:openapi_one_of)
86
+ # nested oneOf model
87
+ model = const.build(data)
88
+ elsif const.respond_to?(:discriminator_attributes)
89
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
90
+ model = const.build_from_hash(data)
91
+ end
92
+ else
93
+ # maybe it's an enum, or doens't have discriminators
94
+ model = const.build_from_hash(data)
95
+ end
96
+
97
+ return model if model
98
+ end
99
+ end
100
+
101
+ # if no match by now, raise
102
+ raise
103
+ rescue
104
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,208 @@
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 Catalog
11
+ # Catalog entries grouped by domain.
12
+ attr_accessor :domains
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :domains => :domains
18
+ }
19
+ end
20
+
21
+ # Attribute type mapping.
22
+ def self.types_mapping
23
+ {
24
+ :domains => :"Hash<String, DomainCatalog>"
25
+ }
26
+ end
27
+
28
+ # List of attributes with nullable: true
29
+ def self.openapi_nullable
30
+ Set.new(
31
+ []
32
+ )
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Catalog` initialize method"
40
+ end
41
+
42
+ # check to see if the attribute exists and convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h|
44
+ if (!self.class.attribute_map.key?(k.to_sym))
45
+ raise(
46
+ ArgumentError,
47
+ "`#{k}` is not a valid attribute in `Algolia::Catalog`. Please check the name to make sure it's valid. List of attributes: " +
48
+ self.class.attribute_map.keys.inspect
49
+ )
50
+ end
51
+
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:domains)
56
+ if (value = attributes[:domains]).is_a?(Hash)
57
+ self.domains = value
58
+ end
59
+ else
60
+ self.domains = nil
61
+ end
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(other)
67
+ return true if self.equal?(other)
68
+ self.class == other.class &&
69
+ domains == other.domains
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(other)
75
+ self == other
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Integer] Hash code
80
+ def hash
81
+ [domains].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def self.build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
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|
99
+ _deserialize(::Regexp.last_match(1), v)
100
+ }
101
+ end
102
+ elsif !attributes[attribute_map[key]].nil?
103
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
104
+ end
105
+ end
106
+
107
+ new(transformed_hash)
108
+ end
109
+
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
114
+ def self._deserialize(type, value)
115
+ case type.to_sym
116
+ when :Time
117
+ Time.parse(value)
118
+ when :Date
119
+ Date.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :Boolean
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+
133
+ when :Object
134
+ # generic object (usually a Hash), return directly
135
+ value
136
+ when /\AArray<(?<inner_type>.+)>\z/
137
+ inner_type = Regexp.last_match[:inner_type]
138
+ value.map { |v| _deserialize(inner_type, v) }
139
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
+ k_type = Regexp.last_match[:k_type]
141
+ v_type = Regexp.last_match[:v_type]
142
+ {}.tap do |hash|
143
+ value.each do |k, v|
144
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
+ end
146
+ end
147
+ # model
148
+ else
149
+ # models (e.g. Pet) or oneOf
150
+ klass = Algolia::Analytics.const_get(type)
151
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
152
+ .build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ def to_json(*_args)
169
+ to_hash.to_json
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.map { |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to?(:to_hash)
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,249 @@
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 CatalogEntry
11
+ # Field identifier.
12
+ attr_accessor :kind
13
+
14
+ # Human-readable description of the field.
15
+ attr_accessor :description
16
+
17
+ # Root stages the field depends on. Two fields are combinable in one query only when their roots intersect.
18
+ attr_accessor :roots
19
+
20
+ # Public ACL identifiers required to read the field, for example `clickAnalyticsEnabled`.
21
+ attr_accessor :requires
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :kind => :kind,
27
+ :description => :description,
28
+ :roots => :roots,
29
+ :requires => :requires
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :kind => :"String",
37
+ :description => :"String",
38
+ :roots => :"Array<String>",
39
+ :requires => :"Array<String>"
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::CatalogEntry` 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::CatalogEntry`. 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?(:kind)
74
+ self.kind = attributes[:kind]
75
+ else
76
+ self.kind = nil
77
+ end
78
+
79
+ if attributes.key?(:description)
80
+ self.description = attributes[:description]
81
+ else
82
+ self.description = nil
83
+ end
84
+
85
+ if attributes.key?(:roots)
86
+ if (value = attributes[:roots]).is_a?(Array)
87
+ self.roots = value
88
+ end
89
+ else
90
+ self.roots = nil
91
+ end
92
+
93
+ if attributes.key?(:requires)
94
+ if (value = attributes[:requires]).is_a?(Array)
95
+ self.requires = value
96
+ end
97
+ else
98
+ self.requires = nil
99
+ end
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(other)
105
+ return true if self.equal?(other)
106
+ self.class == other.class &&
107
+ kind == other.kind &&
108
+ description == other.description &&
109
+ roots == other.roots &&
110
+ requires == other.requires
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(other)
116
+ self == other
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [kind, description, roots, requires].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ transformed_hash = {}
132
+ types_mapping.each_pair do |key, type|
133
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
134
+ transformed_hash[key.to_sym] = nil
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[attribute_map[key]].is_a?(Array)
139
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
140
+ _deserialize(::Regexp.last_match(1), v)
141
+ }
142
+ end
143
+ elsif !attributes[attribute_map[key]].nil?
144
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
145
+ end
146
+ end
147
+
148
+ new(transformed_hash)
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def self._deserialize(type, value)
156
+ case type.to_sym
157
+ when :Time
158
+ Time.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ # model
189
+ else
190
+ # models (e.g. Pet) or oneOf
191
+ klass = Algolia::Analytics.const_get(type)
192
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
193
+ .build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ def to_json(*_args)
210
+ to_hash.to_json
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+
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.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