algolia 3.0.0.beta.10 → 3.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/algolia/api/ingestion_client.rb +912 -359
  5. data/lib/algolia/api/query_suggestions_client.rb +4 -10
  6. data/lib/algolia/api/search_client.rb +4 -4
  7. data/lib/algolia/api/usage_client.rb +4 -4
  8. data/lib/algolia/error.rb +10 -0
  9. data/lib/algolia/logger_helper.rb +11 -2
  10. data/lib/algolia/models/abtesting/{filter_effects_empty_search.rb → empty_search_filter.rb} +3 -3
  11. data/lib/algolia/models/abtesting/filter_effects.rb +2 -2
  12. data/lib/algolia/models/abtesting/{filter_effects_outliers.rb → outliers_filter.rb} +3 -3
  13. data/lib/algolia/models/analytics/{click_positions_inner.rb → click_position.rb} +3 -3
  14. data/lib/algolia/models/analytics/get_click_positions_response.rb +1 -1
  15. data/lib/algolia/models/analytics/top_search_with_analytics.rb +1 -1
  16. data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +1 -1
  17. data/lib/algolia/models/ingestion/action.rb +45 -0
  18. data/lib/algolia/models/{search/search_for_hits_options.rb → ingestion/batch_request.rb} +22 -20
  19. data/lib/algolia/models/ingestion/{source_shopify_base.rb → batch_write_params.rb} +14 -12
  20. data/lib/algolia/models/ingestion/docker_streams_input.rb +1 -0
  21. data/lib/algolia/models/{recommend/recommendations_hits.rb → ingestion/list_tasks_response_v1.rb} +26 -14
  22. data/lib/algolia/models/ingestion/task.rb +30 -9
  23. data/lib/algolia/models/ingestion/task_create.rb +11 -12
  24. data/lib/algolia/models/{search/search_for_facets_options.rb → ingestion/task_create_v1.rb} +86 -51
  25. data/lib/algolia/models/ingestion/task_update.rb +8 -7
  26. data/lib/algolia/models/{search/browse_pagination.rb → ingestion/task_update_v1.rb} +50 -55
  27. data/lib/algolia/models/{recommend/looking_similar.rb → ingestion/task_v1.rb} +147 -30
  28. data/lib/algolia/models/ingestion/{transformation_try_response_error.rb → transformation_error.rb} +3 -3
  29. data/lib/algolia/models/ingestion/transformation_try_response.rb +1 -1
  30. data/lib/algolia/models/monitoring/{incidents_inner.rb → incident_entry.rb} +3 -3
  31. data/lib/algolia/models/monitoring/{indexing_time_response_metrics.rb → indexing_metric.rb} +3 -3
  32. data/lib/algolia/models/monitoring/indexing_time_response.rb +1 -1
  33. data/lib/algolia/models/monitoring/infrastructure_response.rb +1 -1
  34. data/lib/algolia/models/monitoring/{latency_response_metrics.rb → latency_metric.rb} +3 -3
  35. data/lib/algolia/models/monitoring/latency_response.rb +1 -1
  36. data/lib/algolia/models/monitoring/{infrastructure_response_metrics.rb → metrics.rb} +3 -6
  37. data/lib/algolia/models/monitoring/{time_inner.rb → time_entry.rb} +3 -3
  38. data/lib/algolia/models/{recommend/trending_items.rb → query-suggestions/config_status.rb} +46 -58
  39. data/lib/algolia/models/{recommend/related_products.rb → query-suggestions/log_file.rb} +36 -32
  40. data/lib/algolia/models/recommend/around_precision.rb +1 -1
  41. data/lib/algolia/models/recommend/fallback_params.rb +1 -1
  42. data/lib/algolia/models/recommend/{around_precision_from_value_inner.rb → range.rb} +3 -6
  43. data/lib/algolia/models/recommend/recommend_rule.rb +1 -1
  44. data/lib/algolia/models/recommend/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  45. data/lib/algolia/models/recommend/redirect_rule_index_metadata.rb +1 -1
  46. data/lib/algolia/models/recommend/{recommend_rule_metadata.rb → rule_metadata.rb} +3 -3
  47. data/lib/algolia/models/recommend/search_params.rb +1 -1
  48. data/lib/algolia/models/recommend/search_params_object.rb +1 -1
  49. data/lib/algolia/models/search/around_precision.rb +1 -1
  50. data/lib/algolia/models/search/browse_params_object.rb +1 -1
  51. data/lib/algolia/models/search/built_in_operation.rb +1 -2
  52. data/lib/algolia/models/search/built_in_operation_value.rb +105 -0
  53. data/lib/algolia/models/search/consequence_params.rb +1 -1
  54. data/lib/algolia/models/search/dictionary_entry.rb +0 -2
  55. data/lib/algolia/models/search/index_settings.rb +2 -2
  56. data/lib/algolia/models/search/{around_precision_from_value_inner.rb → range.rb} +3 -6
  57. data/lib/algolia/models/search/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  58. data/lib/algolia/models/search/redirect_rule_index_metadata.rb +1 -1
  59. data/lib/algolia/models/search/search_for_facets.rb +1 -1
  60. data/lib/algolia/models/search/search_for_hits.rb +1 -1
  61. data/lib/algolia/models/search/search_params_object.rb +1 -1
  62. data/lib/algolia/models/search/search_params_string.rb +1 -0
  63. data/lib/algolia/models/search/{index_settings_as_search_params.rb → settings_response.rb} +251 -11
  64. data/lib/algolia/models/usage/{get_usage400_response_error_errors_inner.rb → error_item.rb} +3 -3
  65. data/lib/algolia/models/usage/{get_usage400_response_error.rb → forbidden_error.rb} +4 -4
  66. data/lib/algolia/models/usage/{get_usage200_response.rb → index_usage.rb} +4 -4
  67. data/lib/algolia/models/usage/invalid_request_error.rb +231 -0
  68. data/lib/algolia/models/usage/{get_usage200_response_statistics_inner.rb → statistic_entry.rb} +3 -3
  69. data/lib/algolia/transport/transport.rb +8 -2
  70. data/lib/algolia/version.rb +1 -1
  71. metadata +32 -63
  72. data/lib/algolia/models/abtesting/custom_search_params.rb +0 -214
  73. data/lib/algolia/models/abtesting/error_base.rb +0 -212
  74. data/lib/algolia/models/analytics/error_base.rb +0 -212
  75. data/lib/algolia/models/ingestion/error_base.rb +0 -212
  76. data/lib/algolia/models/insights/error_base.rb +0 -212
  77. data/lib/algolia/models/monitoring/error_base.rb +0 -212
  78. data/lib/algolia/models/monitoring/get_servers403_response.rb +0 -211
  79. data/lib/algolia/models/personalization/error_base.rb +0 -212
  80. data/lib/algolia/models/query-suggestions/app_id.rb +0 -209
  81. data/lib/algolia/models/query-suggestions/error_base.rb +0 -212
  82. data/lib/algolia/models/recommend/base_recommend_request.rb +0 -281
  83. data/lib/algolia/models/recommend/base_search_params.rb +0 -635
  84. data/lib/algolia/models/recommend/base_search_params_without_query.rb +0 -616
  85. data/lib/algolia/models/recommend/base_search_response.rb +0 -499
  86. data/lib/algolia/models/recommend/error_base.rb +0 -212
  87. data/lib/algolia/models/recommend/frequently_bought_together.rb +0 -247
  88. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +0 -788
  89. data/lib/algolia/models/recommend/recommended_for_you.rb +0 -244
  90. data/lib/algolia/models/recommend/search_pagination.rb +0 -282
  91. data/lib/algolia/models/recommend/search_params_query.rb +0 -212
  92. data/lib/algolia/models/recommend/trending_facets.rb +0 -258
  93. data/lib/algolia/models/search/base_get_api_key_response.rb +0 -224
  94. data/lib/algolia/models/search/base_index_settings.rb +0 -426
  95. data/lib/algolia/models/search/base_search_params.rb +0 -635
  96. data/lib/algolia/models/search/base_search_params_without_query.rb +0 -616
  97. data/lib/algolia/models/search/base_search_response.rb +0 -499
  98. data/lib/algolia/models/search/cursor.rb +0 -209
  99. data/lib/algolia/models/search/error_base.rb +0 -212
  100. data/lib/algolia/models/search/params.rb +0 -236
  101. data/lib/algolia/models/search/search_hits.rb +0 -240
  102. data/lib/algolia/models/search/search_pagination.rb +0 -282
  103. data/lib/algolia/models/search/search_params_query.rb +0 -212
  104. data/lib/algolia/models/usage/error_base.rb +0 -212
  105. 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 Recommend
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::Recommend.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,258 +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 Recommend
8
- class TrendingFacets
9
- # Facet attribute for which to retrieve trending facet values.
10
- attr_accessor :facet_name
11
-
12
- attr_accessor :model
13
-
14
- attr_accessor :fallback_parameters
15
-
16
- class EnumAttributeValidator
17
- attr_reader :datatype
18
- attr_reader :allowable_values
19
-
20
- def initialize(datatype, allowable_values)
21
- @allowable_values = allowable_values.map do |value|
22
- case datatype.to_s
23
- when /Integer/i
24
- value.to_i
25
- when /Float/i
26
- value.to_f
27
- else
28
- value
29
- end
30
- end
31
- end
32
-
33
- def valid?(value)
34
- !value || allowable_values.include?(value)
35
- end
36
- end
37
-
38
- # Attribute mapping from ruby-style variable name to JSON key.
39
- def self.attribute_map
40
- {
41
- :facet_name => :facetName,
42
- :model => :model,
43
- :fallback_parameters => :fallbackParameters
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
- :facet_name => :"Object",
56
- :model => :"TrendingFacetsModel",
57
- :fallback_parameters => :"FallbackParams"
58
- }
59
- end
60
-
61
- # List of attributes with nullable: true
62
- def self.openapi_nullable
63
- Set.new(
64
- [
65
- :facet_name
66
- ]
67
- )
68
- end
69
-
70
- # Initializes the object
71
- # @param [Hash] attributes Model attributes in the form of hash
72
- def initialize(attributes = {})
73
- if (!attributes.is_a?(Hash))
74
- raise(
75
- ArgumentError,
76
- "The input argument (attributes) must be a hash in `Algolia::TrendingFacets` initialize method"
77
- )
78
- end
79
-
80
- # check to see if the attribute exists and convert string to symbol for hash key
81
- attributes = attributes.each_with_object({}) { |(k, v), h|
82
- if (!self.class.attribute_map.key?(k.to_sym))
83
- raise(
84
- ArgumentError,
85
- "`#{k}` is not a valid attribute in `Algolia::TrendingFacets`. Please check the name to make sure it's valid. List of attributes: " +
86
- self.class.attribute_map.keys.inspect
87
- )
88
- end
89
-
90
- h[k.to_sym] = v
91
- }
92
-
93
- if attributes.key?(:facet_name)
94
- self.facet_name = attributes[:facet_name]
95
- else
96
- self.facet_name = nil
97
- end
98
-
99
- if attributes.key?(:model)
100
- self.model = attributes[:model]
101
- else
102
- self.model = nil
103
- end
104
-
105
- if attributes.key?(:fallback_parameters)
106
- self.fallback_parameters = attributes[:fallback_parameters]
107
- end
108
- end
109
-
110
- # Checks equality by comparing each attribute.
111
- # @param [Object] Object to be compared
112
- def ==(other)
113
- return true if self.equal?(other)
114
- self.class == other.class &&
115
- facet_name == other.facet_name &&
116
- model == other.model &&
117
- fallback_parameters == other.fallback_parameters
118
- end
119
-
120
- # @see the `==` method
121
- # @param [Object] Object to be compared
122
- def eql?(other)
123
- self == other
124
- end
125
-
126
- # Calculates hash code according to all attributes.
127
- # @return [Integer] Hash code
128
- def hash
129
- [facet_name, model, fallback_parameters].hash
130
- end
131
-
132
- # Builds the object from hash
133
- # @param [Hash] attributes Model attributes in the form of hash
134
- # @return [Object] Returns the model itself
135
- def self.build_from_hash(attributes)
136
- return nil unless attributes.is_a?(Hash)
137
- attributes = attributes.transform_keys(&:to_sym)
138
- transformed_hash = {}
139
- types_mapping.each_pair do |key, type|
140
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
141
- transformed_hash[key.to_sym] = nil
142
- elsif type =~ /\AArray<(.*)>/i
143
- # check to ensure the input is an array given that the attribute
144
- # is documented as an array but the input is not
145
- if attributes[attribute_map[key]].is_a?(Array)
146
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
147
- _deserialize(::Regexp.last_match(1), v)
148
- }
149
- end
150
- elsif !attributes[attribute_map[key]].nil?
151
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
152
- end
153
- end
154
-
155
- new(transformed_hash)
156
- end
157
-
158
- # Deserializes the data based on type
159
- # @param string type Data type
160
- # @param string value Value to be deserialized
161
- # @return [Object] Deserialized data
162
- def self._deserialize(type, value)
163
- case type.to_sym
164
- when :Time
165
- Time.parse(value)
166
- when :Date
167
- Date.parse(value)
168
- when :String
169
- value.to_s
170
- when :Integer
171
- value.to_i
172
- when :Float
173
- value.to_f
174
- when :Boolean
175
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
- true
177
- else
178
- false
179
- end
180
-
181
- when :Object
182
- # generic object (usually a Hash), return directly
183
- value
184
- when /\AArray<(?<inner_type>.+)>\z/
185
- inner_type = Regexp.last_match[:inner_type]
186
- value.map { |v| _deserialize(inner_type, v) }
187
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
- k_type = Regexp.last_match[:k_type]
189
- v_type = Regexp.last_match[:v_type]
190
- {}.tap do |hash|
191
- value.each do |k, v|
192
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
- end
194
- end
195
- # model
196
- else
197
- # models (e.g. Pet) or oneOf
198
- klass = Algolia::Recommend.const_get(type)
199
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
200
- .build_from_hash(value)
201
- end
202
- end
203
-
204
- # Returns the string representation of the object
205
- # @return [String] String presentation of the object
206
- def to_s
207
- to_hash.to_s
208
- end
209
-
210
- # to_body is an alias to to_hash (backward compatibility)
211
- # @return [Hash] Returns the object in the form of hash
212
- def to_body
213
- to_hash
214
- end
215
-
216
- def to_json(*_args)
217
- to_hash.to_json
218
- end
219
-
220
- # Returns the object in the form of hash
221
- # @return [Hash] Returns the object in the form of hash
222
- def to_hash
223
- hash = {}
224
- self.class.attribute_map.each_pair do |attr, param|
225
- value = send(attr)
226
- if value.nil?
227
- is_nullable = self.class.openapi_nullable.include?(attr)
228
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
- end
230
-
231
- hash[param] = _to_hash(value)
232
- end
233
-
234
- hash
235
- end
236
-
237
- # Outputs non-array value in the form of hash
238
- # For object, use to_hash. Otherwise, just return the value
239
- # @param [Object] value Any valid value
240
- # @return [Hash] Returns the value in the form of hash
241
- def _to_hash(value)
242
- if value.is_a?(Array)
243
- value.compact.map { |v| _to_hash(v) }
244
- elsif value.is_a?(Hash)
245
- {}.tap do |hash|
246
- value.each { |k, v| hash[k] = _to_hash(v) }
247
- end
248
- elsif value.respond_to?(:to_hash)
249
- value.to_hash
250
- else
251
- value
252
- end
253
- end
254
-
255
- end
256
-
257
- end
258
- end
@@ -1,224 +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 BaseGetApiKeyResponse
9
- # API key.
10
- attr_accessor :value
11
-
12
- # Timestamp when the object was created, in milliseconds since the Unix epoch.
13
- attr_accessor :created_at
14
-
15
- # Attribute mapping from ruby-style variable name to JSON key.
16
- def self.attribute_map
17
- {
18
- :value => :value,
19
- :created_at => :createdAt
20
- }
21
- end
22
-
23
- # Returns all the JSON keys this model knows about
24
- def self.acceptable_attributes
25
- attribute_map.values
26
- end
27
-
28
- # Attribute type mapping.
29
- def self.types_mapping
30
- {
31
- :value => :"String",
32
- :created_at => :"Integer"
33
- }
34
- end
35
-
36
- # List of attributes with nullable: true
37
- def self.openapi_nullable
38
- Set.new(
39
- []
40
- )
41
- end
42
-
43
- # Initializes the object
44
- # @param [Hash] attributes Model attributes in the form of hash
45
- def initialize(attributes = {})
46
- if (!attributes.is_a?(Hash))
47
- raise(
48
- ArgumentError,
49
- "The input argument (attributes) must be a hash in `Algolia::BaseGetApiKeyResponse` initialize method"
50
- )
51
- end
52
-
53
- # check to see if the attribute exists and convert string to symbol for hash key
54
- attributes = attributes.each_with_object({}) { |(k, v), h|
55
- if (!self.class.attribute_map.key?(k.to_sym))
56
- raise(
57
- ArgumentError,
58
- "`#{k}` is not a valid attribute in `Algolia::BaseGetApiKeyResponse`. Please check the name to make sure it's valid. List of attributes: " +
59
- self.class.attribute_map.keys.inspect
60
- )
61
- end
62
-
63
- h[k.to_sym] = v
64
- }
65
-
66
- if attributes.key?(:value)
67
- self.value = attributes[:value]
68
- end
69
-
70
- if attributes.key?(:created_at)
71
- self.created_at = attributes[:created_at]
72
- else
73
- self.created_at = nil
74
- end
75
- end
76
-
77
- # Checks equality by comparing each attribute.
78
- # @param [Object] Object to be compared
79
- def ==(other)
80
- return true if self.equal?(other)
81
- self.class == other.class &&
82
- value == other.value &&
83
- created_at == other.created_at
84
- end
85
-
86
- # @see the `==` method
87
- # @param [Object] Object to be compared
88
- def eql?(other)
89
- self == other
90
- end
91
-
92
- # Calculates hash code according to all attributes.
93
- # @return [Integer] Hash code
94
- def hash
95
- [value, created_at].hash
96
- end
97
-
98
- # Builds the object from hash
99
- # @param [Hash] attributes Model attributes in the form of hash
100
- # @return [Object] Returns the model itself
101
- def self.build_from_hash(attributes)
102
- return nil unless attributes.is_a?(Hash)
103
- attributes = attributes.transform_keys(&:to_sym)
104
- transformed_hash = {}
105
- types_mapping.each_pair do |key, type|
106
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
107
- transformed_hash[key.to_sym] = nil
108
- elsif type =~ /\AArray<(.*)>/i
109
- # check to ensure the input is an array given that the attribute
110
- # is documented as an array but the input is not
111
- if attributes[attribute_map[key]].is_a?(Array)
112
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
113
- _deserialize(::Regexp.last_match(1), v)
114
- }
115
- end
116
- elsif !attributes[attribute_map[key]].nil?
117
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
118
- end
119
- end
120
-
121
- new(transformed_hash)
122
- end
123
-
124
- # Deserializes the data based on type
125
- # @param string type Data type
126
- # @param string value Value to be deserialized
127
- # @return [Object] Deserialized data
128
- def self._deserialize(type, value)
129
- case type.to_sym
130
- when :Time
131
- Time.parse(value)
132
- when :Date
133
- Date.parse(value)
134
- when :String
135
- value.to_s
136
- when :Integer
137
- value.to_i
138
- when :Float
139
- value.to_f
140
- when :Boolean
141
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
- true
143
- else
144
- false
145
- end
146
-
147
- when :Object
148
- # generic object (usually a Hash), return directly
149
- value
150
- when /\AArray<(?<inner_type>.+)>\z/
151
- inner_type = Regexp.last_match[:inner_type]
152
- value.map { |v| _deserialize(inner_type, v) }
153
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
- k_type = Regexp.last_match[:k_type]
155
- v_type = Regexp.last_match[:v_type]
156
- {}.tap do |hash|
157
- value.each do |k, v|
158
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
- end
160
- end
161
- # model
162
- else
163
- # models (e.g. Pet) or oneOf
164
- klass = Algolia::Search.const_get(type)
165
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
166
- .build_from_hash(value)
167
- end
168
- end
169
-
170
- # Returns the string representation of the object
171
- # @return [String] String presentation of the object
172
- def to_s
173
- to_hash.to_s
174
- end
175
-
176
- # to_body is an alias to to_hash (backward compatibility)
177
- # @return [Hash] Returns the object in the form of hash
178
- def to_body
179
- to_hash
180
- end
181
-
182
- def to_json(*_args)
183
- to_hash.to_json
184
- end
185
-
186
- # Returns the object in the form of hash
187
- # @return [Hash] Returns the object in the form of hash
188
- def to_hash
189
- hash = {}
190
- self.class.attribute_map.each_pair do |attr, param|
191
- value = send(attr)
192
- if value.nil?
193
- is_nullable = self.class.openapi_nullable.include?(attr)
194
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
195
- end
196
-
197
- hash[param] = _to_hash(value)
198
- end
199
-
200
- hash
201
- end
202
-
203
- # Outputs non-array value in the form of hash
204
- # For object, use to_hash. Otherwise, just return the value
205
- # @param [Object] value Any valid value
206
- # @return [Hash] Returns the value in the form of hash
207
- def _to_hash(value)
208
- if value.is_a?(Array)
209
- value.compact.map { |v| _to_hash(v) }
210
- elsif value.is_a?(Hash)
211
- {}.tap do |hash|
212
- value.each { |k, v| hash[k] = _to_hash(v) }
213
- end
214
- elsif value.respond_to?(:to_hash)
215
- value.to_hash
216
- else
217
- value
218
- end
219
- end
220
-
221
- end
222
-
223
- end
224
- end