algolia 3.0.0.alpha.16 → 3.0.0.alpha.17

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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/FILES +10 -167
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/analytics_client.rb +76 -76
  6. data/lib/algolia/api/recommend_client.rb +22 -22
  7. data/lib/algolia/api/search_client.rb +8 -8
  8. data/lib/algolia/api/usage_client.rb +329 -0
  9. data/lib/algolia/models/analytics/get_status_response.rb +1 -1
  10. data/lib/algolia/models/ingestion/auth_algolia_insights.rb +212 -0
  11. data/lib/algolia/models/{recommend/consequence_query_object.rb → ingestion/auth_algolia_insights_partial.rb} +21 -24
  12. data/lib/algolia/models/ingestion/auth_input.rb +1 -0
  13. data/lib/algolia/models/ingestion/auth_input_partial.rb +1 -0
  14. data/lib/algolia/models/ingestion/authentication_type.rb +2 -1
  15. data/lib/algolia/models/insights/added_to_cart_object_ids.rb +1 -1
  16. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
  17. data/lib/algolia/models/insights/clicked_filters.rb +1 -1
  18. data/lib/algolia/models/insights/clicked_object_ids.rb +1 -1
  19. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
  20. data/lib/algolia/models/insights/converted_filters.rb +1 -1
  21. data/lib/algolia/models/insights/converted_object_ids.rb +1 -1
  22. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
  23. data/lib/algolia/models/insights/purchased_object_ids.rb +1 -1
  24. data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +1 -1
  25. data/lib/algolia/models/insights/viewed_filters.rb +1 -1
  26. data/lib/algolia/models/insights/viewed_object_ids.rb +1 -1
  27. data/lib/algolia/models/monitoring/incidents_inner.rb +1 -1
  28. data/lib/algolia/models/monitoring/probes_metric.rb +1 -1
  29. data/lib/algolia/models/monitoring/time_inner.rb +1 -1
  30. data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +2 -2
  31. data/lib/algolia/models/query-suggestions/get_log_file200_response.rb +1 -1
  32. data/lib/algolia/models/recommend/auto_facet_filter.rb +208 -0
  33. data/lib/algolia/models/recommend/base_recommend_request.rb +36 -7
  34. data/lib/algolia/models/recommend/base_search_params.rb +1 -1
  35. data/lib/algolia/models/recommend/base_search_params_without_query.rb +1 -1
  36. data/lib/algolia/models/recommend/bought_together_query.rb +319 -0
  37. data/lib/algolia/models/recommend/condition.rb +12 -62
  38. data/lib/algolia/models/recommend/consequence.rb +32 -54
  39. data/lib/algolia/models/recommend/deleted_at_response.rb +1 -1
  40. data/lib/algolia/models/recommend/{recommended_for_you_query_parameters.rb → fallback_params.rb} +9 -12
  41. data/lib/algolia/models/recommend/{edit_type.rb → fbt_model.rb} +5 -6
  42. data/lib/algolia/models/recommend/{base_trending_facets_query.rb → frequently_bought_together.rb} +20 -18
  43. data/lib/algolia/models/recommend/get_recommendations_params.rb +2 -2
  44. data/lib/algolia/models/recommend/{consequence_hide.rb → hide_consequence_object.rb} +4 -6
  45. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +5 -5
  46. data/lib/algolia/models/recommend/{base_recommendations_query.rb → looking_similar.rb} +6 -15
  47. data/lib/algolia/models/recommend/{anchoring.rb → looking_similar_model.rb} +5 -8
  48. data/lib/algolia/models/recommend/looking_similar_query.rb +328 -0
  49. data/lib/algolia/models/recommend/{params.rb → params_consequence.rb} +26 -28
  50. data/lib/algolia/models/recommend/{promote_object_id.rb → promote_consequence_object.rb} +19 -9
  51. data/lib/algolia/models/recommend/{rule_response.rb → recommend_rule.rb} +13 -18
  52. data/lib/algolia/models/recommend/{rule_response_metadata.rb → recommend_rule_metadata.rb} +5 -4
  53. data/lib/algolia/models/recommend/recommendations_hits.rb +4 -24
  54. data/lib/algolia/models/recommend/recommendations_request.rb +3 -1
  55. data/lib/algolia/models/recommend/recommendations_results.rb +4 -24
  56. data/lib/algolia/models/recommend/{base_recommended_for_you_query.rb → recommended_for_you.rb} +5 -14
  57. data/lib/algolia/models/recommend/recommended_for_you_query.rb +35 -15
  58. data/lib/algolia/models/recommend/{recommendation_models.rb → related_model.rb} +4 -5
  59. data/lib/algolia/models/recommend/{edit.rb → related_products.rb} +27 -24
  60. data/lib/algolia/models/recommend/{recommendations_query.rb → related_query.rb} +39 -19
  61. data/lib/algolia/models/recommend/{consequence_params.rb → search_params.rb} +25 -44
  62. data/lib/algolia/models/recommend/search_params_object.rb +6 -6
  63. data/lib/algolia/models/recommend/search_recommend_rules_params.rb +58 -10
  64. data/lib/algolia/models/recommend/search_recommend_rules_response.rb +2 -2
  65. data/lib/algolia/models/recommend/trending_facet_hit.rb +2 -2
  66. data/lib/algolia/models/recommend/trending_facets.rb +243 -0
  67. data/lib/algolia/models/recommend/trending_facets_query.rb +50 -10
  68. data/lib/algolia/models/recommend/{base_trending_items_query.rb → trending_items.rb} +12 -15
  69. data/lib/algolia/models/recommend/trending_items_query.rb +42 -16
  70. data/lib/algolia/models/search/add_api_key_response.rb +1 -1
  71. data/lib/algolia/models/search/base_get_api_key_response.rb +1 -1
  72. data/lib/algolia/models/search/base_index_settings.rb +4 -4
  73. data/lib/algolia/models/search/base_search_params.rb +1 -1
  74. data/lib/algolia/models/search/base_search_params_without_query.rb +1 -1
  75. data/lib/algolia/models/search/browse_params_object.rb +6 -6
  76. data/lib/algolia/models/search/consequence_params.rb +6 -6
  77. data/lib/algolia/models/search/created_at_response.rb +1 -1
  78. data/lib/algolia/models/search/delete_api_key_response.rb +1 -1
  79. data/lib/algolia/models/search/delete_by_params.rb +1 -1
  80. data/lib/algolia/models/search/delete_source_response.rb +1 -1
  81. data/lib/algolia/models/search/deleted_at_response.rb +1 -1
  82. data/lib/algolia/models/search/fetched_index.rb +1 -1
  83. data/lib/algolia/models/search/get_api_key_response.rb +1 -1
  84. data/lib/algolia/models/search/index_settings.rb +9 -9
  85. data/lib/algolia/models/search/index_settings_as_search_params.rb +5 -5
  86. data/lib/algolia/models/search/log.rb +1 -1
  87. data/lib/algolia/models/search/remove_user_id_response.rb +1 -1
  88. data/lib/algolia/models/search/replace_source_response.rb +1 -1
  89. data/lib/algolia/models/search/save_object_response.rb +1 -1
  90. data/lib/algolia/models/search/save_synonym_response.rb +1 -1
  91. data/lib/algolia/models/search/search_for_facets.rb +6 -6
  92. data/lib/algolia/models/search/search_for_hits.rb +6 -6
  93. data/lib/algolia/models/search/search_params_object.rb +6 -6
  94. data/lib/algolia/models/search/search_user_ids_response.rb +1 -1
  95. data/lib/algolia/models/search/secured_api_key_restrictions.rb +1 -1
  96. data/lib/algolia/models/search/update_api_key_response.rb +1 -1
  97. data/lib/algolia/models/search/updated_at_response.rb +1 -1
  98. data/lib/algolia/models/search/updated_at_with_object_id_response.rb +1 -1
  99. data/lib/algolia/models/search/updated_rule_response.rb +1 -1
  100. data/lib/algolia/models/search/user_hit.rb +1 -1
  101. data/lib/algolia/models/search/user_id.rb +1 -1
  102. data/lib/algolia/models/usage/error_base.rb +205 -0
  103. data/lib/algolia/models/usage/get_usage200_response.rb +198 -0
  104. data/lib/algolia/models/usage/get_usage200_response_statistics_inner.rb +206 -0
  105. data/lib/algolia/models/{recommend/base_recommended_for_you_query_parameters.rb → usage/get_usage400_response.rb} +13 -14
  106. data/lib/algolia/models/usage/get_usage400_response_error.rb +216 -0
  107. data/lib/algolia/models/usage/get_usage400_response_error_errors_inner.rb +225 -0
  108. data/lib/algolia/models/usage/granularity.rb +33 -0
  109. data/lib/algolia/models/usage/statistic.rb +116 -0
  110. data/lib/algolia/models/{recommend/promote.rb → usage/statistic_value.rb} +5 -5
  111. data/lib/algolia/version.rb +1 -1
  112. metadata +34 -25
  113. data/lib/algolia/models/recommend/automatic_facet_filter.rb +0 -220
  114. data/lib/algolia/models/recommend/automatic_facet_filters.rb +0 -97
  115. data/lib/algolia/models/recommend/consequence_query.rb +0 -97
  116. data/lib/algolia/models/recommend/promote_object_ids.rb +0 -228
