algolia 3.0.0.beta.11 → 3.0.0.beta.12

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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/algolia/api/query_suggestions_client.rb +4 -10
  5. data/lib/algolia/api/search_client.rb +2 -2
  6. data/lib/algolia/api/usage_client.rb +4 -4
  7. data/lib/algolia/models/abtesting/{filter_effects_empty_search.rb → empty_search_filter.rb} +3 -3
  8. data/lib/algolia/models/abtesting/filter_effects.rb +2 -2
  9. data/lib/algolia/models/abtesting/{filter_effects_outliers.rb → outliers_filter.rb} +3 -3
  10. data/lib/algolia/models/analytics/{click_positions_inner.rb → click_position.rb} +3 -3
  11. data/lib/algolia/models/analytics/get_click_positions_response.rb +1 -1
  12. data/lib/algolia/models/analytics/top_search_with_analytics.rb +1 -1
  13. data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +1 -1
  14. data/lib/algolia/models/ingestion/docker_streams_input.rb +1 -0
  15. data/lib/algolia/models/ingestion/{transformation_try_response_error.rb → transformation_error.rb} +3 -3
  16. data/lib/algolia/models/ingestion/transformation_try_response.rb +1 -1
  17. data/lib/algolia/models/monitoring/{incidents_inner.rb → incident_entry.rb} +3 -3
  18. data/lib/algolia/models/monitoring/{indexing_time_response_metrics.rb → indexing_metric.rb} +3 -3
  19. data/lib/algolia/models/monitoring/indexing_time_response.rb +1 -1
  20. data/lib/algolia/models/monitoring/infrastructure_response.rb +1 -1
  21. data/lib/algolia/models/monitoring/{latency_response_metrics.rb → latency_metric.rb} +3 -3
  22. data/lib/algolia/models/monitoring/latency_response.rb +1 -1
  23. data/lib/algolia/models/monitoring/{infrastructure_response_metrics.rb → metrics.rb} +3 -6
  24. data/lib/algolia/models/monitoring/{time_inner.rb → time_entry.rb} +3 -3
  25. data/lib/algolia/models/{search/search_for_hits_options.rb → query-suggestions/config_status.rb} +43 -36
  26. data/lib/algolia/models/{recommend/related_products.rb → query-suggestions/log_file.rb} +36 -32
  27. data/lib/algolia/models/recommend/around_precision.rb +1 -1
  28. data/lib/algolia/models/recommend/fallback_params.rb +1 -1
  29. data/lib/algolia/models/recommend/{around_precision_from_value_inner.rb → range.rb} +3 -6
  30. data/lib/algolia/models/recommend/recommend_rule.rb +1 -1
  31. data/lib/algolia/models/recommend/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  32. data/lib/algolia/models/recommend/redirect_rule_index_metadata.rb +1 -1
  33. data/lib/algolia/models/recommend/{recommend_rule_metadata.rb → rule_metadata.rb} +3 -3
  34. data/lib/algolia/models/recommend/search_params.rb +1 -1
  35. data/lib/algolia/models/recommend/search_params_object.rb +1 -1
  36. data/lib/algolia/models/search/around_precision.rb +1 -1
  37. data/lib/algolia/models/search/browse_params_object.rb +1 -1
  38. data/lib/algolia/models/search/built_in_operation.rb +1 -2
  39. data/lib/algolia/models/search/built_in_operation_value.rb +105 -0
  40. data/lib/algolia/models/search/consequence_params.rb +1 -1
  41. data/lib/algolia/models/search/dictionary_entry.rb +0 -2
  42. data/lib/algolia/models/search/index_settings.rb +2 -2
  43. data/lib/algolia/models/search/{around_precision_from_value_inner.rb → range.rb} +3 -6
  44. data/lib/algolia/models/search/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  45. data/lib/algolia/models/search/redirect_rule_index_metadata.rb +1 -1
  46. data/lib/algolia/models/search/search_for_facets.rb +1 -1
  47. data/lib/algolia/models/search/search_for_hits.rb +1 -1
  48. data/lib/algolia/models/search/search_params_object.rb +1 -1
  49. data/lib/algolia/models/search/search_params_string.rb +1 -0
  50. data/lib/algolia/models/search/settings_response.rb +2 -2
  51. data/lib/algolia/models/usage/{get_usage400_response_error_errors_inner.rb → error_item.rb} +3 -3
  52. data/lib/algolia/models/usage/{get_usage400_response_error.rb → forbidden_error.rb} +4 -4
  53. data/lib/algolia/models/usage/{get_usage200_response.rb → index_usage.rb} +4 -4
  54. data/lib/algolia/models/usage/invalid_request_error.rb +231 -0
  55. data/lib/algolia/models/usage/{get_usage200_response_statistics_inner.rb → statistic_entry.rb} +3 -3
  56. data/lib/algolia/version.rb +1 -1
  57. metadata +24 -64
  58. data/lib/algolia/models/abtesting/custom_search_params.rb +0 -214
  59. data/lib/algolia/models/abtesting/error_base.rb +0 -212
  60. data/lib/algolia/models/analytics/error_base.rb +0 -212
  61. data/lib/algolia/models/ingestion/error_base.rb +0 -212
  62. data/lib/algolia/models/ingestion/source_shopify_base.rb +0 -214
  63. data/lib/algolia/models/insights/error_base.rb +0 -212
  64. data/lib/algolia/models/monitoring/error_base.rb +0 -212
  65. data/lib/algolia/models/monitoring/get_servers403_response.rb +0 -211
  66. data/lib/algolia/models/personalization/error_base.rb +0 -212
  67. data/lib/algolia/models/query-suggestions/app_id.rb +0 -209
  68. data/lib/algolia/models/query-suggestions/error_base.rb +0 -212
  69. data/lib/algolia/models/recommend/base_recommend_request.rb +0 -281
  70. data/lib/algolia/models/recommend/base_search_params.rb +0 -635
  71. data/lib/algolia/models/recommend/base_search_params_without_query.rb +0 -616
  72. data/lib/algolia/models/recommend/base_search_response.rb +0 -499
  73. data/lib/algolia/models/recommend/error_base.rb +0 -212
  74. data/lib/algolia/models/recommend/frequently_bought_together.rb +0 -247
  75. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +0 -788
  76. data/lib/algolia/models/recommend/looking_similar.rb +0 -256
  77. data/lib/algolia/models/recommend/recommendations_hits.rb +0 -215
  78. data/lib/algolia/models/recommend/recommended_for_you.rb +0 -244
  79. data/lib/algolia/models/recommend/search_pagination.rb +0 -282
  80. data/lib/algolia/models/recommend/search_params_query.rb +0 -212
  81. data/lib/algolia/models/recommend/trending_facets.rb +0 -258
  82. data/lib/algolia/models/recommend/trending_items.rb +0 -264
  83. data/lib/algolia/models/search/base_get_api_key_response.rb +0 -224
  84. data/lib/algolia/models/search/base_index_settings.rb +0 -426
  85. data/lib/algolia/models/search/base_search_params.rb +0 -635
  86. data/lib/algolia/models/search/base_search_params_without_query.rb +0 -616
  87. data/lib/algolia/models/search/base_search_response.rb +0 -499
  88. data/lib/algolia/models/search/browse_pagination.rb +0 -274
  89. data/lib/algolia/models/search/cursor.rb +0 -209
  90. data/lib/algolia/models/search/error_base.rb +0 -212
  91. data/lib/algolia/models/search/index_settings_as_search_params.rb +0 -788
  92. data/lib/algolia/models/search/params.rb +0 -236
  93. data/lib/algolia/models/search/search_for_facets_options.rb +0 -293
  94. data/lib/algolia/models/search/search_hits.rb +0 -240
  95. data/lib/algolia/models/search/search_pagination.rb +0 -282
  96. data/lib/algolia/models/search/search_params_query.rb +0 -212
  97. data/lib/algolia/models/search/with_primary.rb +0 -212
  98. data/lib/algolia/models/usage/error_base.rb +0 -212
  99. data/lib/algolia/models/usage/get_usage400_response.rb +0 -213
