algolia 3.0.0.alpha.17 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +4 -4
- data/lib/algolia/api/abtesting_client.rb +20 -20
- data/lib/algolia/api/personalization_client.rb +12 -12
- data/lib/algolia/models/abtesting/ab_test.rb +41 -16
- data/lib/algolia/models/abtesting/ab_test_configuration.rb +217 -0
- data/lib/algolia/models/abtesting/ab_test_response.rb +2 -2
- data/lib/algolia/models/abtesting/ab_tests_variant.rb +21 -3
- data/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +21 -3
- data/lib/algolia/models/abtesting/add_ab_tests_request.rb +1 -1
- data/lib/algolia/models/abtesting/custom_search_params.rb +1 -1
- data/lib/algolia/models/abtesting/effect.rb +35 -0
- data/lib/algolia/models/abtesting/empty_search.rb +198 -0
- data/lib/algolia/models/abtesting/list_ab_tests_response.rb +1 -1
- data/lib/algolia/models/abtesting/minimum_detectable_effect.rb +247 -0
- data/lib/algolia/models/abtesting/outliers.rb +198 -0
- data/lib/algolia/models/abtesting/status.rb +35 -0
- data/lib/algolia/models/abtesting/variant.rb +31 -13
- data/lib/algolia/models/ingestion/destination_index_name.rb +1 -1
- data/lib/algolia/models/ingestion/shopify_input.rb +212 -0
- data/lib/algolia/models/ingestion/shopify_market.rb +227 -0
- data/lib/algolia/models/ingestion/shopify_metafield.rb +221 -0
- data/lib/algolia/models/ingestion/source_input.rb +2 -1
- data/lib/algolia/models/ingestion/source_shopify.rb +278 -0
- data/lib/algolia/models/ingestion/source_shopify_base.rb +199 -0
- data/lib/algolia/models/ingestion/source_update_input.rb +2 -1
- data/lib/algolia/models/ingestion/source_update_shopify.rb +258 -0
- data/lib/algolia/models/ingestion/task_input.rb +1 -0
- data/lib/algolia/models/insights/added_to_cart_object_ids.rb +1 -1
- data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/clicked_filters.rb +1 -1
- data/lib/algolia/models/insights/clicked_object_ids.rb +1 -1
- data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/converted_filters.rb +1 -1
- data/lib/algolia/models/insights/converted_object_ids.rb +1 -1
- data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/purchased_object_ids.rb +1 -1
- data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/viewed_filters.rb +1 -1
- data/lib/algolia/models/insights/viewed_object_ids.rb +1 -1
- data/lib/algolia/models/personalization/delete_user_profile_response.rb +2 -2
- data/lib/algolia/models/personalization/event_scoring.rb +25 -4
- data/lib/algolia/models/personalization/event_type.rb +34 -0
- data/lib/algolia/models/personalization/facet_scoring.rb +2 -2
- data/lib/algolia/models/personalization/get_user_token_response.rb +3 -3
- data/lib/algolia/models/personalization/personalization_strategy_params.rb +21 -3
- data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +1 -1
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +1 -1
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +1 -1
- data/lib/algolia/models/query-suggestions/source_index.rb +1 -1
- data/lib/algolia/models/recommend/base_recommend_request.rb +1 -1
- data/lib/algolia/models/recommend/base_search_params.rb +3 -3
- data/lib/algolia/models/recommend/base_search_params_without_query.rb +3 -3
- data/lib/algolia/models/recommend/bought_together_query.rb +1 -1
- data/lib/algolia/models/recommend/fallback_params.rb +9 -9
- data/lib/algolia/models/recommend/index_settings_as_search_params.rb +6 -6
- data/lib/algolia/models/recommend/looking_similar_query.rb +1 -1
- data/lib/algolia/models/recommend/re_ranking_apply_filter.rb +1 -1
- data/lib/algolia/models/recommend/recommended_for_you_query.rb +1 -1
- data/lib/algolia/models/recommend/related_query.rb +1 -1
- data/lib/algolia/models/recommend/search_params.rb +9 -9
- data/lib/algolia/models/recommend/search_params_object.rb +10 -9
- data/lib/algolia/models/recommend/trending_facets_query.rb +1 -1
- data/lib/algolia/models/recommend/trending_items_query.rb +1 -1
- data/lib/algolia/models/search/base_index_settings.rb +9 -9
- data/lib/algolia/models/search/base_search_params.rb +3 -3
- data/lib/algolia/models/search/base_search_params_without_query.rb +3 -3
- data/lib/algolia/models/search/browse_params_object.rb +9 -9
- data/lib/algolia/models/search/consequence_params.rb +9 -9
- data/lib/algolia/models/search/delete_by_params.rb +1 -1
- data/lib/algolia/models/search/index_settings.rb +15 -15
- data/lib/algolia/models/search/index_settings_as_search_params.rb +6 -6
- data/lib/algolia/models/search/multiple_batch_request.rb +1 -1
- data/lib/algolia/models/search/operation_index_params.rb +1 -1
- data/lib/algolia/models/search/re_ranking_apply_filter.rb +1 -1
- data/lib/algolia/models/search/search_for_facets.rb +10 -10
- data/lib/algolia/models/search/search_for_facets_options.rb +1 -1
- data/lib/algolia/models/search/search_for_hits.rb +10 -10
- data/lib/algolia/models/search/search_for_hits_options.rb +1 -1
- data/lib/algolia/models/search/search_params_object.rb +10 -9
- data/lib/algolia/version.rb +1 -1
- metadata +15 -2
@@ -0,0 +1,278 @@
|
|
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 Ingestion
|
8
|
+
class SourceShopify
|
9
|
+
# Whether to index collection IDs. If your store has `has_collection_search_page` set to true, collection IDs will be indexed even if `collectionIDIndexing` is false.
|
10
|
+
attr_accessor :collection_id_indexing
|
11
|
+
|
12
|
+
# Whether to increase the number of indexed collections per product. If true, Algolia indexes 200 collections per product. If false, 100 collections per product are indexed.
|
13
|
+
attr_accessor :increase_product_collection_limit
|
14
|
+
|
15
|
+
# Whether to set the default price ratio to 1 if no sale price is present. The price ratio is determined by the ratio: `sale_price` / `regular_price`. If no sale price is present, the price ratio would be 0. If `defaultPriceRatioAsOne` is true, the price ratio is indexed as 1 instead.
|
16
|
+
attr_accessor :default_price_ratio_as_one
|
17
|
+
|
18
|
+
# Whether to exclude out-of-stock variants when determining the `max_variant_price` and `min_variant_price` attributes.
|
19
|
+
attr_accessor :exclude_oos_variants_for_price_at_trs
|
20
|
+
|
21
|
+
# Whether to include an inventory with every variant for every product record.
|
22
|
+
attr_accessor :include_variants_inventory
|
23
|
+
|
24
|
+
# Whether to include collection IDs and handles in the product records.
|
25
|
+
attr_accessor :has_collection_search_page
|
26
|
+
|
27
|
+
# Whether to convert tags on products to named tags. To learn more, see [Named tags](https://www.algolia.com/doc/integration/shopify/sending-and-managing-data/named-tags).
|
28
|
+
attr_accessor :product_named_tags
|
29
|
+
|
30
|
+
# URL of the Shopify store.
|
31
|
+
attr_accessor :shop_url
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
:collection_id_indexing => :collectionIDIndexing,
|
37
|
+
:increase_product_collection_limit => :increaseProductCollectionLimit,
|
38
|
+
:default_price_ratio_as_one => :defaultPriceRatioAsOne,
|
39
|
+
:exclude_oos_variants_for_price_at_trs => :excludeOOSVariantsForPriceAtTRS,
|
40
|
+
:include_variants_inventory => :includeVariantsInventory,
|
41
|
+
:has_collection_search_page => :hasCollectionSearchPage,
|
42
|
+
:product_named_tags => :productNamedTags,
|
43
|
+
:shop_url => :shopURL
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns all the JSON keys this model knows about
|
48
|
+
def self.acceptable_attributes
|
49
|
+
attribute_map.values
|
50
|
+
end
|
51
|
+
|
52
|
+
# Attribute type mapping.
|
53
|
+
def self.types_mapping
|
54
|
+
{
|
55
|
+
:collection_id_indexing => :Boolean,
|
56
|
+
:increase_product_collection_limit => :Boolean,
|
57
|
+
:default_price_ratio_as_one => :Boolean,
|
58
|
+
:exclude_oos_variants_for_price_at_trs => :Boolean,
|
59
|
+
:include_variants_inventory => :Boolean,
|
60
|
+
:has_collection_search_page => :Boolean,
|
61
|
+
:product_named_tags => :Boolean,
|
62
|
+
:shop_url => :String
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# List of attributes with nullable: true
|
67
|
+
def self.openapi_nullable
|
68
|
+
Set.new([])
|
69
|
+
end
|
70
|
+
|
71
|
+
# List of class defined in allOf (OpenAPI v3)
|
72
|
+
def self.openapi_all_of
|
73
|
+
[
|
74
|
+
:SourceShopifyBase,
|
75
|
+
:SourceUpdateShopify
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
# Initializes the object
|
80
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
81
|
+
def initialize(attributes = {})
|
82
|
+
unless attributes.is_a?(Hash)
|
83
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::SourceShopify` initialize method"
|
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({}) do |(k, v), h|
|
88
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
89
|
+
raise ArgumentError,
|
90
|
+
"`#{k}` is not a valid attribute in `Algolia::SourceShopify`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
91
|
+
end
|
92
|
+
|
93
|
+
h[k.to_sym] = v
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.key?(:collection_id_indexing)
|
97
|
+
self.collection_id_indexing = attributes[:collection_id_indexing]
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.key?(:increase_product_collection_limit)
|
101
|
+
self.increase_product_collection_limit = attributes[:increase_product_collection_limit]
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.key?(:default_price_ratio_as_one)
|
105
|
+
self.default_price_ratio_as_one = attributes[:default_price_ratio_as_one]
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.key?(:exclude_oos_variants_for_price_at_trs)
|
109
|
+
self.exclude_oos_variants_for_price_at_trs = attributes[:exclude_oos_variants_for_price_at_trs]
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:include_variants_inventory)
|
113
|
+
self.include_variants_inventory = attributes[:include_variants_inventory]
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:has_collection_search_page)
|
117
|
+
self.has_collection_search_page = attributes[:has_collection_search_page]
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:product_named_tags)
|
121
|
+
self.product_named_tags = attributes[:product_named_tags]
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:shop_url)
|
125
|
+
self.shop_url = attributes[:shop_url]
|
126
|
+
else
|
127
|
+
self.shop_url = nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Checks equality by comparing each attribute.
|
132
|
+
# @param [Object] Object to be compared
|
133
|
+
def ==(other)
|
134
|
+
return true if equal?(other)
|
135
|
+
|
136
|
+
self.class == other.class &&
|
137
|
+
collection_id_indexing == other.collection_id_indexing &&
|
138
|
+
increase_product_collection_limit == other.increase_product_collection_limit &&
|
139
|
+
default_price_ratio_as_one == other.default_price_ratio_as_one &&
|
140
|
+
exclude_oos_variants_for_price_at_trs == other.exclude_oos_variants_for_price_at_trs &&
|
141
|
+
include_variants_inventory == other.include_variants_inventory &&
|
142
|
+
has_collection_search_page == other.has_collection_search_page &&
|
143
|
+
product_named_tags == other.product_named_tags &&
|
144
|
+
shop_url == other.shop_url
|
145
|
+
end
|
146
|
+
|
147
|
+
# @see the `==` method
|
148
|
+
# @param [Object] Object to be compared
|
149
|
+
def eql?(other)
|
150
|
+
self == other
|
151
|
+
end
|
152
|
+
|
153
|
+
# Calculates hash code according to all attributes.
|
154
|
+
# @return [Integer] Hash code
|
155
|
+
def hash
|
156
|
+
[collection_id_indexing, increase_product_collection_limit, default_price_ratio_as_one, exclude_oos_variants_for_price_at_trs, include_variants_inventory,
|
157
|
+
has_collection_search_page, product_named_tags, shop_url].hash
|
158
|
+
end
|
159
|
+
|
160
|
+
# Builds the object from hash
|
161
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
162
|
+
# @return [Object] Returns the model itself
|
163
|
+
def self.build_from_hash(attributes)
|
164
|
+
return nil unless attributes.is_a?(Hash)
|
165
|
+
|
166
|
+
attributes = attributes.transform_keys(&:to_sym)
|
167
|
+
transformed_hash = {}
|
168
|
+
types_mapping.each_pair do |key, type|
|
169
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
170
|
+
transformed_hash[key.to_sym] = nil
|
171
|
+
elsif type =~ /\AArray<(.*)>/i
|
172
|
+
# check to ensure the input is an array given that the attribute
|
173
|
+
# is documented as an array but the input is not
|
174
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
175
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
176
|
+
end
|
177
|
+
elsif !attributes[attribute_map[key]].nil?
|
178
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
179
|
+
end
|
180
|
+
end
|
181
|
+
new(transformed_hash)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Deserializes the data based on type
|
185
|
+
# @param string type Data type
|
186
|
+
# @param string value Value to be deserialized
|
187
|
+
# @return [Object] Deserialized data
|
188
|
+
def self._deserialize(type, value)
|
189
|
+
case type.to_sym
|
190
|
+
when :Time
|
191
|
+
Time.parse(value)
|
192
|
+
when :Date
|
193
|
+
Date.parse(value)
|
194
|
+
when :String
|
195
|
+
value.to_s
|
196
|
+
when :Integer
|
197
|
+
value.to_i
|
198
|
+
when :Float
|
199
|
+
value.to_f
|
200
|
+
when :Boolean
|
201
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
202
|
+
true
|
203
|
+
else
|
204
|
+
false
|
205
|
+
end
|
206
|
+
when :Object
|
207
|
+
# generic object (usually a Hash), return directly
|
208
|
+
value
|
209
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
210
|
+
inner_type = Regexp.last_match[:inner_type]
|
211
|
+
value.map { |v| _deserialize(inner_type, v) }
|
212
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
213
|
+
k_type = Regexp.last_match[:k_type]
|
214
|
+
v_type = Regexp.last_match[:v_type]
|
215
|
+
{}.tap do |hash|
|
216
|
+
value.each do |k, v|
|
217
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
else # model
|
221
|
+
# models (e.g. Pet) or oneOf
|
222
|
+
klass = Algolia::Ingestion.const_get(type)
|
223
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
|
+
hash
|
257
|
+
end
|
258
|
+
|
259
|
+
# Outputs non-array value in the form of hash
|
260
|
+
# For object, use to_hash. Otherwise, just return the value
|
261
|
+
# @param [Object] value Any valid value
|
262
|
+
# @return [Hash] Returns the value in the form of hash
|
263
|
+
def _to_hash(value)
|
264
|
+
if value.is_a?(Array)
|
265
|
+
value.compact.map { |v| _to_hash(v) }
|
266
|
+
elsif value.is_a?(Hash)
|
267
|
+
{}.tap do |hash|
|
268
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
269
|
+
end
|
270
|
+
elsif value.respond_to? :to_hash
|
271
|
+
value.to_hash
|
272
|
+
else
|
273
|
+
value
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
@@ -0,0 +1,199 @@
|
|
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 Ingestion
|
8
|
+
class SourceShopifyBase
|
9
|
+
# URL of the Shopify store.
|
10
|
+
attr_accessor :shop_url
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
:shop_url => :shopURL
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns all the JSON keys this model knows about
|
20
|
+
def self.acceptable_attributes
|
21
|
+
attribute_map.values
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute type mapping.
|
25
|
+
def self.types_mapping
|
26
|
+
{
|
27
|
+
:shop_url => :String
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# List of attributes with nullable: true
|
32
|
+
def self.openapi_nullable
|
33
|
+
Set.new([])
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
unless attributes.is_a?(Hash)
|
40
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::SourceShopifyBase` initialize method"
|
41
|
+
end
|
42
|
+
|
43
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
44
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
45
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
46
|
+
raise ArgumentError,
|
47
|
+
"`#{k}` is not a valid attribute in `Algolia::SourceShopifyBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
48
|
+
end
|
49
|
+
|
50
|
+
h[k.to_sym] = v
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes.key?(:shop_url)
|
54
|
+
self.shop_url = attributes[:shop_url]
|
55
|
+
else
|
56
|
+
self.shop_url = nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Checks equality by comparing each attribute.
|
61
|
+
# @param [Object] Object to be compared
|
62
|
+
def ==(other)
|
63
|
+
return true if equal?(other)
|
64
|
+
|
65
|
+
self.class == other.class &&
|
66
|
+
shop_url == other.shop_url
|
67
|
+
end
|
68
|
+
|
69
|
+
# @see the `==` method
|
70
|
+
# @param [Object] Object to be compared
|
71
|
+
def eql?(other)
|
72
|
+
self == other
|
73
|
+
end
|
74
|
+
|
75
|
+
# Calculates hash code according to all attributes.
|
76
|
+
# @return [Integer] Hash code
|
77
|
+
def hash
|
78
|
+
[shop_url].hash
|
79
|
+
end
|
80
|
+
|
81
|
+
# Builds the object from hash
|
82
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
83
|
+
# @return [Object] Returns the model itself
|
84
|
+
def self.build_from_hash(attributes)
|
85
|
+
return nil unless attributes.is_a?(Hash)
|
86
|
+
|
87
|
+
attributes = attributes.transform_keys(&:to_sym)
|
88
|
+
transformed_hash = {}
|
89
|
+
types_mapping.each_pair do |key, type|
|
90
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
91
|
+
transformed_hash[key.to_sym] = nil
|
92
|
+
elsif type =~ /\AArray<(.*)>/i
|
93
|
+
# check to ensure the input is an array given that the attribute
|
94
|
+
# is documented as an array but the input is not
|
95
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
96
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
97
|
+
end
|
98
|
+
elsif !attributes[attribute_map[key]].nil?
|
99
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
new(transformed_hash)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Deserializes the data based on type
|
106
|
+
# @param string type Data type
|
107
|
+
# @param string value Value to be deserialized
|
108
|
+
# @return [Object] Deserialized data
|
109
|
+
def self._deserialize(type, value)
|
110
|
+
case type.to_sym
|
111
|
+
when :Time
|
112
|
+
Time.parse(value)
|
113
|
+
when :Date
|
114
|
+
Date.parse(value)
|
115
|
+
when :String
|
116
|
+
value.to_s
|
117
|
+
when :Integer
|
118
|
+
value.to_i
|
119
|
+
when :Float
|
120
|
+
value.to_f
|
121
|
+
when :Boolean
|
122
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
123
|
+
true
|
124
|
+
else
|
125
|
+
false
|
126
|
+
end
|
127
|
+
when :Object
|
128
|
+
# generic object (usually a Hash), return directly
|
129
|
+
value
|
130
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
131
|
+
inner_type = Regexp.last_match[:inner_type]
|
132
|
+
value.map { |v| _deserialize(inner_type, v) }
|
133
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
134
|
+
k_type = Regexp.last_match[:k_type]
|
135
|
+
v_type = Regexp.last_match[:v_type]
|
136
|
+
{}.tap do |hash|
|
137
|
+
value.each do |k, v|
|
138
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
else # model
|
142
|
+
# models (e.g. Pet) or oneOf
|
143
|
+
klass = Algolia::Ingestion.const_get(type)
|
144
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns the string representation of the object
|
149
|
+
# @return [String] String presentation of the object
|
150
|
+
def to_s
|
151
|
+
to_hash.to_s
|
152
|
+
end
|
153
|
+
|
154
|
+
# to_body is an alias to to_hash (backward compatibility)
|
155
|
+
# @return [Hash] Returns the object in the form of hash
|
156
|
+
def to_body
|
157
|
+
to_hash
|
158
|
+
end
|
159
|
+
|
160
|
+
def to_json(*_args)
|
161
|
+
to_hash.to_json
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns the object in the form of hash
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_hash
|
167
|
+
hash = {}
|
168
|
+
self.class.attribute_map.each_pair do |attr, param|
|
169
|
+
value = send(attr)
|
170
|
+
if value.nil?
|
171
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
172
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
173
|
+
end
|
174
|
+
|
175
|
+
hash[param] = _to_hash(value)
|
176
|
+
end
|
177
|
+
hash
|
178
|
+
end
|
179
|
+
|
180
|
+
# Outputs non-array value in the form of hash
|
181
|
+
# For object, use to_hash. Otherwise, just return the value
|
182
|
+
# @param [Object] value Any valid value
|
183
|
+
# @return [Hash] Returns the value in the form of hash
|
184
|
+
def _to_hash(value)
|
185
|
+
if value.is_a?(Array)
|
186
|
+
value.compact.map { |v| _to_hash(v) }
|
187
|
+
elsif value.is_a?(Hash)
|
188
|
+
{}.tap do |hash|
|
189
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
190
|
+
end
|
191
|
+
elsif value.respond_to? :to_hash
|
192
|
+
value.to_hash
|
193
|
+
else
|
194
|
+
value
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|