@@ -1,220 +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
- # Filter or optional filter to be applied to the search.
9
- class AutomaticFacetFilter
10
- # Facet name to be applied as filter. The name must match placeholders in the `pattern` parameter. For example, with `pattern: {facet:genre}`, `automaticFacetFilters` must be `genre`.
11
- attr_accessor :facet
12
-
13
- # Filter scores to give different weights to individual filters.
14
- attr_accessor :score
15
-
16
- # Whether the filter is disjunctive or conjunctive. If true the filter has multiple matches, multiple occurences are combined with the logical `OR` operation. If false, multiple occurences are combined with the logical `AND` operation.
17
- attr_accessor :disjunctive
18
-
19
- # Attribute mapping from ruby-style variable name to JSON key.
20
- def self.attribute_map
21
- {
22
- :facet => :facet,
23
- :score => :score,
24
- :disjunctive => :disjunctive
25
- }
26
- end
27
-
28
- # Returns all the JSON keys this model knows about
29
- def self.acceptable_attributes
30
- attribute_map.values
31
- end
32
-
33
- # Attribute type mapping.
34
- def self.types_mapping
35
- {
36
- :facet => :String,
37
- :score => :Integer,
38
- :disjunctive => :Boolean
39
- }
40
- end
41
-
42
- # List of attributes with nullable: true
43
- def self.openapi_nullable
44
- Set.new([])
45
- end
46
-
47
- # Initializes the object
48
- # @param [Hash] attributes Model attributes in the form of hash
49
- def initialize(attributes = {})
50
- unless attributes.is_a?(Hash)
51
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::AutomaticFacetFilter` initialize method"
52
- end
53
-
54
- # check to see if the attribute exists and convert string to symbol for hash key
55
- attributes = attributes.each_with_object({}) do |(k, v), h|
56
- unless self.class.attribute_map.key?(k.to_sym)
57
- raise ArgumentError,
58
- "`#{k}` is not a valid attribute in `Algolia::AutomaticFacetFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
- end
60
-
61
- h[k.to_sym] = v
62
- end
63
-
64
- if attributes.key?(:facet)
65
- self.facet = attributes[:facet]
66
- else
67
- self.facet = nil
68
- end
69
-
70
- if attributes.key?(:score)
71
- self.score = attributes[:score]
72
- end
73
-
74
- if attributes.key?(:disjunctive)
75
- self.disjunctive = attributes[:disjunctive]
76
- end
77
- end
78
-
79
- # Checks equality by comparing each attribute.
80
- # @param [Object] Object to be compared
81
- def ==(other)
82
- return true if equal?(other)
83
-
84
- self.class == other.class &&
85
- facet == other.facet &&
86
- score == other.score &&
87
- disjunctive == other.disjunctive
88
- end
89
-
90
- # @see the `==` method
91
- # @param [Object] Object to be compared
92
- def eql?(other)
93
- self == other
94
- end
95
-
96
- # Calculates hash code according to all attributes.
97
- # @return [Integer] Hash code
98
- def hash
99
- [facet, score, disjunctive].hash
100
- end
101
-
102
- # Builds the object from hash
103
- # @param [Hash] attributes Model attributes in the form of hash
104
- # @return [Object] Returns the model itself
105
- def self.build_from_hash(attributes)
106
- return nil unless attributes.is_a?(Hash)
107
-
108
- attributes = attributes.transform_keys(&:to_sym)
109
- transformed_hash = {}
110
- types_mapping.each_pair do |key, type|
111
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
112
- transformed_hash[key.to_sym] = nil
113
- elsif type =~ /\AArray<(.*)>/i
114
- # check to ensure the input is an array given that the attribute
115
- # is documented as an array but the input is not
116
- if attributes[attribute_map[key]].is_a?(Array)
117
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
118
- end
119
- elsif !attributes[attribute_map[key]].nil?
120
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
121
- end
122
- end
123
- new(transformed_hash)
124
- end
125
-
126
- # Deserializes the data based on type
127
- # @param string type Data type
128
- # @param string value Value to be deserialized
129
- # @return [Object] Deserialized data
130
- def self._deserialize(type, value)
131
- case type.to_sym
132
- when :Time
133
- Time.parse(value)
134
- when :Date
135
- Date.parse(value)
136
- when :String
137
- value.to_s
138
- when :Integer
139
- value.to_i
140
- when :Float
141
- value.to_f
142
- when :Boolean
143
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
- true
145
- else
146
- false
147
- end
148
- when :Object
149
- # generic object (usually a Hash), return directly
150
- value
151
- when /\AArray<(?<inner_type>.+)>\z/
152
- inner_type = Regexp.last_match[:inner_type]
153
- value.map { |v| _deserialize(inner_type, v) }
154
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
- k_type = Regexp.last_match[:k_type]
156
- v_type = Regexp.last_match[:v_type]
157
- {}.tap do |hash|
158
- value.each do |k, v|
159
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
- end
161
- end
162
- else # model
163
- # models (e.g. Pet) or oneOf
164
- klass = Algolia::Recommend.const_get(type)
165
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
166
- end
167
- end
168
-
169
- # Returns the string representation of the object
170
- # @return [String] String presentation of the object
171
- def to_s
172
- to_hash.to_s
173
- end
174
-
175
- # to_body is an alias to to_hash (backward compatibility)
176
- # @return [Hash] Returns the object in the form of hash
177
- def to_body
178
- to_hash
179
- end
180
-
181
- def to_json(*_args)
182
- to_hash.to_json
183
- end
184
-
185
- # Returns the object in the form of hash
186
- # @return [Hash] Returns the object in the form of hash
187
- def to_hash
188
- hash = {}
189
- self.class.attribute_map.each_pair do |attr, param|
190
- value = send(attr)
191
- if value.nil?
192
- is_nullable = self.class.openapi_nullable.include?(attr)
193
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
- end
195
-
196
- hash[param] = _to_hash(value)
197
- end
198
- hash
199
- end
200
-
201
- # Outputs non-array value in the form of hash
202
- # For object, use to_hash. Otherwise, just return the value
203
- # @param [Object] value Any valid value
204
- # @return [Hash] Returns the value in the form of hash
205
- def _to_hash(value)
206
- if value.is_a?(Array)
207
- value.compact.map { |v| _to_hash(v) }
208
- elsif value.is_a?(Hash)
209
- {}.tap do |hash|
210
- value.each { |k, v| hash[k] = _to_hash(v) }
211
- end
212
- elsif value.respond_to? :to_hash
213
- value.to_hash
214
- else
215
- value
216
- end
217
- end
218
- end
219
- end
220
- end
@@ -1,97 +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
- # Filter to be applied to the search. You can use this to respond to search queries that match a facet value. For example, if users search for \"comedy\", which matches a facet value of the \"genre\" facet, you can filter the results to show the top-ranked comedy movies.
9
- module AutomaticFacetFilters
10
- class << self
11
- # List of class defined in oneOf (OpenAPI v3)
12
- def openapi_one_of
13
- [
14
- :'Array<AutomaticFacetFilter>',
15
- :'Array<String>'
16
- ]
17
- end
18
-
19
- # Builds the object
20
- # @param [Mixed] Data to be matched against the list of oneOf items
21
- # @return [Object] Returns the model or the data itself
22
- def build(data)
23
- # Go through the list of oneOf items and attempt to identify the appropriate one.
24
- # Note:
25
- # - We do not attempt to check whether exactly one item matches.
26
- # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
27
- # due to the way the deserialization is made in the base_object template (it just casts without verifying).
28
- # - TODO: scalar values are de facto behaving as if they were nullable.
29
- # - TODO: logging when debugging is set.
30
- openapi_one_of.each do |klass|
31
- next if klass == :AnyType # "nullable: true"
32
-
33
- typed_data = find_and_cast_into_type(klass, data)
34
- return typed_data if typed_data
35
- rescue # rescue all errors so we keep iterating even if the current item lookup raises
36
- end
37
-
38
- openapi_one_of.include?(:AnyType) ? data : nil
39
- end
40
-
41
- private
42
-
43
- SchemaMismatchError = Class.new(StandardError)
44
-
45
- # NOTE: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
46
- def find_and_cast_into_type(klass, data)
47
- return if data.nil?
48
-
49
- case klass.to_s
50
- when 'Boolean'
51
- return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
52
- when 'Float'
53
- return data if data.instance_of?(Float)
54
- when 'Integer'
55
- return data if data.instance_of?(Integer)
56
- when 'Time'
57
- return Time.parse(data)
58
- when 'Date'
59
- return Date.parse(data)
60
- when 'String'
61
- return data if data.instance_of?(String)
62
- when 'Object' # "type: object"
63
- return data if data.instance_of?(Hash)
64
- when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
65
- if data.instance_of?(Array)
66
- sub_type = Regexp.last_match[:sub_type]
67
- return data.map { |item| find_and_cast_into_type(sub_type, item) }
68
- end
69
- when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
70
- if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
71
- sub_type = Regexp.last_match[:sub_type]
72
- return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
73
- end
74
- else # model
75
- const = Algolia::Recommend.const_get(klass)
76
- if const
77
- if const.respond_to?(:openapi_one_of) # nested oneOf model
78
- model = const.build(data)
79
- else
80
- # raise if data contains keys that are not known to the model
81
- raise unless (data.keys - const.acceptable_attributes).empty?
82
-
83
- model = const.build_from_hash(data)
84
- end
85
-
86
- return model if model
87
- end
88
- end
89
-
90
- raise # if no match by now, raise
91
- rescue
92
- raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,97 +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
- # Replace or edit the search query. If `consequenceQuery` is a string, the entire search query is replaced with that string. If `consequenceQuery` is an object, it describes incremental edits made to the query.
9
- module ConsequenceQuery
10
- class << self
11
- # List of class defined in oneOf (OpenAPI v3)
12
- def openapi_one_of
13
- [
14
- :ConsequenceQueryObject,
15
- :String
16
- ]
17
- end
18
-
19
- # Builds the object
20
- # @param [Mixed] Data to be matched against the list of oneOf items
21
- # @return [Object] Returns the model or the data itself
22
- def build(data)
23
- # Go through the list of oneOf items and attempt to identify the appropriate one.
24
- # Note:
25
- # - We do not attempt to check whether exactly one item matches.
26
- # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
27
- # due to the way the deserialization is made in the base_object template (it just casts without verifying).
28
- # - TODO: scalar values are de facto behaving as if they were nullable.
29
- # - TODO: logging when debugging is set.
30
- openapi_one_of.each do |klass|
31
- next if klass == :AnyType # "nullable: true"
32
-
33
- typed_data = find_and_cast_into_type(klass, data)
34
- return typed_data if typed_data
35
- rescue # rescue all errors so we keep iterating even if the current item lookup raises
36
- end
37
-
38
- openapi_one_of.include?(:AnyType) ? data : nil
39
- end
40
-
41
- private
42
-
43
- SchemaMismatchError = Class.new(StandardError)
44
-
45
- # NOTE: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
46
- def find_and_cast_into_type(klass, data)
47
- return if data.nil?
48
-
49
- case klass.to_s
50
- when 'Boolean'
51
- return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
52
- when 'Float'
53
- return data if data.instance_of?(Float)
54
- when 'Integer'
55
- return data if data.instance_of?(Integer)
56
- when 'Time'
57
- return Time.parse(data)
58
- when 'Date'
59
- return Date.parse(data)
60
- when 'String'
61
- return data if data.instance_of?(String)
62
- when 'Object' # "type: object"
63
- return data if data.instance_of?(Hash)
64
- when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
65
- if data.instance_of?(Array)
66
- sub_type = Regexp.last_match[:sub_type]
67
- return data.map { |item| find_and_cast_into_type(sub_type, item) }
68
- end
69
- when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
70
- if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
71
- sub_type = Regexp.last_match[:sub_type]
72
- return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
73
- end
74
- else # model
75
- const = Algolia::Recommend.const_get(klass)
76
- if const
77
- if const.respond_to?(:openapi_one_of) # nested oneOf model
78
- model = const.build(data)
79
- else
80
- # raise if data contains keys that are not known to the model
81
- raise unless (data.keys - const.acceptable_attributes).empty?
82
-
83
- model = const.build_from_hash(data)
84
- end
85
-
86
- return model if model
87
- end
88
- end
89
-
90
- raise # if no match by now, raise
91
- rescue
92
- raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,228 +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
- # Records to promote.
9
- class PromoteObjectIDs
10
- # Object IDs of the records you want to promote. The records are placed as a group at the `position`. For example, if you want to promote four records to position `0`, they will be the first four search results.
11
- attr_accessor :object_ids
12
-
13
- # Position in the search results where you want to show the promoted records.
14
- attr_accessor :position
15
-
16
- # Attribute mapping from ruby-style variable name to JSON key.
17
- def self.attribute_map
18
- {
19
- :object_ids => :objectIDs,
20
- :position => :position
21
- }
22
- end
23
-
24
- # Returns all the JSON keys this model knows about
25
- def self.acceptable_attributes
26
- attribute_map.values
27
- end
28
-
29
- # Attribute type mapping.
30
- def self.types_mapping
31
- {
32
- :object_ids => :'Array<String>',
33
- :position => :Integer
34
- }
35
- end
36
-
37
- # List of attributes with nullable: true
38
- def self.openapi_nullable
39
- Set.new([])
40
- end
41
-
42
- # Initializes the object
43
- # @param [Hash] attributes Model attributes in the form of hash
44
- def initialize(attributes = {})
45
- unless attributes.is_a?(Hash)
46
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::PromoteObjectIDs` initialize method"
47
- end
48
-
49
- # check to see if the attribute exists and convert string to symbol for hash key
50
- attributes = attributes.each_with_object({}) do |(k, v), h|
51
- unless self.class.attribute_map.key?(k.to_sym)
52
- raise ArgumentError,
53
- "`#{k}` is not a valid attribute in `Algolia::PromoteObjectIDs`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
- end
55
-
56
- h[k.to_sym] = v
57
- end
58
-
59
- if attributes.key?(:object_ids)
60
- if (value = attributes[:object_ids]).is_a?(Array)
61
- self.object_ids = value
62
- end
63
- else
64
- self.object_ids = nil
65
- end
66
-
67
- if attributes.key?(:position)
68
- self.position = attributes[:position]
69
- else
70
- self.position = nil
71
- end
72
- end
73
-
74
- # Custom attribute writer method with validation
75
- # @param [Object] object_ids Value to be assigned
76
- def object_ids=(object_ids)
77
- if object_ids.nil?
78
- raise ArgumentError, 'object_ids cannot be nil'
79
- end
80
-
81
- if object_ids.length > 100
82
- raise ArgumentError, 'invalid value for "object_ids", number of items must be less than or equal to 100.'
83
- end
84
-
85
- @object_ids = object_ids
86
- end
87
-
88
- # Checks equality by comparing each attribute.
89
- # @param [Object] Object to be compared
90
- def ==(other)
91
- return true if equal?(other)
92
-
93
- self.class == other.class &&
94
- object_ids == other.object_ids &&
95
- position == other.position
96
- end
97
-
98
- # @see the `==` method
99
- # @param [Object] Object to be compared
100
- def eql?(other)
101
- self == other
102
- end
103
-
104
- # Calculates hash code according to all attributes.
105
- # @return [Integer] Hash code
106
- def hash
107
- [object_ids, position].hash
108
- end
109
-
110
- # Builds the object from hash
111
- # @param [Hash] attributes Model attributes in the form of hash
112
- # @return [Object] Returns the model itself
113
- def self.build_from_hash(attributes)
114
- return nil unless attributes.is_a?(Hash)
115
-
116
- attributes = attributes.transform_keys(&:to_sym)
117
- transformed_hash = {}
118
- types_mapping.each_pair do |key, type|
119
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
120
- transformed_hash[key.to_sym] = nil
121
- elsif type =~ /\AArray<(.*)>/i
122
- # check to ensure the input is an array given that the attribute
123
- # is documented as an array but the input is not
124
- if attributes[attribute_map[key]].is_a?(Array)
125
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
126
- end
127
- elsif !attributes[attribute_map[key]].nil?
128
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
129
- end
130
- end
131
- new(transformed_hash)
132
- end
133
-
134
- # Deserializes the data based on type
135
- # @param string type Data type
136
- # @param string value Value to be deserialized
137
- # @return [Object] Deserialized data
138
- def self._deserialize(type, value)
139
- case type.to_sym
140
- when :Time
141
- Time.parse(value)
142
- when :Date
143
- Date.parse(value)
144
- when :String
145
- value.to_s
146
- when :Integer
147
- value.to_i
148
- when :Float
149
- value.to_f
150
- when :Boolean
151
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
- true
153
- else
154
- false
155
- end
156
- when :Object
157
- # generic object (usually a Hash), return directly
158
- value
159
- when /\AArray<(?<inner_type>.+)>\z/
160
- inner_type = Regexp.last_match[:inner_type]
161
- value.map { |v| _deserialize(inner_type, v) }
162
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
- k_type = Regexp.last_match[:k_type]
164
- v_type = Regexp.last_match[:v_type]
165
- {}.tap do |hash|
166
- value.each do |k, v|
167
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
- end
169
- end
170
- else # model
171
- # models (e.g. Pet) or oneOf
172
- klass = Algolia::Recommend.const_get(type)
173
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
- end
175
- end
176
-
177
- # Returns the string representation of the object
178
- # @return [String] String presentation of the object
179
- def to_s
180
- to_hash.to_s
181
- end
182
-
183
- # to_body is an alias to to_hash (backward compatibility)
184
- # @return [Hash] Returns the object in the form of hash
185
- def to_body
186
- to_hash
187
- end
188
-
189
- def to_json(*_args)
190
- to_hash.to_json
191
- end
192
-
193
- # Returns the object in the form of hash
194
- # @return [Hash] Returns the object in the form of hash
195
- def to_hash
196
- hash = {}
197
- self.class.attribute_map.each_pair do |attr, param|
198
- value = send(attr)
199
- if value.nil?
200
- is_nullable = self.class.openapi_nullable.include?(attr)
201
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
- end
203
-
204
- hash[param] = _to_hash(value)
205
- end
206
- hash
207
- end
208
-
209
- # Outputs non-array value in the form of hash
210
- # For object, use to_hash. Otherwise, just return the value
211
- # @param [Object] value Any valid value
212
- # @return [Hash] Returns the value in the form of hash
213
- def _to_hash(value)
214
- if value.is_a?(Array)
215
- value.compact.map { |v| _to_hash(v) }
216
- elsif value.is_a?(Hash)
217
- {}.tap do |hash|
218
- value.each { |k, v| hash[k] = _to_hash(v) }
219
- end
220
- elsif value.respond_to? :to_hash
221
- value.to_hash
222
- else
223
- value
224
- end
225
- end
226
- end
227
- end
228
- end