algolia 3.23.0 → 3.25.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 +14 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/ingestion_client.rb +48 -2
- data/lib/algolia/api/search_client.rb +6 -3
- data/lib/algolia/models/abtesting/ab_test.rb +13 -1
- data/lib/algolia/models/abtesting-v3/ab_test.rb +25 -2
- data/lib/algolia/models/composition/external_injected_item.rb +212 -0
- data/lib/algolia/models/composition/external_injection.rb +223 -0
- data/lib/algolia/models/composition/hit.rb +13 -4
- data/lib/algolia/models/composition/hit_metadata.rb +210 -0
- data/lib/algolia/models/composition/params.rb +19 -5
- data/lib/algolia/models/ingestion/task_replace.rb +310 -0
- data/lib/algolia/models/ingestion/task_update.rb +1 -1
- data/lib/algolia/models/recommend/fallback_params.rb +26 -26
- data/lib/algolia/models/recommend/recommend_search_params.rb +26 -26
- data/lib/algolia/models/search/browse_params_object.rb +26 -26
- data/lib/algolia/models/search/consequence.rb +1 -1
- data/lib/algolia/models/search/consequence_params.rb +26 -26
- data/lib/algolia/models/search/index_settings.rb +18 -18
- data/lib/algolia/models/search/search_for_facets.rb +26 -26
- data/lib/algolia/models/search/search_for_hits.rb +26 -26
- data/lib/algolia/models/search/search_params_object.rb +26 -26
- data/lib/algolia/models/search/settings_response.rb +18 -18
- data/lib/algolia/transport/transport.rb +6 -1
- 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: 1404975c1e5ba8114c39898c74721f95f8e5c20f9eb9d823c12257dff41808cc
|
4
|
+
data.tar.gz: 49e83567a7b8792318599f9615a3332aaa390a3a8796f2b8500d0c613df5338f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd8fd30e11c95742f37123615223560666119959ad070b024a9aee73f9fca725fe0745d239900a7a4c85a37d5ab4050c16ffafe33eb16f23e4b6a15b4aaeaaa0
|
7
|
+
data.tar.gz: b2471b57a54330686b9fdf52e40f7999015d81e23befd8d712ec0f21f91c98e64f644ed22c3eb97e56f6cd6260002d484fadcafb7a5085273209f617976c12a1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [3.25.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.24.0...3.25.0)
|
2
|
+
|
3
|
+
- [8f4abf3a1](https://github.com/algolia/api-clients-automation/commit/8f4abf3a1) fix(specs): Cross-reference filerPromotes to relevant guide ([#5279](https://github.com/algolia/api-clients-automation/pull/5279)) by [@gazconroy](https://github.com/gazconroy/)
|
4
|
+
- [1f4a3a9f7](https://github.com/algolia/api-clients-automation/commit/1f4a3a9f7) feat(specs): add put task endpoint to ingestion api ([#5281](https://github.com/algolia/api-clients-automation/pull/5281)) by [@shortcuts](https://github.com/shortcuts/)
|
5
|
+
- [08e9d1888](https://github.com/algolia/api-clients-automation/commit/08e9d1888) fix(specs): add getVersion parameter to getSettings ([#5254](https://github.com/algolia/api-clients-automation/pull/5254)) by [@millotp](https://github.com/millotp/)
|
6
|
+
- [f4eee1c4a](https://github.com/algolia/api-clients-automation/commit/f4eee1c4a) chore(website): exclude schema from generated variables file ([#5306](https://github.com/algolia/api-clients-automation/pull/5306)) by [@Fluf22](https://github.com/Fluf22/)
|
7
|
+
- [2fa0389f8](https://github.com/algolia/api-clients-automation/commit/2fa0389f8) fix(clients): link to support/help center on unreachable hosts ([#5305](https://github.com/algolia/api-clients-automation/pull/5305)) by [@shortcuts](https://github.com/shortcuts/)
|
8
|
+
|
9
|
+
## [3.24.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.23.0...3.24.0)
|
10
|
+
|
11
|
+
- [48672036c1](https://github.com/algolia/api-clients-automation/commit/48672036c1) refactor(specs): mutualise code between Search API & Comp API for search query parameters ([#5125](https://github.com/algolia/api-clients-automation/pull/5125)) by [@ClaraMuller](https://github.com/ClaraMuller/)
|
12
|
+
- [99f8174c7d](https://github.com/algolia/api-clients-automation/commit/99f8174c7d) feat(specs): add fields for metadata in composition injectedItems ([#5241](https://github.com/algolia/api-clients-automation/pull/5241)) by [@gavinwade12](https://github.com/gavinwade12/)
|
13
|
+
- [ff178d8118](https://github.com/algolia/api-clients-automation/commit/ff178d8118) feat(specs): abtests stopped at ([#5275](https://github.com/algolia/api-clients-automation/pull/5275)) by [@stevenMevans](https://github.com/stevenMevans/)
|
14
|
+
|
1
15
|
## [3.23.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.22.1...3.23.0)
|
2
16
|
|
3
17
|
- [050aacef17](https://github.com/algolia/api-clients-automation/commit/050aacef17) chore(deps): dependencies 2025-07-28 ([#5161](https://github.com/algolia/api-clients-automation/pull/5161)) by [@algolia-bot](https://github.com/algolia-bot/)
|
data/Gemfile.lock
CHANGED
@@ -2265,6 +2265,52 @@ module Algolia
|
|
2265
2265
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Ingestion::WatchResponse")
|
2266
2266
|
end
|
2267
2267
|
|
2268
|
+
# Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
|
2269
|
+
|
2270
|
+
# @param task_id [String] Unique identifier of a task. (required)
|
2271
|
+
# @param task_replace [TaskReplace] (required)
|
2272
|
+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
2273
|
+
# @return [Http::Response] the response
|
2274
|
+
def replace_task_with_http_info(task_id, task_replace, request_options = {})
|
2275
|
+
# verify the required parameter 'task_id' is set
|
2276
|
+
if @api_client.config.client_side_validation && task_id.nil?
|
2277
|
+
raise ArgumentError, "Parameter `task_id` is required when calling `replace_task`."
|
2278
|
+
end
|
2279
|
+
# verify the required parameter 'task_replace' is set
|
2280
|
+
if @api_client.config.client_side_validation && task_replace.nil?
|
2281
|
+
raise ArgumentError, "Parameter `task_replace` is required when calling `replace_task`."
|
2282
|
+
end
|
2283
|
+
|
2284
|
+
path = "/2/tasks/{taskID}".sub("{" + "taskID" + "}", Transport.encode_uri(task_id.to_s))
|
2285
|
+
query_params = {}
|
2286
|
+
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
|
2287
|
+
header_params = {}
|
2288
|
+
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
|
2289
|
+
|
2290
|
+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(task_replace)
|
2291
|
+
|
2292
|
+
new_options = request_options.merge(
|
2293
|
+
:operation => :"IngestionClient.replace_task",
|
2294
|
+
:header_params => header_params,
|
2295
|
+
:query_params => query_params,
|
2296
|
+
:body => post_body,
|
2297
|
+
:use_read_transporter => false
|
2298
|
+
)
|
2299
|
+
|
2300
|
+
@api_client.call_api(:PUT, path, new_options)
|
2301
|
+
end
|
2302
|
+
|
2303
|
+
# Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
|
2304
|
+
|
2305
|
+
# @param task_id [String] Unique identifier of a task. (required)
|
2306
|
+
# @param task_replace [TaskReplace] (required)
|
2307
|
+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
2308
|
+
# @return [TaskUpdateResponse]
|
2309
|
+
def replace_task(task_id, task_replace, request_options = {})
|
2310
|
+
response = replace_task_with_http_info(task_id, task_replace, request_options)
|
2311
|
+
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Ingestion::TaskUpdateResponse")
|
2312
|
+
end
|
2313
|
+
|
2268
2314
|
# Runs all tasks linked to a source, only available for Shopify, BigCommerce and commercetools sources. Creates one run per task.
|
2269
2315
|
#
|
2270
2316
|
# Required API Key ACLs:
|
@@ -3046,7 +3092,7 @@ module Algolia
|
|
3046
3092
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Ingestion::SourceUpdateResponse")
|
3047
3093
|
end
|
3048
3094
|
|
3049
|
-
#
|
3095
|
+
# Partially updates a task by its ID.
|
3050
3096
|
|
3051
3097
|
# @param task_id [String] Unique identifier of a task. (required)
|
3052
3098
|
# @param task_update [TaskUpdate] (required)
|
@@ -3081,7 +3127,7 @@ module Algolia
|
|
3081
3127
|
@api_client.call_api(:PATCH, path, new_options)
|
3082
3128
|
end
|
3083
3129
|
|
3084
|
-
#
|
3130
|
+
# Partially updates a task by its ID.
|
3085
3131
|
|
3086
3132
|
# @param task_id [String] Unique identifier of a task. (required)
|
3087
3133
|
# @param task_update [TaskUpdate] (required)
|
@@ -1503,9 +1503,10 @@ module Algolia
|
|
1503
1503
|
# Required API Key ACLs:
|
1504
1504
|
# - settings
|
1505
1505
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
1506
|
+
# @param get_version [Integer] When set to 2, the endpoint will not include `synonyms` in the response. This parameter is here for backward compatibility. (default to 1)
|
1506
1507
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
1507
1508
|
# @return [Http::Response] the response
|
1508
|
-
def get_settings_with_http_info(index_name, request_options = {})
|
1509
|
+
def get_settings_with_http_info(index_name, get_version = nil, request_options = {})
|
1509
1510
|
# verify the required parameter 'index_name' is set
|
1510
1511
|
if @api_client.config.client_side_validation && index_name.nil?
|
1511
1512
|
raise ArgumentError, "Parameter `index_name` is required when calling `get_settings`."
|
@@ -1513,6 +1514,7 @@ module Algolia
|
|
1513
1514
|
|
1514
1515
|
path = "/1/indexes/{indexName}/settings".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
1515
1516
|
query_params = {}
|
1517
|
+
query_params[:getVersion] = get_version unless get_version.nil?
|
1516
1518
|
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
|
1517
1519
|
header_params = {}
|
1518
1520
|
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
|
@@ -1535,10 +1537,11 @@ module Algolia
|
|
1535
1537
|
# Required API Key ACLs:
|
1536
1538
|
# - settings
|
1537
1539
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
1540
|
+
# @param get_version [Integer] When set to 2, the endpoint will not include `synonyms` in the response. This parameter is here for backward compatibility. (default to 1)
|
1538
1541
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
1539
1542
|
# @return [SettingsResponse]
|
1540
|
-
def get_settings(index_name, request_options = {})
|
1541
|
-
response = get_settings_with_http_info(index_name, request_options)
|
1543
|
+
def get_settings(index_name, get_version = nil, request_options = {})
|
1544
|
+
response = get_settings_with_http_info(index_name, get_version, request_options)
|
1542
1545
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SettingsResponse")
|
1543
1546
|
end
|
1544
1547
|
|
@@ -30,6 +30,9 @@ module Algolia
|
|
30
30
|
# End date and time of the A/B test, in RFC 3339 format.
|
31
31
|
attr_accessor :end_at
|
32
32
|
|
33
|
+
# Date and time when the A/B test was stopped, in RFC 3339 format.
|
34
|
+
attr_accessor :stopped_at
|
35
|
+
|
33
36
|
# A/B test name.
|
34
37
|
attr_accessor :name
|
35
38
|
|
@@ -52,6 +55,7 @@ module Algolia
|
|
52
55
|
:updated_at => :updatedAt,
|
53
56
|
:created_at => :createdAt,
|
54
57
|
:end_at => :endAt,
|
58
|
+
:stopped_at => :stoppedAt,
|
55
59
|
:name => :name,
|
56
60
|
:status => :status,
|
57
61
|
:variants => :variants,
|
@@ -71,6 +75,7 @@ module Algolia
|
|
71
75
|
:updated_at => :"String",
|
72
76
|
:created_at => :"String",
|
73
77
|
:end_at => :"String",
|
78
|
+
:stopped_at => :"String",
|
74
79
|
:name => :"String",
|
75
80
|
:status => :"Status",
|
76
81
|
:variants => :"Array<Variant>",
|
@@ -86,7 +91,8 @@ module Algolia
|
|
86
91
|
:conversion_significance,
|
87
92
|
:add_to_cart_significance,
|
88
93
|
:purchase_significance,
|
89
|
-
:revenue_significance
|
94
|
+
:revenue_significance,
|
95
|
+
:stopped_at
|
90
96
|
]
|
91
97
|
)
|
92
98
|
end
|
@@ -157,6 +163,10 @@ module Algolia
|
|
157
163
|
self.end_at = nil
|
158
164
|
end
|
159
165
|
|
166
|
+
if attributes.key?(:stopped_at)
|
167
|
+
self.stopped_at = attributes[:stopped_at]
|
168
|
+
end
|
169
|
+
|
160
170
|
if attributes.key?(:name)
|
161
171
|
self.name = attributes[:name]
|
162
172
|
else
|
@@ -196,6 +206,7 @@ module Algolia
|
|
196
206
|
updated_at == other.updated_at &&
|
197
207
|
created_at == other.created_at &&
|
198
208
|
end_at == other.end_at &&
|
209
|
+
stopped_at == other.stopped_at &&
|
199
210
|
name == other.name &&
|
200
211
|
status == other.status &&
|
201
212
|
variants == other.variants &&
|
@@ -221,6 +232,7 @@ module Algolia
|
|
221
232
|
updated_at,
|
222
233
|
created_at,
|
223
234
|
end_at,
|
235
|
+
stopped_at,
|
224
236
|
name,
|
225
237
|
status,
|
226
238
|
variants,
|
@@ -20,6 +20,9 @@ module Algolia
|
|
20
20
|
# End date and time of the A/B test, in RFC 3339 format.
|
21
21
|
attr_accessor :end_at
|
22
22
|
|
23
|
+
# Date and time when the A/B test was stopped, in RFC 3339 format.
|
24
|
+
attr_accessor :stopped_at
|
25
|
+
|
23
26
|
# A/B test name.
|
24
27
|
attr_accessor :name
|
25
28
|
|
@@ -40,6 +43,7 @@ module Algolia
|
|
40
43
|
:updated_at => :updatedAt,
|
41
44
|
:created_at => :createdAt,
|
42
45
|
:end_at => :endAt,
|
46
|
+
:stopped_at => :stoppedAt,
|
43
47
|
:name => :name,
|
44
48
|
:status => :status,
|
45
49
|
:variants => :variants,
|
@@ -55,6 +59,7 @@ module Algolia
|
|
55
59
|
:updated_at => :"String",
|
56
60
|
:created_at => :"String",
|
57
61
|
:end_at => :"String",
|
62
|
+
:stopped_at => :"String",
|
58
63
|
:name => :"String",
|
59
64
|
:status => :"Status",
|
60
65
|
:variants => :"Array<Variant>",
|
@@ -66,7 +71,9 @@ module Algolia
|
|
66
71
|
# List of attributes with nullable: true
|
67
72
|
def self.openapi_nullable
|
68
73
|
Set.new(
|
69
|
-
[
|
74
|
+
[
|
75
|
+
:stopped_at
|
76
|
+
]
|
70
77
|
)
|
71
78
|
end
|
72
79
|
|
@@ -114,6 +121,10 @@ module Algolia
|
|
114
121
|
self.end_at = nil
|
115
122
|
end
|
116
123
|
|
124
|
+
if attributes.key?(:stopped_at)
|
125
|
+
self.stopped_at = attributes[:stopped_at]
|
126
|
+
end
|
127
|
+
|
117
128
|
if attributes.key?(:name)
|
118
129
|
self.name = attributes[:name]
|
119
130
|
else
|
@@ -152,6 +163,7 @@ module Algolia
|
|
152
163
|
updated_at == other.updated_at &&
|
153
164
|
created_at == other.created_at &&
|
154
165
|
end_at == other.end_at &&
|
166
|
+
stopped_at == other.stopped_at &&
|
155
167
|
name == other.name &&
|
156
168
|
status == other.status &&
|
157
169
|
variants == other.variants &&
|
@@ -168,7 +180,18 @@ module Algolia
|
|
168
180
|
# Calculates hash code according to all attributes.
|
169
181
|
# @return [Integer] Hash code
|
170
182
|
def hash
|
171
|
-
[
|
183
|
+
[
|
184
|
+
ab_test_id,
|
185
|
+
updated_at,
|
186
|
+
created_at,
|
187
|
+
end_at,
|
188
|
+
stopped_at,
|
189
|
+
name,
|
190
|
+
status,
|
191
|
+
variants,
|
192
|
+
configuration,
|
193
|
+
migrated_ab_test_id
|
194
|
+
].hash
|
172
195
|
end
|
173
196
|
|
174
197
|
# Builds the object from hash
|
@@ -0,0 +1,212 @@
|
|
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 ExternalInjectedItem
|
11
|
+
attr_accessor :items
|
12
|
+
|
13
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
14
|
+
def self.attribute_map
|
15
|
+
{
|
16
|
+
:items => :items
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Attribute type mapping.
|
21
|
+
def self.types_mapping
|
22
|
+
{
|
23
|
+
:items => :"Array<ExternalInjection>"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# List of attributes with nullable: true
|
28
|
+
def self.openapi_nullable
|
29
|
+
Set.new(
|
30
|
+
[]
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initializes the object
|
35
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
|
+
def initialize(attributes = {})
|
37
|
+
if (!attributes.is_a?(Hash))
|
38
|
+
raise(
|
39
|
+
ArgumentError,
|
40
|
+
"The input argument (attributes) must be a hash in `Algolia::ExternalInjectedItem` initialize method"
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
46
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
47
|
+
raise(
|
48
|
+
ArgumentError,
|
49
|
+
"`#{k}` is not a valid attribute in `Algolia::ExternalInjectedItem`. Please check the name to make sure it's valid. List of attributes: " +
|
50
|
+
self.class.attribute_map.keys.inspect
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
h[k.to_sym] = v
|
55
|
+
}
|
56
|
+
|
57
|
+
if attributes.key?(:items)
|
58
|
+
if (value = attributes[:items]).is_a?(Array)
|
59
|
+
self.items = value
|
60
|
+
end
|
61
|
+
else
|
62
|
+
self.items = nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(other)
|
69
|
+
return true if self.equal?(other)
|
70
|
+
self.class == other.class &&
|
71
|
+
items == other.items
|
72
|
+
end
|
73
|
+
|
74
|
+
# @see the `==` method
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def eql?(other)
|
77
|
+
self == other
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates hash code according to all attributes.
|
81
|
+
# @return [Integer] Hash code
|
82
|
+
def hash
|
83
|
+
[items].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
# Builds the object from hash
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
# @return [Object] Returns the model itself
|
89
|
+
def self.build_from_hash(attributes)
|
90
|
+
return nil unless attributes.is_a?(Hash)
|
91
|
+
attributes = attributes.transform_keys(&:to_sym)
|
92
|
+
transformed_hash = {}
|
93
|
+
types_mapping.each_pair do |key, type|
|
94
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
95
|
+
transformed_hash[key.to_sym] = nil
|
96
|
+
elsif type =~ /\AArray<(.*)>/i
|
97
|
+
# check to ensure the input is an array given that the attribute
|
98
|
+
# is documented as an array but the input is not
|
99
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
100
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
101
|
+
_deserialize(::Regexp.last_match(1), v)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
elsif !attributes[attribute_map[key]].nil?
|
105
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
new(transformed_hash)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deserializes the data based on type
|
113
|
+
# @param string type Data type
|
114
|
+
# @param string value Value to be deserialized
|
115
|
+
# @return [Object] Deserialized data
|
116
|
+
def self._deserialize(type, value)
|
117
|
+
case type.to_sym
|
118
|
+
when :Time
|
119
|
+
Time.parse(value)
|
120
|
+
when :Date
|
121
|
+
Date.parse(value)
|
122
|
+
when :String
|
123
|
+
value.to_s
|
124
|
+
when :Integer
|
125
|
+
value.to_i
|
126
|
+
when :Float
|
127
|
+
value.to_f
|
128
|
+
when :Boolean
|
129
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
130
|
+
true
|
131
|
+
else
|
132
|
+
false
|
133
|
+
end
|
134
|
+
|
135
|
+
when :Object
|
136
|
+
# generic object (usually a Hash), return directly
|
137
|
+
value
|
138
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
139
|
+
inner_type = Regexp.last_match[:inner_type]
|
140
|
+
value.map { |v| _deserialize(inner_type, v) }
|
141
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
142
|
+
k_type = Regexp.last_match[:k_type]
|
143
|
+
v_type = Regexp.last_match[:v_type]
|
144
|
+
{}.tap do |hash|
|
145
|
+
value.each do |k, v|
|
146
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
# model
|
150
|
+
else
|
151
|
+
# models (e.g. Pet) or oneOf
|
152
|
+
klass = Algolia::Composition.const_get(type)
|
153
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
154
|
+
.build_from_hash(value)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the string representation of the object
|
159
|
+
# @return [String] String presentation of the object
|
160
|
+
def to_s
|
161
|
+
to_hash.to_s
|
162
|
+
end
|
163
|
+
|
164
|
+
# to_body is an alias to to_hash (backward compatibility)
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_body
|
167
|
+
to_hash
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_json(*_args)
|
171
|
+
to_hash.to_json
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the object in the form of hash
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_hash
|
177
|
+
hash = {}
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
179
|
+
value = send(attr)
|
180
|
+
if value.nil?
|
181
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
182
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
183
|
+
end
|
184
|
+
|
185
|
+
hash[param] = _to_hash(value)
|
186
|
+
end
|
187
|
+
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to?(:to_hash)
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|