algolia 3.24.0 → 3.26.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue.yml +1 -1
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +18 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/composition_client.rb +765 -0
  7. data/lib/algolia/api/ingestion_client.rb +63 -6
  8. data/lib/algolia/api/search_client.rb +10 -5
  9. data/lib/algolia/models/composition/action.rb +34 -0
  10. data/lib/algolia/models/composition/advanced_syntax_features.rb +34 -0
  11. data/lib/algolia/models/composition/alternatives_as_exact.rb +36 -0
  12. data/lib/algolia/models/composition/anchoring.rb +36 -0
  13. data/lib/algolia/models/composition/base_injection_query_parameters.rb +732 -0
  14. data/lib/algolia/models/composition/batch_composition_action.rb +109 -0
  15. data/lib/algolia/models/composition/batch_params.rb +213 -0
  16. data/lib/algolia/models/composition/boolean_string.rb +34 -0
  17. data/lib/algolia/models/composition/composition.rb +244 -0
  18. data/lib/algolia/models/composition/composition_behavior.rb +210 -0
  19. data/lib/algolia/models/composition/composition_rule.rb +280 -0
  20. data/lib/algolia/models/composition/composition_rule_consequence.rb +211 -0
  21. data/lib/algolia/models/composition/composition_rules_batch_params.rb +211 -0
  22. data/lib/algolia/models/composition/composition_source.rb +210 -0
  23. data/lib/algolia/models/composition/composition_source_search.rb +220 -0
  24. data/lib/algolia/models/composition/condition.rb +238 -0
  25. data/lib/algolia/models/composition/delete_composition_action.rb +212 -0
  26. data/lib/algolia/models/composition/delete_composition_rule_action.rb +212 -0
  27. data/lib/algolia/models/composition/distinct.rb +110 -0
  28. data/lib/algolia/models/composition/exact_on_single_word_query.rb +35 -0
  29. data/lib/algolia/models/composition/external.rb +226 -0
  30. data/lib/algolia/models/composition/external_injected_item.rb +212 -0
  31. data/lib/algolia/models/composition/external_injection.rb +223 -0
  32. data/lib/algolia/models/composition/external_ordering.rb +34 -0
  33. data/lib/algolia/models/composition/external_source.rb +211 -0
  34. data/lib/algolia/models/composition/get_task_response.rb +210 -0
  35. data/lib/algolia/models/composition/ignore_plurals.rb +111 -0
  36. data/lib/algolia/models/composition/injected_item.rb +253 -0
  37. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +222 -0
  38. data/lib/algolia/models/composition/injected_item_metadata.rb +209 -0
  39. data/lib/algolia/models/composition/injected_item_source.rb +109 -0
  40. data/lib/algolia/models/composition/injection.rb +222 -0
  41. data/lib/algolia/models/composition/list_compositions_response.rb +261 -0
  42. data/lib/algolia/models/composition/main.rb +207 -0
  43. data/lib/algolia/models/composition/main_injection_query_parameters.rb +807 -0
  44. data/lib/algolia/models/composition/multiple_batch_request.rb +221 -0
  45. data/lib/algolia/models/composition/multiple_batch_response.rb +213 -0
  46. data/lib/algolia/models/composition/optional_words.rb +110 -0
  47. data/lib/algolia/models/composition/params.rb +17 -4
  48. data/lib/algolia/models/composition/query_type.rb +35 -0
  49. data/lib/algolia/models/composition/remove_stop_words.rb +110 -0
  50. data/lib/algolia/models/composition/remove_words_if_no_results.rb +36 -0
  51. data/lib/algolia/models/composition/rules_batch_composition_action.rb +109 -0
  52. data/lib/algolia/models/composition/rules_multiple_batch_request.rb +221 -0
  53. data/lib/algolia/models/composition/rules_multiple_batch_response.rb +211 -0
  54. data/lib/algolia/models/composition/search.rb +217 -0
  55. data/lib/algolia/models/composition/search_composition_rules_params.rb +261 -0
  56. data/lib/algolia/models/composition/search_composition_rules_response.rb +249 -0
  57. data/lib/algolia/models/composition/search_source.rb +211 -0
  58. data/lib/algolia/models/composition/task_id_response.rb +211 -0
  59. data/lib/algolia/models/composition/task_status.rb +34 -0
  60. data/lib/algolia/models/composition/time_range.rb +219 -0
  61. data/lib/algolia/models/composition/typo_tolerance.rb +110 -0
  62. data/lib/algolia/models/composition/typo_tolerance_enum.rb +36 -0
  63. data/lib/algolia/models/ingestion/task_replace.rb +310 -0
  64. data/lib/algolia/models/ingestion/task_update.rb +1 -1
  65. data/lib/algolia/models/search/consequence.rb +1 -1
  66. data/lib/algolia/transport/transport.rb +6 -1
  67. data/lib/algolia/version.rb +1 -1
  68. metadata +55 -1
