algolia 3.15.3 → 3.15.5
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/.github/workflows/release.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +5 -5
- data/lib/algolia/api/search_client.rb +2 -2
- data/lib/algolia/models/ingestion/destination_input.rb +206 -82
- data/lib/algolia/models/ingestion/event.rb +4 -1
- data/lib/algolia/models/ingestion/record_type.rb +2 -1
- data/lib/algolia/models/ingestion/source_docker.rb +1 -1
- data/lib/algolia/models/search/condition.rb +1 -1
- data/lib/algolia/transport/http/http_requester.rb +1 -1
- data/lib/algolia/version.rb +1 -1
- metadata +3 -4
- data/lib/algolia/models/ingestion/destination_index_name.rb +0 -232
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 866c3b0ca3aeefdf7eac97bc971e746f161b53ac53807083a28223a933e27a49
|
4
|
+
data.tar.gz: f1b7931dfcee757ea5bf242f5a89df2b613bb2e27f1ebdd318197589e632a920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46aeb23ea063e85a8ed25baec6910c3099c1bbd31d46d0393fbcad90acc33bc3f4c62b8e5f891f9ae870e3bed301fb7509314e796cf1950775f27656a5c36d58
|
7
|
+
data.tar.gz: f74c062ec55982f8fd360bd60aacdc65b72e2646bdc76392b75353f5b833df335548dfbe24465091ab2cf7f9fd1bd9dee45c4cdf7da199d8498a869abd7a984b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## [3.15.5](https://github.com/algolia/algoliasearch-client-ruby/compare/3.15.4...3.15.5)
|
2
|
+
|
3
|
+
- [efec6baf1c](https://github.com/algolia/api-clients-automation/commit/efec6baf1c) chore(deps): dependencies 2025-04-21 ([#4762](https://github.com/algolia/api-clients-automation/pull/4762)) by [@algolia-bot](https://github.com/algolia-bot/)
|
4
|
+
- [53ac749807](https://github.com/algolia/api-clients-automation/commit/53ac749807) chore(deps): dependencies 2025-04-28 ([#4785](https://github.com/algolia/api-clients-automation/pull/4785)) by [@algolia-bot](https://github.com/algolia-bot/)
|
5
|
+
|
6
|
+
## [3.15.4](https://github.com/algolia/algoliasearch-client-ruby/compare/3.15.3...3.15.4)
|
7
|
+
|
8
|
+
- [369c14232](https://github.com/algolia/api-clients-automation/commit/369c14232) fix(specs): condition cant be numeric filter ([#4726](https://github.com/algolia/api-clients-automation/pull/4726)) by [@kai687](https://github.com/kai687/)
|
9
|
+
- [1911d224b](https://github.com/algolia/api-clients-automation/commit/1911d224b) fix(specs): event.status can be null ([#4727](https://github.com/algolia/api-clients-automation/pull/4727)) by [@millotp](https://github.com/millotp/)
|
10
|
+
- [a18b555b4](https://github.com/algolia/api-clients-automation/commit/a18b555b4) fix(specs): add missing recordType collection ([#4728](https://github.com/algolia/api-clients-automation/pull/4728)) by [@millotp](https://github.com/millotp/)
|
11
|
+
- [b8d187623](https://github.com/algolia/api-clients-automation/commit/b8d187623) fix(ruby): avoid mutating frozen string literals by replacing upcase! ([#4755](https://github.com/algolia/api-clients-automation/pull/4755)) by [@satoruk](https://github.com/satoruk/)
|
12
|
+
- [4570f18b8](https://github.com/algolia/api-clients-automation/commit/4570f18b8) fix(clients): correctly deserialize SearchResult ([#4756](https://github.com/algolia/api-clients-automation/pull/4756)) by [@millotp](https://github.com/millotp/)
|
13
|
+
|
1
14
|
## [3.15.3](https://github.com/algolia/algoliasearch-client-ruby/compare/3.15.2...3.15.3)
|
2
15
|
|
3
16
|
- [dbaef6696](https://github.com/algolia/api-clients-automation/commit/dbaef6696) fix(specs): userData is any type ([#4702](https://github.com/algolia/api-clients-automation/pull/4702)) by [@millotp](https://github.com/millotp/)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
algolia (3.15.
|
4
|
+
algolia (3.15.5)
|
5
5
|
base64 (>= 0.2.0, < 1)
|
6
6
|
faraday (>= 1.0.1, < 3.0)
|
7
7
|
faraday-net_http_persistent (>= 0.15, < 3)
|
@@ -11,8 +11,8 @@ GEM
|
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
13
|
base64 (0.2.0)
|
14
|
-
connection_pool (2.5.
|
15
|
-
faraday (2.
|
14
|
+
connection_pool (2.5.2)
|
15
|
+
faraday (2.13.1)
|
16
16
|
faraday-net_http (>= 2.0, < 3.5)
|
17
17
|
json
|
18
18
|
logger
|
@@ -21,8 +21,8 @@ GEM
|
|
21
21
|
faraday-net_http_persistent (2.3.0)
|
22
22
|
faraday (~> 2.5)
|
23
23
|
net-http-persistent (>= 4.0.4, < 5)
|
24
|
-
json (2.
|
25
|
-
logger (1.
|
24
|
+
json (2.11.3)
|
25
|
+
logger (1.7.0)
|
26
26
|
net-http (0.6.0)
|
27
27
|
uri
|
28
28
|
net-http-persistent (4.0.5)
|
@@ -2603,7 +2603,7 @@ module Algolia
|
|
2603
2603
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
|
2604
2604
|
end
|
2605
2605
|
|
2606
|
-
# Sends multiple search requests to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters.
|
2606
|
+
# Sends multiple search requests to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters. Use the helper `searchForHits` or `searchForFacets` to get the results in a more convenient format, if you already know the return type you want.
|
2607
2607
|
#
|
2608
2608
|
# Required API Key ACLs:
|
2609
2609
|
# - search
|
@@ -2635,7 +2635,7 @@ module Algolia
|
|
2635
2635
|
@api_client.call_api(:POST, path, new_options)
|
2636
2636
|
end
|
2637
2637
|
|
2638
|
-
# Sends multiple search requests to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters.
|
2638
|
+
# Sends multiple search requests to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters. Use the helper `searchForHits` or `searchForFacets` to get the results in a more convenient format, if you already know the return type you want.
|
2639
2639
|
#
|
2640
2640
|
# Required API Key ACLs:
|
2641
2641
|
# - search
|
@@ -7,101 +7,225 @@ require "time"
|
|
7
7
|
|
8
8
|
module Algolia
|
9
9
|
module Ingestion
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
class DestinationInput
|
11
|
+
# Algolia index name (case-sensitive).
|
12
|
+
attr_accessor :index_name
|
13
|
+
|
14
|
+
attr_accessor :record_type
|
15
|
+
|
16
|
+
# Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array.
|
17
|
+
attr_accessor :attributes_to_exclude
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:index_name => :indexName,
|
23
|
+
:record_type => :recordType,
|
24
|
+
:attributes_to_exclude => :attributesToExclude
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.types_mapping
|
30
|
+
{
|
31
|
+
:index_name => :"String",
|
32
|
+
:record_type => :"RecordType",
|
33
|
+
:attributes_to_exclude => :"Array<String>"
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# List of attributes with nullable: true
|
38
|
+
def self.openapi_nullable
|
39
|
+
Set.new(
|
40
|
+
[]
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
if (!attributes.is_a?(Hash))
|
48
|
+
raise(
|
49
|
+
ArgumentError,
|
50
|
+
"The input argument (attributes) must be a hash in `Algolia::DestinationInput` initialize method"
|
51
|
+
)
|
17
52
|
end
|
18
53
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
28
|
-
# - TODO: scalar values are de facto behaving as if they were nullable.
|
29
|
-
# - TODO: logging when debugging is set.
|
30
|
-
openapi_one_of.each do |klass|
|
31
|
-
begin
|
32
|
-
# "nullable: true"
|
33
|
-
next if klass == :AnyType
|
34
|
-
typed_data = find_and_cast_into_type(klass, data)
|
35
|
-
return typed_data if typed_data
|
36
|
-
# rescue all errors so we keep iterating even if the current item lookup raises
|
37
|
-
rescue
|
38
|
-
end
|
54
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
55
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
56
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
57
|
+
raise(
|
58
|
+
ArgumentError,
|
59
|
+
"`#{k}` is not a valid attribute in `Algolia::DestinationInput`. Please check the name to make sure it's valid. List of attributes: " +
|
60
|
+
self.class.attribute_map.keys.inspect
|
61
|
+
)
|
39
62
|
end
|
40
63
|
|
41
|
-
|
64
|
+
h[k.to_sym] = v
|
65
|
+
}
|
66
|
+
|
67
|
+
if attributes.key?(:index_name)
|
68
|
+
self.index_name = attributes[:index_name]
|
69
|
+
else
|
70
|
+
self.index_name = nil
|
42
71
|
end
|
43
72
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
if attributes.key?(:record_type)
|
74
|
+
self.record_type = attributes[:record_type]
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:attributes_to_exclude)
|
78
|
+
if (value = attributes[:attributes_to_exclude]).is_a?(Array)
|
79
|
+
self.attributes_to_exclude = value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Checks equality by comparing each attribute.
|
85
|
+
# @param [Object] Object to be compared
|
86
|
+
def ==(other)
|
87
|
+
return true if self.equal?(other)
|
88
|
+
self.class == other.class &&
|
89
|
+
index_name == other.index_name &&
|
90
|
+
record_type == other.record_type &&
|
91
|
+
attributes_to_exclude == other.attributes_to_exclude
|
92
|
+
end
|
93
|
+
|
94
|
+
# @see the `==` method
|
95
|
+
# @param [Object] Object to be compared
|
96
|
+
def eql?(other)
|
97
|
+
self == other
|
98
|
+
end
|
99
|
+
|
100
|
+
# Calculates hash code according to all attributes.
|
101
|
+
# @return [Integer] Hash code
|
102
|
+
def hash
|
103
|
+
[index_name, record_type, attributes_to_exclude].hash
|
104
|
+
end
|
105
|
+
|
106
|
+
# Builds the object from hash
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
# @return [Object] Returns the model itself
|
109
|
+
def self.build_from_hash(attributes)
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
111
|
+
attributes = attributes.transform_keys(&:to_sym)
|
112
|
+
transformed_hash = {}
|
113
|
+
types_mapping.each_pair do |key, type|
|
114
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
115
|
+
transformed_hash[key.to_sym] = nil
|
116
|
+
elsif type =~ /\AArray<(.*)>/i
|
117
|
+
# check to ensure the input is an array given that the attribute
|
118
|
+
# is documented as an array but the input is not
|
119
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
120
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
121
|
+
_deserialize(::Regexp.last_match(1), v)
|
122
|
+
}
|
78
123
|
end
|
79
|
-
|
124
|
+
elsif !attributes[attribute_map[key]].nil?
|
125
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
new(transformed_hash)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deserializes the data based on type
|
133
|
+
# @param string type Data type
|
134
|
+
# @param string value Value to be deserialized
|
135
|
+
# @return [Object] Deserialized data
|
136
|
+
def self._deserialize(type, value)
|
137
|
+
case type.to_sym
|
138
|
+
when :Time
|
139
|
+
Time.parse(value)
|
140
|
+
when :Date
|
141
|
+
Date.parse(value)
|
142
|
+
when :String
|
143
|
+
value.to_s
|
144
|
+
when :Integer
|
145
|
+
value.to_i
|
146
|
+
when :Float
|
147
|
+
value.to_f
|
148
|
+
when :Boolean
|
149
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
150
|
+
true
|
80
151
|
else
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
152
|
+
false
|
153
|
+
end
|
154
|
+
|
155
|
+
when :Object
|
156
|
+
# generic object (usually a Hash), return directly
|
157
|
+
value
|
158
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
159
|
+
inner_type = Regexp.last_match[:inner_type]
|
160
|
+
value.map { |v| _deserialize(inner_type, v) }
|
161
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
162
|
+
k_type = Regexp.last_match[:k_type]
|
163
|
+
v_type = Regexp.last_match[:v_type]
|
164
|
+
{}.tap do |hash|
|
165
|
+
value.each do |k, v|
|
166
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
96
167
|
end
|
97
168
|
end
|
169
|
+
# model
|
170
|
+
else
|
171
|
+
# models (e.g. Pet) or oneOf
|
172
|
+
klass = Algolia::Ingestion.const_get(type)
|
173
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
174
|
+
.build_from_hash(value)
|
175
|
+
end
|
176
|
+
end
|
98
177
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
178
|
+
# Returns the string representation of the object
|
179
|
+
# @return [String] String presentation of the object
|
180
|
+
def to_s
|
181
|
+
to_hash.to_s
|
182
|
+
end
|
183
|
+
|
184
|
+
# to_body is an alias to to_hash (backward compatibility)
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
186
|
+
def to_body
|
187
|
+
to_hash
|
188
|
+
end
|
189
|
+
|
190
|
+
def to_json(*_args)
|
191
|
+
to_hash.to_json
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the object in the form of hash
|
195
|
+
# @return [Hash] Returns the object in the form of hash
|
196
|
+
def to_hash
|
197
|
+
hash = {}
|
198
|
+
self.class.attribute_map.each_pair do |attr, param|
|
199
|
+
value = send(attr)
|
200
|
+
if value.nil?
|
201
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
202
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
203
|
+
end
|
204
|
+
|
205
|
+
hash[param] = _to_hash(value)
|
103
206
|
end
|
207
|
+
|
208
|
+
hash
|
104
209
|
end
|
210
|
+
|
211
|
+
# Outputs non-array value in the form of hash
|
212
|
+
# For object, use to_hash. Otherwise, just return the value
|
213
|
+
# @param [Object] value Any valid value
|
214
|
+
# @return [Hash] Returns the value in the form of hash
|
215
|
+
def _to_hash(value)
|
216
|
+
if value.is_a?(Array)
|
217
|
+
value.compact.map { |v| _to_hash(v) }
|
218
|
+
elsif value.is_a?(Hash)
|
219
|
+
{}.tap do |hash|
|
220
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
221
|
+
end
|
222
|
+
elsif value.respond_to?(:to_hash)
|
223
|
+
value.to_hash
|
224
|
+
else
|
225
|
+
value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
105
229
|
end
|
106
230
|
|
107
231
|
end
|
@@ -10,9 +10,10 @@ module Algolia
|
|
10
10
|
class RecordType
|
11
11
|
PRODUCT = "product".freeze
|
12
12
|
VARIANT = "variant".freeze
|
13
|
+
COLLECTION = "collection".freeze
|
13
14
|
|
14
15
|
def self.all_vars
|
15
|
-
@all_vars ||= [PRODUCT, VARIANT].freeze
|
16
|
+
@all_vars ||= [PRODUCT, VARIANT, COLLECTION].freeze
|
16
17
|
end
|
17
18
|
|
18
19
|
# Builds the enum from string
|
@@ -19,7 +19,7 @@ module Algolia
|
|
19
19
|
# An additional restriction that only triggers the rule, when the search has the same value as `ruleContexts` parameter. For example, if `context: mobile`, the rule is only triggered when the search request has a matching `ruleContexts: mobile`. A rule context must only contain alphanumeric characters.
|
20
20
|
attr_accessor :context
|
21
21
|
|
22
|
-
# Filters that trigger the rule. You can add
|
22
|
+
# Filters that trigger the rule. You can add filters using the syntax `facet:value` so that the rule is triggered, when the specific filter is selected. You can use `filters` on its own or combine it with the `pattern` parameter. You can't combine multiple filters with `OR` and you can't use numeric filters.
|
23
23
|
attr_accessor :filters
|
24
24
|
|
25
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -30,7 +30,7 @@ module Algolia
|
|
30
30
|
connection.options.open_timeout = connect_timeout / 1000
|
31
31
|
path += handle_query_params(query_params)
|
32
32
|
|
33
|
-
@logger.info("Sending #{method.to_s.upcase
|
33
|
+
@logger.info("Sending #{method.to_s.upcase} request to #{path} with body #{body}") if ENV["ALGOLIA_DEBUG"]
|
34
34
|
|
35
35
|
response = connection.run_request(method, path, body, headers)
|
36
36
|
|
data/lib/algolia/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.15.
|
4
|
+
version: 3.15.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://alg.li/support
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: faraday
|
@@ -307,7 +307,6 @@ files:
|
|
307
307
|
- lib/algolia/models/ingestion/destination.rb
|
308
308
|
- lib/algolia/models/ingestion/destination_create.rb
|
309
309
|
- lib/algolia/models/ingestion/destination_create_response.rb
|
310
|
-
- lib/algolia/models/ingestion/destination_index_name.rb
|
311
310
|
- lib/algolia/models/ingestion/destination_input.rb
|
312
311
|
- lib/algolia/models/ingestion/destination_search.rb
|
313
312
|
- lib/algolia/models/ingestion/destination_sort_keys.rb
|
@@ -765,7 +764,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
765
764
|
- !ruby/object:Gem::Version
|
766
765
|
version: '0'
|
767
766
|
requirements: []
|
768
|
-
rubygems_version: 3.6.
|
767
|
+
rubygems_version: 3.6.7
|
769
768
|
specification_version: 4
|
770
769
|
summary: A simple Ruby client for the algolia.com REST API
|
771
770
|
test_files: []
|
@@ -1,232 +0,0 @@
|
|
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
|
-
class DestinationIndexName
|
11
|
-
# Algolia index name (case-sensitive).
|
12
|
-
attr_accessor :index_name
|
13
|
-
|
14
|
-
attr_accessor :record_type
|
15
|
-
|
16
|
-
# Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array.
|
17
|
-
attr_accessor :attributes_to_exclude
|
18
|
-
|
19
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
-
def self.attribute_map
|
21
|
-
{
|
22
|
-
:index_name => :indexName,
|
23
|
-
:record_type => :recordType,
|
24
|
-
:attributes_to_exclude => :attributesToExclude
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
# Attribute type mapping.
|
29
|
-
def self.types_mapping
|
30
|
-
{
|
31
|
-
:index_name => :"String",
|
32
|
-
:record_type => :"RecordType",
|
33
|
-
:attributes_to_exclude => :"Array<String>"
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
# List of attributes with nullable: true
|
38
|
-
def self.openapi_nullable
|
39
|
-
Set.new(
|
40
|
-
[]
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Initializes the object
|
45
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
-
def initialize(attributes = {})
|
47
|
-
if (!attributes.is_a?(Hash))
|
48
|
-
raise(
|
49
|
-
ArgumentError,
|
50
|
-
"The input argument (attributes) must be a hash in `Algolia::DestinationIndexName` initialize method"
|
51
|
-
)
|
52
|
-
end
|
53
|
-
|
54
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
55
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
56
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
57
|
-
raise(
|
58
|
-
ArgumentError,
|
59
|
-
"`#{k}` is not a valid attribute in `Algolia::DestinationIndexName`. Please check the name to make sure it's valid. List of attributes: " +
|
60
|
-
self.class.attribute_map.keys.inspect
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
h[k.to_sym] = v
|
65
|
-
}
|
66
|
-
|
67
|
-
if attributes.key?(:index_name)
|
68
|
-
self.index_name = attributes[:index_name]
|
69
|
-
else
|
70
|
-
self.index_name = nil
|
71
|
-
end
|
72
|
-
|
73
|
-
if attributes.key?(:record_type)
|
74
|
-
self.record_type = attributes[:record_type]
|
75
|
-
end
|
76
|
-
|
77
|
-
if attributes.key?(:attributes_to_exclude)
|
78
|
-
if (value = attributes[:attributes_to_exclude]).is_a?(Array)
|
79
|
-
self.attributes_to_exclude = value
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# Checks equality by comparing each attribute.
|
85
|
-
# @param [Object] Object to be compared
|
86
|
-
def ==(other)
|
87
|
-
return true if self.equal?(other)
|
88
|
-
self.class == other.class &&
|
89
|
-
index_name == other.index_name &&
|
90
|
-
record_type == other.record_type &&
|
91
|
-
attributes_to_exclude == other.attributes_to_exclude
|
92
|
-
end
|
93
|
-
|
94
|
-
# @see the `==` method
|
95
|
-
# @param [Object] Object to be compared
|
96
|
-
def eql?(other)
|
97
|
-
self == other
|
98
|
-
end
|
99
|
-
|
100
|
-
# Calculates hash code according to all attributes.
|
101
|
-
# @return [Integer] Hash code
|
102
|
-
def hash
|
103
|
-
[index_name, record_type, attributes_to_exclude].hash
|
104
|
-
end
|
105
|
-
|
106
|
-
# Builds the object from hash
|
107
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
-
# @return [Object] Returns the model itself
|
109
|
-
def self.build_from_hash(attributes)
|
110
|
-
return nil unless attributes.is_a?(Hash)
|
111
|
-
attributes = attributes.transform_keys(&:to_sym)
|
112
|
-
transformed_hash = {}
|
113
|
-
types_mapping.each_pair do |key, type|
|
114
|
-
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
115
|
-
transformed_hash[key.to_sym] = nil
|
116
|
-
elsif type =~ /\AArray<(.*)>/i
|
117
|
-
# check to ensure the input is an array given that the attribute
|
118
|
-
# is documented as an array but the input is not
|
119
|
-
if attributes[attribute_map[key]].is_a?(Array)
|
120
|
-
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
121
|
-
_deserialize(::Regexp.last_match(1), v)
|
122
|
-
}
|
123
|
-
end
|
124
|
-
elsif !attributes[attribute_map[key]].nil?
|
125
|
-
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
new(transformed_hash)
|
130
|
-
end
|
131
|
-
|
132
|
-
# Deserializes the data based on type
|
133
|
-
# @param string type Data type
|
134
|
-
# @param string value Value to be deserialized
|
135
|
-
# @return [Object] Deserialized data
|
136
|
-
def self._deserialize(type, value)
|
137
|
-
case type.to_sym
|
138
|
-
when :Time
|
139
|
-
Time.parse(value)
|
140
|
-
when :Date
|
141
|
-
Date.parse(value)
|
142
|
-
when :String
|
143
|
-
value.to_s
|
144
|
-
when :Integer
|
145
|
-
value.to_i
|
146
|
-
when :Float
|
147
|
-
value.to_f
|
148
|
-
when :Boolean
|
149
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
150
|
-
true
|
151
|
-
else
|
152
|
-
false
|
153
|
-
end
|
154
|
-
|
155
|
-
when :Object
|
156
|
-
# generic object (usually a Hash), return directly
|
157
|
-
value
|
158
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
159
|
-
inner_type = Regexp.last_match[:inner_type]
|
160
|
-
value.map { |v| _deserialize(inner_type, v) }
|
161
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
162
|
-
k_type = Regexp.last_match[:k_type]
|
163
|
-
v_type = Regexp.last_match[:v_type]
|
164
|
-
{}.tap do |hash|
|
165
|
-
value.each do |k, v|
|
166
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
# model
|
170
|
-
else
|
171
|
-
# models (e.g. Pet) or oneOf
|
172
|
-
klass = Algolia::Ingestion.const_get(type)
|
173
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
174
|
-
.build_from_hash(value)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
# Returns the string representation of the object
|
179
|
-
# @return [String] String presentation of the object
|
180
|
-
def to_s
|
181
|
-
to_hash.to_s
|
182
|
-
end
|
183
|
-
|
184
|
-
# to_body is an alias to to_hash (backward compatibility)
|
185
|
-
# @return [Hash] Returns the object in the form of hash
|
186
|
-
def to_body
|
187
|
-
to_hash
|
188
|
-
end
|
189
|
-
|
190
|
-
def to_json(*_args)
|
191
|
-
to_hash.to_json
|
192
|
-
end
|
193
|
-
|
194
|
-
# Returns the object in the form of hash
|
195
|
-
# @return [Hash] Returns the object in the form of hash
|
196
|
-
def to_hash
|
197
|
-
hash = {}
|
198
|
-
self.class.attribute_map.each_pair do |attr, param|
|
199
|
-
value = send(attr)
|
200
|
-
if value.nil?
|
201
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
202
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
203
|
-
end
|
204
|
-
|
205
|
-
hash[param] = _to_hash(value)
|
206
|
-
end
|
207
|
-
|
208
|
-
hash
|
209
|
-
end
|
210
|
-
|
211
|
-
# Outputs non-array value in the form of hash
|
212
|
-
# For object, use to_hash. Otherwise, just return the value
|
213
|
-
# @param [Object] value Any valid value
|
214
|
-
# @return [Hash] Returns the value in the form of hash
|
215
|
-
def _to_hash(value)
|
216
|
-
if value.is_a?(Array)
|
217
|
-
value.compact.map { |v| _to_hash(v) }
|
218
|
-
elsif value.is_a?(Hash)
|
219
|
-
{}.tap do |hash|
|
220
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
221
|
-
end
|
222
|
-
elsif value.respond_to?(:to_hash)
|
223
|
-
value.to_hash
|
224
|
-
else
|
225
|
-
value
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
230
|
-
|
231
|
-
end
|
232
|
-
end
|