algolia 3.0.0.alpha.17 → 3.0.0.alpha.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +4 -4
  4. data/lib/algolia/api/abtesting_client.rb +20 -20
  5. data/lib/algolia/api/personalization_client.rb +12 -12
  6. data/lib/algolia/models/abtesting/ab_test.rb +41 -16
  7. data/lib/algolia/models/abtesting/ab_test_configuration.rb +217 -0
  8. data/lib/algolia/models/abtesting/ab_test_response.rb +2 -2
  9. data/lib/algolia/models/abtesting/ab_tests_variant.rb +21 -3
  10. data/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +21 -3
  11. data/lib/algolia/models/abtesting/add_ab_tests_request.rb +1 -1
  12. data/lib/algolia/models/abtesting/custom_search_params.rb +1 -1
  13. data/lib/algolia/models/abtesting/effect.rb +35 -0
  14. data/lib/algolia/models/abtesting/empty_search.rb +198 -0
  15. data/lib/algolia/models/abtesting/list_ab_tests_response.rb +1 -1
  16. data/lib/algolia/models/abtesting/minimum_detectable_effect.rb +247 -0
  17. data/lib/algolia/models/abtesting/outliers.rb +198 -0
  18. data/lib/algolia/models/abtesting/status.rb +35 -0
  19. data/lib/algolia/models/abtesting/variant.rb +31 -13
  20. data/lib/algolia/models/ingestion/destination_index_name.rb +1 -1
  21. data/lib/algolia/models/ingestion/shopify_input.rb +212 -0
  22. data/lib/algolia/models/ingestion/shopify_market.rb +227 -0
  23. data/lib/algolia/models/ingestion/shopify_metafield.rb +221 -0
  24. data/lib/algolia/models/ingestion/source_input.rb +2 -1
  25. data/lib/algolia/models/ingestion/source_shopify.rb +278 -0
  26. data/lib/algolia/models/ingestion/source_shopify_base.rb +199 -0
  27. data/lib/algolia/models/ingestion/source_update_input.rb +2 -1
  28. data/lib/algolia/models/ingestion/source_update_shopify.rb +258 -0
  29. data/lib/algolia/models/ingestion/task_input.rb +1 -0
  30. data/lib/algolia/models/insights/added_to_cart_object_ids.rb +1 -1
  31. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
  32. data/lib/algolia/models/insights/clicked_filters.rb +1 -1
  33. data/lib/algolia/models/insights/clicked_object_ids.rb +1 -1
  34. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
  35. data/lib/algolia/models/insights/converted_filters.rb +1 -1
  36. data/lib/algolia/models/insights/converted_object_ids.rb +1 -1
  37. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
  38. data/lib/algolia/models/insights/purchased_object_ids.rb +1 -1
  39. data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +1 -1
  40. data/lib/algolia/models/insights/viewed_filters.rb +1 -1
  41. data/lib/algolia/models/insights/viewed_object_ids.rb +1 -1
  42. data/lib/algolia/models/personalization/delete_user_profile_response.rb +2 -2
  43. data/lib/algolia/models/personalization/event_scoring.rb +25 -4
  44. data/lib/algolia/models/personalization/event_type.rb +34 -0
  45. data/lib/algolia/models/personalization/facet_scoring.rb +2 -2
  46. data/lib/algolia/models/personalization/get_user_token_response.rb +3 -3
  47. data/lib/algolia/models/personalization/personalization_strategy_params.rb +21 -3
  48. data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +1 -1
  49. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +1 -1
  50. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +1 -1
  51. data/lib/algolia/models/query-suggestions/source_index.rb +1 -1
  52. data/lib/algolia/models/recommend/base_recommend_request.rb +1 -1
  53. data/lib/algolia/models/recommend/base_search_params.rb +3 -3
  54. data/lib/algolia/models/recommend/base_search_params_without_query.rb +3 -3
  55. data/lib/algolia/models/recommend/bought_together_query.rb +1 -1
  56. data/lib/algolia/models/recommend/fallback_params.rb +9 -9
  57. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +6 -6
  58. data/lib/algolia/models/recommend/looking_similar_query.rb +1 -1
  59. data/lib/algolia/models/recommend/re_ranking_apply_filter.rb +1 -1
  60. data/lib/algolia/models/recommend/recommended_for_you_query.rb +1 -1
  61. data/lib/algolia/models/recommend/related_query.rb +1 -1
  62. data/lib/algolia/models/recommend/search_params.rb +9 -9
  63. data/lib/algolia/models/recommend/search_params_object.rb +10 -9
  64. data/lib/algolia/models/recommend/trending_facets_query.rb +1 -1
  65. data/lib/algolia/models/recommend/trending_items_query.rb +1 -1
  66. data/lib/algolia/models/search/base_index_settings.rb +9 -9
  67. data/lib/algolia/models/search/base_search_params.rb +3 -3
  68. data/lib/algolia/models/search/base_search_params_without_query.rb +3 -3
  69. data/lib/algolia/models/search/browse_params_object.rb +9 -9
  70. data/lib/algolia/models/search/consequence_params.rb +9 -9
  71. data/lib/algolia/models/search/delete_by_params.rb +1 -1
  72. data/lib/algolia/models/search/index_settings.rb +15 -15
  73. data/lib/algolia/models/search/index_settings_as_search_params.rb +6 -6
  74. data/lib/algolia/models/search/multiple_batch_request.rb +1 -1
  75. data/lib/algolia/models/search/operation_index_params.rb +1 -1
  76. data/lib/algolia/models/search/re_ranking_apply_filter.rb +1 -1
  77. data/lib/algolia/models/search/search_for_facets.rb +10 -10
  78. data/lib/algolia/models/search/search_for_facets_options.rb +1 -1
  79. data/lib/algolia/models/search/search_for_hits.rb +10 -10
  80. data/lib/algolia/models/search/search_for_hits_options.rb +1 -1
  81. data/lib/algolia/models/search/search_params_object.rb +10 -9
  82. data/lib/algolia/version.rb +1 -1
  83. metadata +15 -2