@@ -0,0 +1,219 @@
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 Composition
10
+ class TimeRange
11
+ # When the rule should start to be active, in Unix epoch time.
12
+ attr_accessor :from
13
+
14
+ # When the rule should stop to be active, in Unix epoch time.
15
+ attr_accessor :_until
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :from => :from,
21
+ :_until => :until
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.types_mapping
27
+ {
28
+ :from => :"Integer",
29
+ :_until => :"Integer"
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::TimeRange` 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::TimeRange`. 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?(:from)
64
+ self.from = attributes[:from]
65
+ end
66
+
67
+ if attributes.key?(:_until)
68
+ self._until = attributes[:_until]
69
+ end
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(other)
75
+ return true if self.equal?(other)
76
+ self.class == other.class &&
77
+ from == other.from &&
78
+ _until == other._until
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(other)
84
+ self == other
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Integer] Hash code
89
+ def hash
90
+ [from, _until].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def self.build_from_hash(attributes)
97
+ return nil unless attributes.is_a?(Hash)
98
+ attributes = attributes.transform_keys(&:to_sym)
99
+ transformed_hash = {}
100
+ types_mapping.each_pair do |key, type|
101
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
102
+ transformed_hash[key.to_sym] = nil
103
+ elsif type =~ /\AArray<(.*)>/i
104
+ # check to ensure the input is an array given that the attribute
105
+ # is documented as an array but the input is not
106
+ if attributes[attribute_map[key]].is_a?(Array)
107
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
108
+ _deserialize(::Regexp.last_match(1), v)
109
+ }
110
+ end
111
+ elsif !attributes[attribute_map[key]].nil?
112
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
113
+ end
114
+ end
115
+
116
+ new(transformed_hash)
117
+ end
118
+
119
+ # Deserializes the data based on type
120
+ # @param string type Data type
121
+ # @param string value Value to be deserialized
122
+ # @return [Object] Deserialized data
123
+ def self._deserialize(type, value)
124
+ case type.to_sym
125
+ when :Time
126
+ Time.parse(value)
127
+ when :Date
128
+ Date.parse(value)
129
+ when :String
130
+ value.to_s
131
+ when :Integer
132
+ value.to_i
133
+ when :Float
134
+ value.to_f
135
+ when :Boolean
136
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
137
+ true
138
+ else
139
+ false
140
+ end
141
+
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ # model
157
+ else
158
+ # models (e.g. Pet) or oneOf
159
+ klass = Algolia::Composition.const_get(type)
160
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
161
+ .build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ def to_json(*_args)
178
+ to_hash.to_json
179
+ end
180
+
181
+ # Returns the object in the form of hash
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_hash
184
+ hash = {}
185
+ self.class.attribute_map.each_pair do |attr, param|
186
+ value = send(attr)
187
+ if value.nil?
188
+ is_nullable = self.class.openapi_nullable.include?(attr)
189
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
190
+ end
191
+
192
+ hash[param] = _to_hash(value)
193
+ end
194
+
195
+ hash
196
+ end
197
+
198
+ # Outputs non-array value in the form of hash
199
+ # For object, use to_hash. Otherwise, just return the value
200
+ # @param [Object] value Any valid value
201
+ # @return [Hash] Returns the value in the form of hash
202
+ def _to_hash(value)
203
+ if value.is_a?(Array)
204
+ value.compact.map { |v| _to_hash(v) }
205
+ elsif value.is_a?(Hash)
206
+ {}.tap do |hash|
207
+ value.each { |k, v| hash[k] = _to_hash(v) }
208
+ end
209
+ elsif value.respond_to?(:to_hash)
210
+ value.to_hash
211
+ else
212
+ value
213
+ end
214
+ end
215
+
216
+ end
217
+
218
+ end
219
+ end
@@ -0,0 +1,110 @@
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 Composition
10
+ # Whether [typo tolerance](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/) is enabled and how it is applied. If typo tolerance is true, `min`, or `strict`, [word splitting and concatenation](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/splitting-and-concatenation/) are also active.
11
+ module TypoTolerance
12
+ class << self
13
+ # List of class defined in oneOf (OpenAPI v3)
14
+ def openapi_one_of
15
+ [
16
+ :"Boolean",
17
+ :"TypoToleranceEnum"
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::Composition.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
+
109
+ end
110
+ end
@@ -0,0 +1,36 @@
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 Composition
10
+ class TypoToleranceEnum
11
+ MIN = "min".freeze
12
+ STRICT = "strict".freeze
13
+ TRUE = "true".freeze
14
+ FALSE = "false".freeze
15
+
16
+ def self.all_vars
17
+ @all_vars ||= [MIN, STRICT, TRUE, FALSE].freeze
18
+ end
19
+
20
+ # Builds the enum from string
21
+ # @param [String] The enum value in the form of the string
22
+ # @return [String] The enum value
23
+ def self.build_from_hash(value)
24
+ new.build_from_hash(value)
25
+ end
26
+
27
+ # Builds the enum from string
28
+ # @param [String] The enum value in the form of the string
29
+ # @return [String] The enum value
30
+ def build_from_hash(value)
31
+ return value if TypoToleranceEnum.all_vars.include?(value)
32
+ raise "Invalid ENUM value #{value} for class #TypoToleranceEnum"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,310 @@
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 Ingestion
10
+ # API request body for updating a task.
11
+ class TaskReplace
12
+ # Universally unique identifier (UUID) of a destination resource.
13
+ attr_accessor :destination_id
14
+
15
+ attr_accessor :action
16
+
17
+ attr_accessor :subscription_action
18
+
19
+ # Cron expression for the task's schedule.
20
+ attr_accessor :cron
21
+
22
+ # Whether the task is enabled.
23
+ attr_accessor :enabled
24
+
25
+ # Maximum accepted percentage of failures for a task run to finish successfully.
26
+ attr_accessor :failure_threshold
27
+
28
+ attr_accessor :input
29
+
30
+ # Date of the last cursor in RFC 3339 format.
31
+ attr_accessor :cursor
32
+
33
+ attr_accessor :notifications
34
+
35
+ attr_accessor :policies
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :destination_id => :destinationID,
41
+ :action => :action,
42
+ :subscription_action => :subscriptionAction,
43
+ :cron => :cron,
44
+ :enabled => :enabled,
45
+ :failure_threshold => :failureThreshold,
46
+ :input => :input,
47
+ :cursor => :cursor,
48
+ :notifications => :notifications,
49
+ :policies => :policies
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.types_mapping
55
+ {
56
+ :destination_id => :"String",
57
+ :action => :"ActionType",
58
+ :subscription_action => :"ActionType",
59
+ :cron => :"String",
60
+ :enabled => :"Boolean",
61
+ :failure_threshold => :"Integer",
62
+ :input => :"TaskInput",
63
+ :cursor => :"String",
64
+ :notifications => :"Notifications",
65
+ :policies => :"Policies"
66
+ }
67
+ end
68
+
69
+ # List of attributes with nullable: true
70
+ def self.openapi_nullable
71
+ Set.new(
72
+ []
73
+ )
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ raise(
81
+ ArgumentError,
82
+ "The input argument (attributes) must be a hash in `Algolia::TaskReplace` initialize method"
83
+ )
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ raise(
90
+ ArgumentError,
91
+ "`#{k}` is not a valid attribute in `Algolia::TaskReplace`. Please check the name to make sure it's valid. List of attributes: " +
92
+ self.class.attribute_map.keys.inspect
93
+ )
94
+ end
95
+
96
+ h[k.to_sym] = v
97
+ }
98
+
99
+ if attributes.key?(:destination_id)
100
+ self.destination_id = attributes[:destination_id]
101
+ else
102
+ self.destination_id = nil
103
+ end
104
+
105
+ if attributes.key?(:action)
106
+ self.action = attributes[:action]
107
+ else
108
+ self.action = nil
109
+ end
110
+
111
+ if attributes.key?(:subscription_action)
112
+ self.subscription_action = attributes[:subscription_action]
113
+ end
114
+
115
+ if attributes.key?(:cron)
116
+ self.cron = attributes[:cron]
117
+ end
118
+
119
+ if attributes.key?(:enabled)
120
+ self.enabled = attributes[:enabled]
121
+ end
122
+
123
+ if attributes.key?(:failure_threshold)
124
+ self.failure_threshold = attributes[:failure_threshold]
125
+ end
126
+
127
+ if attributes.key?(:input)
128
+ self.input = attributes[:input]
129
+ end
130
+
131
+ if attributes.key?(:cursor)
132
+ self.cursor = attributes[:cursor]
133
+ end
134
+
135
+ if attributes.key?(:notifications)
136
+ self.notifications = attributes[:notifications]
137
+ end
138
+
139
+ if attributes.key?(:policies)
140
+ self.policies = attributes[:policies]
141
+ end
142
+ end
143
+
144
+ # Checks equality by comparing each attribute.
145
+ # @param [Object] Object to be compared
146
+ def ==(other)
147
+ return true if self.equal?(other)
148
+ self.class == other.class &&
149
+ destination_id == other.destination_id &&
150
+ action == other.action &&
151
+ subscription_action == other.subscription_action &&
152
+ cron == other.cron &&
153
+ enabled == other.enabled &&
154
+ failure_threshold == other.failure_threshold &&
155
+ input == other.input &&
156
+ cursor == other.cursor &&
157
+ notifications == other.notifications &&
158
+ policies == other.policies
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(other)
164
+ self == other
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [
171
+ destination_id,
172
+ action,
173
+ subscription_action,
174
+ cron,
175
+ enabled,
176
+ failure_threshold,
177
+ input,
178
+ cursor,
179
+ notifications,
180
+ policies
181
+ ].hash
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def self.build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ attributes = attributes.transform_keys(&:to_sym)
190
+ transformed_hash = {}
191
+ types_mapping.each_pair do |key, type|
192
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
193
+ transformed_hash[key.to_sym] = nil
194
+ elsif type =~ /\AArray<(.*)>/i
195
+ # check to ensure the input is an array given that the attribute
196
+ # is documented as an array but the input is not
197
+ if attributes[attribute_map[key]].is_a?(Array)
198
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
199
+ _deserialize(::Regexp.last_match(1), v)
200
+ }
201
+ end
202
+ elsif !attributes[attribute_map[key]].nil?
203
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
204
+ end
205
+ end
206
+
207
+ new(transformed_hash)
208
+ end
209
+
210
+ # Deserializes the data based on type
211
+ # @param string type Data type
212
+ # @param string value Value to be deserialized
213
+ # @return [Object] Deserialized data
214
+ def self._deserialize(type, value)
215
+ case type.to_sym
216
+ when :Time
217
+ Time.parse(value)
218
+ when :Date
219
+ Date.parse(value)
220
+ when :String
221
+ value.to_s
222
+ when :Integer
223
+ value.to_i
224
+ when :Float
225
+ value.to_f
226
+ when :Boolean
227
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
228
+ true
229
+ else
230
+ false
231
+ end
232
+
233
+ when :Object
234
+ # generic object (usually a Hash), return directly
235
+ value
236
+ when /\AArray<(?<inner_type>.+)>\z/
237
+ inner_type = Regexp.last_match[:inner_type]
238
+ value.map { |v| _deserialize(inner_type, v) }
239
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
240
+ k_type = Regexp.last_match[:k_type]
241
+ v_type = Regexp.last_match[:v_type]
242
+ {}.tap do |hash|
243
+ value.each do |k, v|
244
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
245
+ end
246
+ end
247
+ # model
248
+ else
249
+ # models (e.g. Pet) or oneOf
250
+ klass = Algolia::Ingestion.const_get(type)
251
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
252
+ .build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ def to_json(*_args)
269
+ to_hash.to_json
270
+ end
271
+
272
+ # Returns the object in the form of hash
273
+ # @return [Hash] Returns the object in the form of hash
274
+ def to_hash
275
+ hash = {}
276
+ self.class.attribute_map.each_pair do |attr, param|
277
+ value = send(attr)
278
+ if value.nil?
279
+ is_nullable = self.class.openapi_nullable.include?(attr)
280
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
281
+ end
282
+
283
+ hash[param] = _to_hash(value)
284
+ end
285
+
286
+ hash
287
+ end
288
+
289
+ # Outputs non-array value in the form of hash
290
+ # For object, use to_hash. Otherwise, just return the value
291
+ # @param [Object] value Any valid value
292
+ # @return [Hash] Returns the value in the form of hash
293
+ def _to_hash(value)
294
+ if value.is_a?(Array)
295
+ value.compact.map { |v| _to_hash(v) }
296
+ elsif value.is_a?(Hash)
297
+ {}.tap do |hash|
298
+ value.each { |k, v| hash[k] = _to_hash(v) }
299
+ end
300
+ elsif value.respond_to?(:to_hash)
301
+ value.to_hash
302
+ else
303
+ value
304
+ end
305
+ end
306
+
307
+ end
308
+
309
+ end
310
+ end
@@ -7,7 +7,7 @@ require "time"
7
7
 
