algolia 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,217 +0,0 @@
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 Recommend
8
- # Settings for the semantic search part of NeuralSearch. Only used when `mode` is `neuralSearch`.
9
- class SemanticSearch
10
- # Indices from which to collect click and conversion events. If null, the current index and all its replicas are used.
11
- attr_accessor :event_sources
12
-
13
- # Attribute mapping from ruby-style variable name to JSON key.
14
- def self.attribute_map
15
- {
16
- :event_sources => :eventSources
17
- }
18
- end
19
-
20
- # Returns all the JSON keys this model knows about
21
- def self.acceptable_attributes
22
- attribute_map.values
23
- end
24
-
25
- # Attribute type mapping.
26
- def self.types_mapping
27
- {
28
- :event_sources => :"Array<String>"
29
- }
30
- end
31
-
32
- # List of attributes with nullable: true
33
- def self.openapi_nullable
34
- Set.new(
35
- [
36
- :event_sources
37
- ]
38
- )
39
- end
40
-
41
- # Initializes the object
42
- # @param [Hash] attributes Model attributes in the form of hash
43
- def initialize(attributes = {})
44
- if (!attributes.is_a?(Hash))
45
- raise(
46
- ArgumentError,
47
- "The input argument (attributes) must be a hash in `Algolia::SemanticSearch` initialize method"
48
- )
49
- end
50
-
51
- # check to see if the attribute exists and convert string to symbol for hash key
52
- attributes = attributes.each_with_object({}) { |(k, v), h|
53
- if (!self.class.attribute_map.key?(k.to_sym))
54
- raise(
55
- ArgumentError,
56
- "`#{k}` is not a valid attribute in `Algolia::SemanticSearch`. Please check the name to make sure it's valid. List of attributes: " +
57
- self.class.attribute_map.keys.inspect
58
- )
59
- end
60
-
61
- h[k.to_sym] = v
62
- }
63
-
64
- if attributes.key?(:event_sources)
65
- if (value = attributes[:event_sources]).is_a?(Array)
66
- self.event_sources = value
67
- end
68
- end
69
- end
70
-
71
- # Checks equality by comparing each attribute.
72
- # @param [Object] Object to be compared
73
- def ==(other)
74
- return true if self.equal?(other)
75
- self.class == other.class &&
76
- event_sources == other.event_sources
77
- end
78
-
79
- # @see the `==` method
80
- # @param [Object] Object to be compared
81
- def eql?(other)
82
- self == other
83
- end
84
-
85
- # Calculates hash code according to all attributes.
86
- # @return [Integer] Hash code
87
- def hash
88
- [event_sources].hash
89
- end
90
-
91
- # Builds the object from hash
92
- # @param [Hash] attributes Model attributes in the form of hash
93
- # @return [Object] Returns the model itself
94
- def self.build_from_hash(attributes)
95
- return nil unless attributes.is_a?(Hash)
96
- attributes = attributes.transform_keys(&:to_sym)
97
- transformed_hash = {}
98
- types_mapping.each_pair do |key, type|
99
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
100
- transformed_hash[key.to_sym] = nil
101
- elsif type =~ /\AArray<(.*)>/i
102
- # check to ensure the input is an array given that the attribute
103
- # is documented as an array but the input is not
104
- if attributes[attribute_map[key]].is_a?(Array)
105
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
106
- _deserialize(::Regexp.last_match(1), v)
107
- }
108
- end
109
- elsif !attributes[attribute_map[key]].nil?
110
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
111
- end
112
- end
113
-
114
- new(transformed_hash)
115
- end
116
-
117
- # Deserializes the data based on type
118
- # @param string type Data type
119
- # @param string value Value to be deserialized
120
- # @return [Object] Deserialized data
121
- def self._deserialize(type, value)
122
- case type.to_sym
123
- when :Time
124
- Time.parse(value)
125
- when :Date
126
- Date.parse(value)
127
- when :String
128
- value.to_s
129
- when :Integer
130
- value.to_i
131
- when :Float
132
- value.to_f
133
- when :Boolean
134
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
135
- true
136
- else
137
- false
138
- end
139
-
140
- when :Object
141
- # generic object (usually a Hash), return directly
142
- value
143
- when /\AArray<(?<inner_type>.+)>\z/
144
- inner_type = Regexp.last_match[:inner_type]
145
- value.map { |v| _deserialize(inner_type, v) }
146
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
147
- k_type = Regexp.last_match[:k_type]
148
- v_type = Regexp.last_match[:v_type]
149
- {}.tap do |hash|
150
- value.each do |k, v|
151
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
152
- end
153
- end
154
- # model
155
- else
156
- # models (e.g. Pet) or oneOf
157
- klass = Algolia::Recommend.const_get(type)
158
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
159
- .build_from_hash(value)
160
- end
161
- end
162
-
163
- # Returns the string representation of the object
164
- # @return [String] String presentation of the object
165
- def to_s
166
- to_hash.to_s
167
- end
168
-
169
- # to_body is an alias to to_hash (backward compatibility)
170
- # @return [Hash] Returns the object in the form of hash
171
- def to_body
172
- to_hash
173
- end
174
-
175
- def to_json(*_args)
176
- to_hash.to_json
177
- end
178
-
179
- # Returns the object in the form of hash
180
- # @return [Hash] Returns the object in the form of hash
181
- def to_hash
182
- hash = {}
183
- self.class.attribute_map.each_pair do |attr, param|
184
- value = send(attr)
185
- if value.nil?
186
- is_nullable = self.class.openapi_nullable.include?(attr)
187
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
- end
189
-
190
- hash[param] = _to_hash(value)
191
- end
192
-
193
- hash
194
- end
195
-
196
- # Outputs non-array value in the form of hash
197
- # For object, use to_hash. Otherwise, just return the value
198
- # @param [Object] value Any valid value
199
- # @return [Hash] Returns the value in the form of hash
200
- def _to_hash(value)
201
- if value.is_a?(Array)
202
- value.compact.map { |v| _to_hash(v) }
203
- elsif value.is_a?(Hash)
204
- {}.tap do |hash|
205
- value.each { |k, v| hash[k] = _to_hash(v) }
206
- end
207
- elsif value.respond_to?(:to_hash)
208
- value.to_hash
209
- else
210
- value
211
- end
212
- end
213
-
214
- end
215
-
216
- end
217
- end