@@ -0,0 +1,198 @@
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 Abtesting
8
+ # Configuration for handling outliers.
9
+ class Outliers
10
+ # Whether to exclude outliers when calculating A/B test results.
11
+ attr_accessor :exclude
12
+
13
+ # Attribute mapping from ruby-style variable name to JSON key.
14
+ def self.attribute_map
15
+ {
16
+ :exclude => :exclude
17
+ }
18
+ end
19
+
20
+ # Returns all the JSON keys this model knows about
21
+ def self.acceptable_attributes
22
+ attribute_map.values
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.types_mapping
27
+ {
28
+ :exclude => :Boolean
29
+ }
30
+ end
31
+
32
+ # List of attributes with nullable: true
33
+ def self.openapi_nullable
34
+ Set.new([])
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ unless attributes.is_a?(Hash)
41
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Outliers` initialize method"
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({}) do |(k, v), h|
46
+ unless self.class.attribute_map.key?(k.to_sym)
47
+ raise ArgumentError,
48
+ "`#{k}` is not a valid attribute in `Algolia::Outliers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
49
+ end
50
+
51
+ h[k.to_sym] = v
52
+ end
53
+
54
+ if attributes.key?(:exclude)
55
+ self.exclude = attributes[:exclude]
56
+ end
57
+ end
58
+
59
+ # Checks equality by comparing each attribute.
60
+ # @param [Object] Object to be compared
61
+ def ==(other)
62
+ return true if equal?(other)
63
+
64
+ self.class == other.class &&
65
+ exclude == other.exclude
66
+ end
67
+
68
+ # @see the `==` method
69
+ # @param [Object] Object to be compared
70
+ def eql?(other)
71
+ self == other
72
+ end
73
+
74
+ # Calculates hash code according to all attributes.
75
+ # @return [Integer] Hash code
76
+ def hash
77
+ [exclude].hash
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def self.build_from_hash(attributes)
84
+ return nil unless attributes.is_a?(Hash)
85
+
86
+ attributes = attributes.transform_keys(&:to_sym)
87
+ transformed_hash = {}
88
+ types_mapping.each_pair do |key, type|
89
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
90
+ transformed_hash[key.to_sym] = nil
91
+ elsif type =~ /\AArray<(.*)>/i
92
+ # check to ensure the input is an array given that the attribute
93
+ # is documented as an array but the input is not
94
+ if attributes[attribute_map[key]].is_a?(Array)
95
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
96
+ end
97
+ elsif !attributes[attribute_map[key]].nil?
98
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
99
+ end
100
+ end
101
+ new(transformed_hash)
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def self._deserialize(type, value)
109
+ case type.to_sym
110
+ when :Time
111
+ Time.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :Boolean
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when :Object
127
+ # generic object (usually a Hash), return directly
128
+ value
129
+ when /\AArray<(?<inner_type>.+)>\z/
130
+ inner_type = Regexp.last_match[:inner_type]
131
+ value.map { |v| _deserialize(inner_type, v) }
132
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
133
+ k_type = Regexp.last_match[:k_type]
134
+ v_type = Regexp.last_match[:v_type]
135
+ {}.tap do |hash|
136
+ value.each do |k, v|
137
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
138
+ end
139
+ end
140
+ else # model
141
+ # models (e.g. Pet) or oneOf
142
+ klass = Algolia::Abtesting.const_get(type)
143
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
144
+ end
145
+ end
146
+
147
+ # Returns the string representation of the object
148
+ # @return [String] String presentation of the object
149
+ def to_s
150
+ to_hash.to_s
151
+ end
152
+
153
+ # to_body is an alias to to_hash (backward compatibility)
154
+ # @return [Hash] Returns the object in the form of hash
155
+ def to_body
156
+ to_hash
157
+ end
158
+
159
+ def to_json(*_args)
160
+ to_hash.to_json
161
+ end
162
+
163
+ # Returns the object in the form of hash
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_hash
166
+ hash = {}
167
+ self.class.attribute_map.each_pair do |attr, param|
168
+ value = send(attr)
169
+ if value.nil?
170
+ is_nullable = self.class.openapi_nullable.include?(attr)
171
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
172
+ end
173
+
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map { |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,35 @@
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 Abtesting
8
+ class Status
9
+ ACTIVE = "active".freeze
10
+ STOPPED = "stopped".freeze
11
+ EXPIRED = "expired".freeze
12
+ FAILED = "failed".freeze
13
+
14
+ def self.all_vars
15
+ @all_vars ||= [ACTIVE, STOPPED, EXPIRED, FAILED].freeze
16
+ end
17
+
18
+ # Builds the enum from string
19
+ # @param [String] The enum value in the form of the string
20
+ # @return [String] The enum value
21
+ def self.build_from_hash(value)
22
+ new.build_from_hash(value)
23
+ end
24
+
25
+ # Builds the enum from string
26
+ # @param [String] The enum value in the form of the string
27
+ # @return [String] The enum value
28
+ def build_from_hash(value)
29
+ return value if Status.all_vars.include?(value)
30
+
31
+ raise "Invalid ENUM value #{value} for class #Status"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -9,60 +9,60 @@ module Algolia
9
9
  # Number of add-to-cart events for this variant.
10
10
  attr_accessor :add_to_cart_count
11
11
 
12
- # Variant's [add-to-cart rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#add-to-cart-rate).
12
+ # [Add-to-cart rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#add-to-cart-rate) for this variant.
13
13
  attr_accessor :add_to_cart_rate
14
14
 
15
- # Variant's [average click position](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-position).
15
+ # [Average click position](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-position) for this variant.
16
16
  attr_accessor :average_click_position
17
17
 
18
18
  # Number of click events for this variant.
19
19
  attr_accessor :click_count
20
20
 
21
- # Variant's [click-through rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-through-rate).
21
+ # [Click-through rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-through-rate) for this variant.
22
22
  attr_accessor :click_through_rate
23
23
 
24
24
  # Number of click events for this variant.
25
25
  attr_accessor :conversion_count
26
26
 
27
- # Variant's [conversion rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#conversion-rate).
27
+ # [Conversion rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#conversion-rate) for this variant.
28
28
  attr_accessor :conversion_rate
29
29
 
30
30
  # A/B test currencies.
31
31
  attr_accessor :currencies
32
32
 
33
- # A/B test description.
33
+ # Description for this variant.
34
34
  attr_accessor :description
35
35
 
36
- # The estimated number of searches that will need to be run to achieve the desired confidence level and statistical power. A `minimumDetectableEffect` must be set in the `configuration` object for this to be used.
36
+ # Estimated number of searches required to achieve the desired statistical significance. The A/B test configuration must include a `mininmumDetectableEffect` setting for this number to be included in the response.
37
37
  attr_accessor :estimated_sample_size
38
38
 
39
39
  attr_accessor :filter_effects
40
40
 
41
- # A/B test index.
41
+ # Index name of the A/B test variant (case-sensitive).
42
42
  attr_accessor :index
43
43
 
44
- # Number of [searches without results](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#searches-without-results) for that variant.
44
+ # Number of [searches without results](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#searches-without-results) for this variant.
45
45
  attr_accessor :no_result_count
46
46
 
47
47
  # Number of purchase events for this variant.
48
48
  attr_accessor :purchase_count
49
49
 
50
- # Variant's [purchase rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#purchase-rate).
50
+ # [Purchase rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#purchase-rate) for this variant.
51
51
  attr_accessor :purchase_rate
52
52
 
53
- # Number of searches carried out during the A/B test.
53
+ # Number of searches for this variant.
54
54
  attr_accessor :search_count
55
55
 
56
56
  # Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
57
57
  attr_accessor :tracked_search_count
58
58
 
59
- # A/B test traffic percentage.
59
+ # Percentage of search requests each variant receives.
60
60
  attr_accessor :traffic_percentage
61
61
 
62
- # Number of users during the A/B test.
62
+ # Number of users that made searches to this variant.
63
63
  attr_accessor :user_count
64
64
 
65
- # Number of users that performed a tracked search during the A/B test.
65
+ # Number of users that made tracked searches to this variant.
66
66
  attr_accessor :tracked_user_count
67
67
 
68
68
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -269,6 +269,24 @@ module Algolia
269
269
  end
270
270
  end
271
271
 
272
+ # Custom attribute writer method with validation
273
+ # @param [Object] traffic_percentage Value to be assigned
274
+ def traffic_percentage=(traffic_percentage)
275
+ if traffic_percentage.nil?
276
+ raise ArgumentError, 'traffic_percentage cannot be nil'
277
+ end
278
+
279
+ if traffic_percentage > 100
280
+ raise ArgumentError, 'invalid value for "traffic_percentage", must be smaller than or equal to 100.'
281
+ end
282
+
283
+ if traffic_percentage < 0
284
+ raise ArgumentError, 'invalid value for "traffic_percentage", must be greater than or equal to 0.'
285
+ end
286
+
287
+ @traffic_percentage = traffic_percentage
288
+ end
289
+
272
290
  # Checks equality by comparing each attribute.
273
291
  # @param [Object] Object to be compared
274
292
  def ==(other)
@@ -6,7 +6,7 @@ require 'time'
6
6
  module Algolia
7
7
  module Ingestion
8
8
  class DestinationIndexName
9
- # Algolia index name.
9
+ # Algolia index name (case-sensitive).
10
10
  attr_accessor :index_name
11
11
 
12
12
  attr_accessor :record_type
@@ -0,0 +1,212 @@
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
+ # Represents the required elements of the task input when using a `shopify` source.
9
+ class ShopifyInput
10
+ attr_accessor :metafields
11
+
12
+ attr_accessor :market
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :metafields => :metafields,
18
+ :market => :market
19
+ }
20
+ end
21
+
22
+ # Returns all the JSON keys this model knows about
23
+ def self.acceptable_attributes
24
+ attribute_map.values
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.types_mapping
29
+ {
30
+ :metafields => :'Array<ShopifyMetafield>',
31
+ :market => :ShopifyMarket
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([])
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ unless attributes.is_a?(Hash)
44
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::ShopifyInput` initialize method"
45
+ end
46
+
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) do |(k, v), h|
49
+ unless self.class.attribute_map.key?(k.to_sym)
50
+ raise ArgumentError,
51
+ "`#{k}` is not a valid attribute in `Algolia::ShopifyInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+
54
+ h[k.to_sym] = v
55
+ end
56
+
57
+ if attributes.key?(:metafields)
58
+ if (value = attributes[:metafields]).is_a?(Array)
59
+ self.metafields = value
60
+ end
61
+ else
62
+ self.metafields = nil
63
+ end
64
+
65
+ if attributes.key?(:market)
66
+ self.market = attributes[:market]
67
+ else
68
+ self.market = nil
69
+ end
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(other)
75
+ return true if equal?(other)
76
+
77
+ self.class == other.class &&
78
+ metafields == other.metafields &&
79
+ market == other.market
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(other)
85
+ self == other
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Integer] Hash code
90
+ def hash
91
+ [metafields, market].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def self.build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+
100
+ attributes = attributes.transform_keys(&:to_sym)
101
+ transformed_hash = {}
102
+ types_mapping.each_pair do |key, type|
103
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
104
+ transformed_hash[key.to_sym] = nil
105
+ elsif type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[attribute_map[key]].is_a?(Array)
109
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
110
+ end
111
+ elsif !attributes[attribute_map[key]].nil?
112
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
113
+ end
114
+ end
115
+ new(transformed_hash)
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def self._deserialize(type, value)
123
+ case type.to_sym
124
+ when :Time
125
+ Time.parse(value)
126
+ when :Date
127
+ Date.parse(value)
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :Boolean
135
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
136
+ true
137
+ else
138
+ false
139
+ end
140
+ when :Object
141
+ # generic object (usually a Hash), return directly
142
+ value
143
+ when /\AArray<(?<inner_type>.+)>\z/
144
+ inner_type = Regexp.last_match[:inner_type]
145
+ value.map { |v| _deserialize(inner_type, v) }
146
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
147
+ k_type = Regexp.last_match[:k_type]
148
+ v_type = Regexp.last_match[:v_type]
149
+ {}.tap do |hash|
150
+ value.each do |k, v|
151
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
152
+ end
153
+ end
154
+ else # model
155
+ # models (e.g. Pet) or oneOf
156
+ klass = Algolia::Ingestion.const_get(type)
157
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
158
+ end
159
+ end
160
+
161
+ # Returns the string representation of the object
162
+ # @return [String] String presentation of the object
163
+ def to_s
164
+ to_hash.to_s
165
+ end
166
+
167
+ # to_body is an alias to to_hash (backward compatibility)
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_body
170
+ to_hash
171
+ end
172
+
173
+ def to_json(*_args)
174
+ to_hash.to_json
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ hash = {}
181
+ self.class.attribute_map.each_pair do |attr, param|
182
+ value = send(attr)
183
+ if value.nil?
184
+ is_nullable = self.class.openapi_nullable.include?(attr)
185
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
186
+ end
187
+
188
+ hash[param] = _to_hash(value)
189
+ end
190
+ hash
191
+ end
192
+
193
+ # Outputs non-array value in the form of hash
194
+ # For object, use to_hash. Otherwise, just return the value
195
+ # @param [Object] value Any valid value
196
+ # @return [Hash] Returns the value in the form of hash
197
+ def _to_hash(value)
198
+ if value.is_a?(Array)
199
+ value.compact.map { |v| _to_hash(v) }
200
+ elsif value.is_a?(Hash)
201
+ {}.tap do |hash|
202
+ value.each { |k, v| hash[k] = _to_hash(v) }
203
+ end
204
+ elsif value.respond_to? :to_hash
205
+ value.to_hash
206
+ else
207
+ value
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end