@@ -1,212 +0,0 @@
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 Search
8
- class SearchParamsQuery
9
- # Search query.
10
- attr_accessor :query
11
-
12
- # Attribute mapping from ruby-style variable name to JSON key.
13
- def self.attribute_map
14
- {
15
- :query => :query
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
- :query => :"String"
28
- }
29
- end
30
-
31
- # List of attributes with nullable: true
32
- def self.openapi_nullable
33
- Set.new(
34
- []
35
- )
36
- end
37
-
38
- # Initializes the object
39
- # @param [Hash] attributes Model attributes in the form of hash
40
- def initialize(attributes = {})
41
- if (!attributes.is_a?(Hash))
42
- raise(
43
- ArgumentError,
44
- "The input argument (attributes) must be a hash in `Algolia::SearchParamsQuery` initialize method"
45
- )
46
- end
47
-
48
- # check to see if the attribute exists and convert string to symbol for hash key
49
- attributes = attributes.each_with_object({}) { |(k, v), h|
50
- if (!self.class.attribute_map.key?(k.to_sym))
51
- raise(
52
- ArgumentError,
53
- "`#{k}` is not a valid attribute in `Algolia::SearchParamsQuery`. Please check the name to make sure it's valid. List of attributes: " +
54
- self.class.attribute_map.keys.inspect
55
- )
56
- end
57
-
58
- h[k.to_sym] = v
59
- }
60
-
61
- if attributes.key?(:query)
62
- self.query = attributes[:query]
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
- query == other.query
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
- [query].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::Search.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
@@ -1,212 +0,0 @@
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 Search
8
- class WithPrimary
9
- # Replica indices only: the name of the primary index for this replica.
10
- attr_accessor :primary
11
-
12
- # Attribute mapping from ruby-style variable name to JSON key.
13
- def self.attribute_map
14
- {
15
- :primary => :primary
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
- :primary => :"String"
28
- }
29
- end
30
-
31
- # List of attributes with nullable: true
32
- def self.openapi_nullable
33
- Set.new(
34
- []
35
- )
36
- end
37
-
38
- # Initializes the object
39
- # @param [Hash] attributes Model attributes in the form of hash
40
- def initialize(attributes = {})
41
- if (!attributes.is_a?(Hash))
42
- raise(
43
- ArgumentError,
44
- "The input argument (attributes) must be a hash in `Algolia::WithPrimary` initialize method"
45
- )
46
- end
47
-
48
- # check to see if the attribute exists and convert string to symbol for hash key
49
- attributes = attributes.each_with_object({}) { |(k, v), h|
50
- if (!self.class.attribute_map.key?(k.to_sym))
51
- raise(
52
- ArgumentError,
53
- "`#{k}` is not a valid attribute in `Algolia::WithPrimary`. Please check the name to make sure it's valid. List of attributes: " +
54
- self.class.attribute_map.keys.inspect
55
- )
56
- end
57
-
58
- h[k.to_sym] = v
59
- }
60
-
61
- if attributes.key?(:primary)
62
- self.primary = attributes[:primary]
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
- primary == other.primary
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
- [primary].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::Search.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
@@ -1,212 +0,0 @@
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 Usage
8
- # Error.
9
- class ErrorBase
10
- attr_accessor :message
11
-
12
- attr_accessor :additional_properties
13
-
14
- # Attribute mapping from ruby-style variable name to JSON key.
15
- def self.attribute_map
16
- {
17
- :message => :message
18
- }
19
- end
20
-
21
- # Returns all the JSON keys this model knows about
22
- def self.acceptable_attributes
23
- attribute_map.values
24
- end
25
-
26
- # Attribute type mapping.
27
- def self.types_mapping
28
- {
29
- :message => :"String"
30
- }
31
- end
32
-
33
- # List of attributes with nullable: true
34
- def self.openapi_nullable
35
- Set.new(
36
- []
37
- )
38
- end
39
-
40
- # Initializes the object
41
- # @param [Hash] attributes Model attributes in the form of hash
42
- def initialize(attributes = {})
43
- if (!attributes.is_a?(Hash))
44
- raise(
45
- ArgumentError,
46
- "The input argument (attributes) must be a hash in `Algolia::ErrorBase` initialize method"
47
- )
48
- end
49
-
50
- if attributes.key?(:message)
51
- self.message = attributes[:message]
52
- end
53
-
54
- # add extra attribute to additional_properties
55
- self.additional_properties ||= {}
56
- self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
57
- end
58
-
59
- # Checks equality by comparing each attribute.
60
- # @param [Object] Object to be compared
61
- def ==(other)
62
- return true if self.equal?(other)
63
- self.class == other.class &&
64
- message == other.message
65
- end
66
-
67
- # @see the `==` method
68
- # @param [Object] Object to be compared
69
- def eql?(other)
70
- self == other
71
- end
72
-
73
- # Calculates hash code according to all attributes.
74
- # @return [Integer] Hash code
75
- def hash
76
- [message].hash
77
- end
78
-
79
- # Builds the object from hash
80
- # @param [Hash] attributes Model attributes in the form of hash
81
- # @return [Object] Returns the model itself
82
- def self.build_from_hash(attributes)
83
- return nil unless attributes.is_a?(Hash)
84
- attributes = attributes.transform_keys(&:to_sym)
85
- transformed_hash = {}
86
- types_mapping.each_pair do |key, type|
87
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
88
- transformed_hash[key.to_sym] = nil
89
- elsif type =~ /\AArray<(.*)>/i
90
- # check to ensure the input is an array given that the attribute
91
- # is documented as an array but the input is not
92
- if attributes[attribute_map[key]].is_a?(Array)
93
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
94
- _deserialize(::Regexp.last_match(1), v)
95
- }
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
-
102
- # add extra attribute to transformed_hash
103
- transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
104
- new(transformed_hash)
105
- end
106
-
107
- # Deserializes the data based on type
108
- # @param string type Data type
109
- # @param string value Value to be deserialized
110
- # @return [Object] Deserialized data
111
- def self._deserialize(type, value)
112
- case type.to_sym
113
- when :Time
114
- Time.parse(value)
115
- when :Date
116
- Date.parse(value)
117
- when :String
118
- value.to_s
119
- when :Integer
120
- value.to_i
121
- when :Float
122
- value.to_f
123
- when :Boolean
124
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
125
- true
126
- else
127
- false
128
- end
129
-
130
- when :Object
131
- # generic object (usually a Hash), return directly
132
- value
133
- when /\AArray<(?<inner_type>.+)>\z/
134
- inner_type = Regexp.last_match[:inner_type]
135
- value.map { |v| _deserialize(inner_type, v) }
136
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
- k_type = Regexp.last_match[:k_type]
138
- v_type = Regexp.last_match[:v_type]
139
- {}.tap do |hash|
140
- value.each do |k, v|
141
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
- end
143
- end
144
- # model
145
- else
146
- # models (e.g. Pet) or oneOf
147
- klass = Algolia::Usage.const_get(type)
148
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
149
- .build_from_hash(value)
150
- end
151
- end
152
-
153
- # Returns the string representation of the object
154
- # @return [String] String presentation of the object
155
- def to_s
156
- to_hash.to_s
157
- end
158
-
159
- # to_body is an alias to to_hash (backward compatibility)
160
- # @return [Hash] Returns the object in the form of hash
161
- def to_body
162
- to_hash
163
- end
164
-
165
- def to_json(*_args)
166
- to_hash.to_json
167
- end
168
-
169
- # Returns the object in the form of hash
170
- # @return [Hash] Returns the object in the form of hash
171
- def to_hash
172
- hash = {}
173
- self.class.attribute_map.each_pair do |attr, param|
174
- value = send(attr)
175
- if value.nil?
176
- is_nullable = self.class.openapi_nullable.include?(attr)
177
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
178
- end
179
-
180
- hash[param] = _to_hash(value)
181
- end
182
-
183
- # also add attributes from additional_properties to hash
184
- self.additional_properties&.each_pair do |k, v|
185
- hash[k.to_sym] = _to_hash(v)
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