8
8
  module Algolia
9
9
  module Ingestion
10
- # API request body for updating a task.
10
+ # API request body for partially updating a task.
11
11
  class TaskUpdate
12
12
  # Universally unique identifier (UUID) of a destination resource.
13
13
  attr_accessor :destination_id
@@ -14,7 +14,7 @@ module Algolia
14
14
  # Records you want to pin to a specific position in the search results. You can promote up to 300 records, either individually, or as groups of up to 100 records each.
15
15
  attr_accessor :promote
16
16
 
17
- # Whether promoted records must match an active filter for the consequence to be applied. This ensures that user actions (filtering the search) are given a higher precendence. For example, if you promote a record with the `color: red` attribute, and the user filters the search for `color: blue`, the \"red\" record won't be shown.
17
+ # Determines whether promoted records must also match active filters for the consequence to apply. This ensures user-applied filters take priority and irrelevant matches aren't shown. For example, if you promote a record with `color: red` but the user filters for `color: blue`, the \"red\" record won't be shown. > In the Algolia dashboard, when you use the **Pin an item** consequence, `filterPromotes` appears as the checkbox: **Pinned items must match active filters to be displayed.** For examples, see [Promote results with rules](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/promote-hits/#promote-results-matching-active-filters).
18
18
  attr_accessor :filter_promotes
19
19
 
20
20
  # Records you want to hide from the search results.