algolia 3.17.0 → 3.18.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/models/ingestion/watch_response.rb +3 -3
- data/lib/algolia/models/search/event.rb +281 -0
- data/lib/algolia/models/search/event_status.rb +38 -0
- data/lib/algolia/models/search/event_type.rb +36 -0
- data/lib/algolia/models/search/watch_response.rb +265 -0
- data/lib/algolia/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cfef852f09fa892158dfa5646a677e6f5bd6a47aa649d79fe72e300585a69a2
|
4
|
+
data.tar.gz: 56d4eaeff8861511b24bb147044242d50db46efdf8316c2948507eae857d7574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7b274ed915307ed33e727e98d8203be3b1617bd12fa5969e6db593079616ead2de5ce062e8fc17c605e64777c6da7695eb5b92bfaa3305598032f33c61e9fe
|
7
|
+
data.tar.gz: 4b0149c96e2a05b5c8cbca0d336fadb398fa28e939909526c0d340d841a9ede02b79dc3695084f465d004412450448e56dbac727d40fe6d5e8f6f8b867c6b083
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [3.18.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.17.0...3.18.0)
|
2
|
+
|
3
|
+
- [835daccb48](https://github.com/algolia/api-clients-automation/commit/835daccb48) feat(specs): add with transformation helpers ([#4931](https://github.com/algolia/api-clients-automation/pull/4931)) by [@shortcuts](https://github.com/shortcuts/)
|
4
|
+
|
1
5
|
## [3.17.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.16.0...3.17.0)
|
2
6
|
|
3
7
|
- [9db03b532b](https://github.com/algolia/api-clients-automation/commit/9db03b532b) fix(specs): typo ([#4854](https://github.com/algolia/api-clients-automation/pull/4854)) by [@kai687](https://github.com/kai687/)
|
data/Gemfile.lock
CHANGED
@@ -14,13 +14,13 @@ module Algolia
|
|
14
14
|
# Universally unique identifier (UUID) of an event.
|
15
15
|
attr_accessor :event_id
|
16
16
|
|
17
|
-
# when used with
|
17
|
+
# This field is always null when used with the Push endpoint. When used for a source discover or source validate run, it will include the sampled data of the source.
|
18
18
|
attr_accessor :data
|
19
19
|
|
20
|
-
# in case of error, observability events will be added to the response
|
20
|
+
# in case of error, observability events will be added to the response.
|
21
21
|
attr_accessor :events
|
22
22
|
|
23
|
-
# a message describing the outcome of
|
23
|
+
# a message describing the outcome of the operation that has been ran (push, discover or validate) run.
|
24
24
|
attr_accessor :message
|
25
25
|
|
26
26
|
# Date of creation in RFC 3339 format.
|
@@ -0,0 +1,281 @@
|
|
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 Search
|
10
|
+
# An event describe a step of the task execution flow..
|
11
|
+
class Event
|
12
|
+
# Universally unique identifier (UUID) of an event.
|
13
|
+
attr_accessor :event_id
|
14
|
+
|
15
|
+
# Universally unique identifier (UUID) of a task run.
|
16
|
+
attr_accessor :run_id
|
17
|
+
|
18
|
+
attr_accessor :status
|
19
|
+
|
20
|
+
attr_accessor :type
|
21
|
+
|
22
|
+
# The extracted record batch size.
|
23
|
+
attr_accessor :batch_size
|
24
|
+
|
25
|
+
attr_accessor :data
|
26
|
+
|
27
|
+
# Date of publish RFC 3339 format.
|
28
|
+
attr_accessor :published_at
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:event_id => :eventID,
|
34
|
+
:run_id => :runID,
|
35
|
+
:status => :status,
|
36
|
+
:type => :type,
|
37
|
+
:batch_size => :batchSize,
|
38
|
+
:data => :data,
|
39
|
+
:published_at => :publishedAt
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute type mapping.
|
44
|
+
def self.types_mapping
|
45
|
+
{
|
46
|
+
:event_id => :"String",
|
47
|
+
:run_id => :"String",
|
48
|
+
:status => :"EventStatus",
|
49
|
+
:type => :"EventType",
|
50
|
+
:batch_size => :"Integer",
|
51
|
+
:data => :"Hash<String, Object>",
|
52
|
+
:published_at => :"String"
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
# List of attributes with nullable: true
|
57
|
+
def self.openapi_nullable
|
58
|
+
Set.new(
|
59
|
+
[
|
60
|
+
:status,
|
61
|
+
:data
|
62
|
+
]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes the object
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
+
def initialize(attributes = {})
|
69
|
+
if (!attributes.is_a?(Hash))
|
70
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Event` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
+
raise(
|
77
|
+
ArgumentError,
|
78
|
+
"`#{k}` is not a valid attribute in `Algolia::Event`. Please check the name to make sure it's valid. List of attributes: " +
|
79
|
+
self.class.attribute_map.keys.inspect
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:event_id)
|
87
|
+
self.event_id = attributes[:event_id]
|
88
|
+
else
|
89
|
+
self.event_id = nil
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:run_id)
|
93
|
+
self.run_id = attributes[:run_id]
|
94
|
+
else
|
95
|
+
self.run_id = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:status)
|
99
|
+
self.status = attributes[:status]
|
100
|
+
else
|
101
|
+
self.status = nil
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.key?(:type)
|
105
|
+
self.type = attributes[:type]
|
106
|
+
else
|
107
|
+
self.type = nil
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:batch_size)
|
111
|
+
self.batch_size = attributes[:batch_size]
|
112
|
+
else
|
113
|
+
self.batch_size = nil
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:data)
|
117
|
+
if (value = attributes[:data]).is_a?(Hash)
|
118
|
+
self.data = value
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:published_at)
|
123
|
+
self.published_at = attributes[:published_at]
|
124
|
+
else
|
125
|
+
self.published_at = nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Checks equality by comparing each attribute.
|
130
|
+
# @param [Object] Object to be compared
|
131
|
+
def ==(other)
|
132
|
+
return true if self.equal?(other)
|
133
|
+
self.class == other.class &&
|
134
|
+
event_id == other.event_id &&
|
135
|
+
run_id == other.run_id &&
|
136
|
+
status == other.status &&
|
137
|
+
type == other.type &&
|
138
|
+
batch_size == other.batch_size &&
|
139
|
+
data == other.data &&
|
140
|
+
published_at == other.published_at
|
141
|
+
end
|
142
|
+
|
143
|
+
# @see the `==` method
|
144
|
+
# @param [Object] Object to be compared
|
145
|
+
def eql?(other)
|
146
|
+
self == other
|
147
|
+
end
|
148
|
+
|
149
|
+
# Calculates hash code according to all attributes.
|
150
|
+
# @return [Integer] Hash code
|
151
|
+
def hash
|
152
|
+
[event_id, run_id, status, type, batch_size, data, published_at].hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# Builds the object from hash
|
156
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
157
|
+
# @return [Object] Returns the model itself
|
158
|
+
def self.build_from_hash(attributes)
|
159
|
+
return nil unless attributes.is_a?(Hash)
|
160
|
+
attributes = attributes.transform_keys(&:to_sym)
|
161
|
+
transformed_hash = {}
|
162
|
+
types_mapping.each_pair do |key, type|
|
163
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
164
|
+
transformed_hash[key.to_sym] = nil
|
165
|
+
elsif type =~ /\AArray<(.*)>/i
|
166
|
+
# check to ensure the input is an array given that the attribute
|
167
|
+
# is documented as an array but the input is not
|
168
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
169
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
170
|
+
_deserialize(::Regexp.last_match(1), v)
|
171
|
+
}
|
172
|
+
end
|
173
|
+
elsif !attributes[attribute_map[key]].nil?
|
174
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
new(transformed_hash)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Deserializes the data based on type
|
182
|
+
# @param string type Data type
|
183
|
+
# @param string value Value to be deserialized
|
184
|
+
# @return [Object] Deserialized data
|
185
|
+
def self._deserialize(type, value)
|
186
|
+
case type.to_sym
|
187
|
+
when :Time
|
188
|
+
Time.parse(value)
|
189
|
+
when :Date
|
190
|
+
Date.parse(value)
|
191
|
+
when :String
|
192
|
+
value.to_s
|
193
|
+
when :Integer
|
194
|
+
value.to_i
|
195
|
+
when :Float
|
196
|
+
value.to_f
|
197
|
+
when :Boolean
|
198
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
199
|
+
true
|
200
|
+
else
|
201
|
+
false
|
202
|
+
end
|
203
|
+
|
204
|
+
when :Object
|
205
|
+
# generic object (usually a Hash), return directly
|
206
|
+
value
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each do |k, v|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
# model
|
219
|
+
else
|
220
|
+
# models (e.g. Pet) or oneOf
|
221
|
+
klass = Algolia::Search.const_get(type)
|
222
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
223
|
+
.build_from_hash(value)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the string representation of the object
|
228
|
+
# @return [String] String presentation of the object
|
229
|
+
def to_s
|
230
|
+
to_hash.to_s
|
231
|
+
end
|
232
|
+
|
233
|
+
# to_body is an alias to to_hash (backward compatibility)
|
234
|
+
# @return [Hash] Returns the object in the form of hash
|
235
|
+
def to_body
|
236
|
+
to_hash
|
237
|
+
end
|
238
|
+
|
239
|
+
def to_json(*_args)
|
240
|
+
to_hash.to_json
|
241
|
+
end
|
242
|
+
|
243
|
+
# Returns the object in the form of hash
|
244
|
+
# @return [Hash] Returns the object in the form of hash
|
245
|
+
def to_hash
|
246
|
+
hash = {}
|
247
|
+
self.class.attribute_map.each_pair do |attr, param|
|
248
|
+
value = send(attr)
|
249
|
+
if value.nil?
|
250
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
251
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
252
|
+
end
|
253
|
+
|
254
|
+
hash[param] = _to_hash(value)
|
255
|
+
end
|
256
|
+
|
257
|
+
hash
|
258
|
+
end
|
259
|
+
|
260
|
+
# Outputs non-array value in the form of hash
|
261
|
+
# For object, use to_hash. Otherwise, just return the value
|
262
|
+
# @param [Object] value Any valid value
|
263
|
+
# @return [Hash] Returns the value in the form of hash
|
264
|
+
def _to_hash(value)
|
265
|
+
if value.is_a?(Array)
|
266
|
+
value.compact.map { |v| _to_hash(v) }
|
267
|
+
elsif value.is_a?(Hash)
|
268
|
+
{}.tap do |hash|
|
269
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
270
|
+
end
|
271
|
+
elsif value.respond_to?(:to_hash)
|
272
|
+
value.to_hash
|
273
|
+
else
|
274
|
+
value
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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 Search
|
10
|
+
class EventStatus
|
11
|
+
CREATED = "created".freeze
|
12
|
+
STARTED = "started".freeze
|
13
|
+
RETRIED = "retried".freeze
|
14
|
+
FAILED = "failed".freeze
|
15
|
+
SUCCEEDED = "succeeded".freeze
|
16
|
+
CRITICAL = "critical".freeze
|
17
|
+
|
18
|
+
def self.all_vars
|
19
|
+
@all_vars ||= [CREATED, STARTED, RETRIED, FAILED, SUCCEEDED, CRITICAL].freeze
|
20
|
+
end
|
21
|
+
|
22
|
+
# Builds the enum from string
|
23
|
+
# @param [String] The enum value in the form of the string
|
24
|
+
# @return [String] The enum value
|
25
|
+
def self.build_from_hash(value)
|
26
|
+
new.build_from_hash(value)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Builds the enum from string
|
30
|
+
# @param [String] The enum value in the form of the string
|
31
|
+
# @return [String] The enum value
|
32
|
+
def build_from_hash(value)
|
33
|
+
return value if EventStatus.all_vars.include?(value)
|
34
|
+
raise "Invalid ENUM value #{value} for class #EventStatus"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
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 Search
|
10
|
+
class EventType
|
11
|
+
FETCH = "fetch".freeze
|
12
|
+
RECORD = "record".freeze
|
13
|
+
LOG = "log".freeze
|
14
|
+
TRANSFORM = "transform".freeze
|
15
|
+
|
16
|
+
def self.all_vars
|
17
|
+
@all_vars ||= [FETCH, RECORD, LOG, TRANSFORM].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 EventType.all_vars.include?(value)
|
32
|
+
raise "Invalid ENUM value #{value} for class #EventType"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,265 @@
|
|
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 Search
|
10
|
+
class WatchResponse
|
11
|
+
# Universally unique identifier (UUID) of a task run.
|
12
|
+
attr_accessor :run_id
|
13
|
+
|
14
|
+
# Universally unique identifier (UUID) of an event.
|
15
|
+
attr_accessor :event_id
|
16
|
+
|
17
|
+
# This field is always null when used with the Push endpoint. When used for a source discover or source validate run, it will include the sampled data of the source.
|
18
|
+
attr_accessor :data
|
19
|
+
|
20
|
+
# in case of error, observability events will be added to the response.
|
21
|
+
attr_accessor :events
|
22
|
+
|
23
|
+
# a message describing the outcome of the operation that has been ran (push, discover or validate) run.
|
24
|
+
attr_accessor :message
|
25
|
+
|
26
|
+
# Date of creation in RFC 3339 format.
|
27
|
+
attr_accessor :created_at
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:run_id => :runID,
|
33
|
+
:event_id => :eventID,
|
34
|
+
:data => :data,
|
35
|
+
:events => :events,
|
36
|
+
:message => :message,
|
37
|
+
:created_at => :createdAt
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Attribute type mapping.
|
42
|
+
def self.types_mapping
|
43
|
+
{
|
44
|
+
:run_id => :"String",
|
45
|
+
:event_id => :"String",
|
46
|
+
:data => :"Array<Object>",
|
47
|
+
:events => :"Array<Event>",
|
48
|
+
:message => :"String",
|
49
|
+
:created_at => :"String"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
# List of attributes with nullable: true
|
54
|
+
def self.openapi_nullable
|
55
|
+
Set.new(
|
56
|
+
[]
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Initializes the object
|
61
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
62
|
+
def initialize(attributes = {})
|
63
|
+
if (!attributes.is_a?(Hash))
|
64
|
+
raise(
|
65
|
+
ArgumentError,
|
66
|
+
"The input argument (attributes) must be a hash in `Algolia::WatchResponse` initialize method"
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
72
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
73
|
+
raise(
|
74
|
+
ArgumentError,
|
75
|
+
"`#{k}` is not a valid attribute in `Algolia::WatchResponse`. Please check the name to make sure it's valid. List of attributes: " +
|
76
|
+
self.class.attribute_map.keys.inspect
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
h[k.to_sym] = v
|
81
|
+
}
|
82
|
+
|
83
|
+
if attributes.key?(:run_id)
|
84
|
+
self.run_id = attributes[:run_id]
|
85
|
+
else
|
86
|
+
self.run_id = nil
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:event_id)
|
90
|
+
self.event_id = attributes[:event_id]
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:data)
|
94
|
+
if (value = attributes[:data]).is_a?(Array)
|
95
|
+
self.data = value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.key?(:events)
|
100
|
+
if (value = attributes[:events]).is_a?(Array)
|
101
|
+
self.events = value
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:message)
|
106
|
+
self.message = attributes[:message]
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:created_at)
|
110
|
+
self.created_at = attributes[:created_at]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Checks equality by comparing each attribute.
|
115
|
+
# @param [Object] Object to be compared
|
116
|
+
def ==(other)
|
117
|
+
return true if self.equal?(other)
|
118
|
+
self.class == other.class &&
|
119
|
+
run_id == other.run_id &&
|
120
|
+
event_id == other.event_id &&
|
121
|
+
data == other.data &&
|
122
|
+
events == other.events &&
|
123
|
+
message == other.message &&
|
124
|
+
created_at == other.created_at
|
125
|
+
end
|
126
|
+
|
127
|
+
# @see the `==` method
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def eql?(other)
|
130
|
+
self == other
|
131
|
+
end
|
132
|
+
|
133
|
+
# Calculates hash code according to all attributes.
|
134
|
+
# @return [Integer] Hash code
|
135
|
+
def hash
|
136
|
+
[run_id, event_id, data, events, message, created_at].hash
|
137
|
+
end
|
138
|
+
|
139
|
+
# Builds the object from hash
|
140
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
141
|
+
# @return [Object] Returns the model itself
|
142
|
+
def self.build_from_hash(attributes)
|
143
|
+
return nil unless attributes.is_a?(Hash)
|
144
|
+
attributes = attributes.transform_keys(&:to_sym)
|
145
|
+
transformed_hash = {}
|
146
|
+
types_mapping.each_pair do |key, type|
|
147
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
148
|
+
transformed_hash[key.to_sym] = nil
|
149
|
+
elsif type =~ /\AArray<(.*)>/i
|
150
|
+
# check to ensure the input is an array given that the attribute
|
151
|
+
# is documented as an array but the input is not
|
152
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
153
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
154
|
+
_deserialize(::Regexp.last_match(1), v)
|
155
|
+
}
|
156
|
+
end
|
157
|
+
elsif !attributes[attribute_map[key]].nil?
|
158
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
new(transformed_hash)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Deserializes the data based on type
|
166
|
+
# @param string type Data type
|
167
|
+
# @param string value Value to be deserialized
|
168
|
+
# @return [Object] Deserialized data
|
169
|
+
def self._deserialize(type, value)
|
170
|
+
case type.to_sym
|
171
|
+
when :Time
|
172
|
+
Time.parse(value)
|
173
|
+
when :Date
|
174
|
+
Date.parse(value)
|
175
|
+
when :String
|
176
|
+
value.to_s
|
177
|
+
when :Integer
|
178
|
+
value.to_i
|
179
|
+
when :Float
|
180
|
+
value.to_f
|
181
|
+
when :Boolean
|
182
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
183
|
+
true
|
184
|
+
else
|
185
|
+
false
|
186
|
+
end
|
187
|
+
|
188
|
+
when :Object
|
189
|
+
# generic object (usually a Hash), return directly
|
190
|
+
value
|
191
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
192
|
+
inner_type = Regexp.last_match[:inner_type]
|
193
|
+
value.map { |v| _deserialize(inner_type, v) }
|
194
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
195
|
+
k_type = Regexp.last_match[:k_type]
|
196
|
+
v_type = Regexp.last_match[:v_type]
|
197
|
+
{}.tap do |hash|
|
198
|
+
value.each do |k, v|
|
199
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
# model
|
203
|
+
else
|
204
|
+
# models (e.g. Pet) or oneOf
|
205
|
+
klass = Algolia::Search.const_get(type)
|
206
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
207
|
+
.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
def to_json(*_args)
|
224
|
+
to_hash.to_json
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the object in the form of hash
|
228
|
+
# @return [Hash] Returns the object in the form of hash
|
229
|
+
def to_hash
|
230
|
+
hash = {}
|
231
|
+
self.class.attribute_map.each_pair do |attr, param|
|
232
|
+
value = send(attr)
|
233
|
+
if value.nil?
|
234
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
235
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
236
|
+
end
|
237
|
+
|
238
|
+
hash[param] = _to_hash(value)
|
239
|
+
end
|
240
|
+
|
241
|
+
hash
|
242
|
+
end
|
243
|
+
|
244
|
+
# Outputs non-array value in the form of hash
|
245
|
+
# For object, use to_hash. Otherwise, just return the value
|
246
|
+
# @param [Object] value Any valid value
|
247
|
+
# @return [Hash] Returns the value in the form of hash
|
248
|
+
def _to_hash(value)
|
249
|
+
if value.is_a?(Array)
|
250
|
+
value.compact.map { |v| _to_hash(v) }
|
251
|
+
elsif value.is_a?(Hash)
|
252
|
+
{}.tap do |hash|
|
253
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
254
|
+
end
|
255
|
+
elsif value.respond_to?(:to_hash)
|
256
|
+
value.to_hash
|
257
|
+
else
|
258
|
+
value
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
end
|
data/lib/algolia/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://alg.li/support
|
@@ -626,6 +626,9 @@ files:
|
|
626
626
|
- lib/algolia/models/search/edit.rb
|
627
627
|
- lib/algolia/models/search/edit_type.rb
|
628
628
|
- lib/algolia/models/search/error_base.rb
|
629
|
+
- lib/algolia/models/search/event.rb
|
630
|
+
- lib/algolia/models/search/event_status.rb
|
631
|
+
- lib/algolia/models/search/event_type.rb
|
629
632
|
- lib/algolia/models/search/exact_on_single_word_query.rb
|
630
633
|
- lib/algolia/models/search/exhaustive.rb
|
631
634
|
- lib/algolia/models/search/facet_filters.rb
|
@@ -735,6 +738,7 @@ files:
|
|
735
738
|
- lib/algolia/models/search/user_hit.rb
|
736
739
|
- lib/algolia/models/search/user_id.rb
|
737
740
|
- lib/algolia/models/search/value.rb
|
741
|
+
- lib/algolia/models/search/watch_response.rb
|
738
742
|
- lib/algolia/models/search/widgets.rb
|
739
743
|
- lib/algolia/transport/call_type.rb
|
740
744
|
- lib/algolia/transport/echo_requester.rb
|