algolia 3.39.1 → 3.40.0

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +1 -1
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/ingestion_client.rb +71 -0
  6. data/lib/algolia/api/search_client.rb +342 -22
  7. data/lib/algolia/chunked_helper_options.rb +15 -0
  8. data/lib/algolia/configuration.rb +3 -1
  9. data/lib/algolia/models/abtesting/ab_test.rb +5 -0
  10. data/lib/algolia/models/query-suggestions/configuration.rb +1 -0
  11. data/lib/algolia/models/query-suggestions/configuration_response.rb +1 -0
  12. data/lib/algolia/models/query-suggestions/configuration_with_index.rb +1 -0
  13. data/lib/algolia/models/query-suggestions/source_index.rb +4 -0
  14. data/lib/algolia/models/recommend/fallback_params.rb +2 -1
  15. data/lib/algolia/models/recommend/recommend_search_params.rb +2 -1
  16. data/lib/algolia/models/search/browse_params_object.rb +2 -1
  17. data/lib/algolia/models/search/consequence_params.rb +2 -1
  18. data/lib/algolia/models/search/fetched_index.rb +25 -4
  19. data/lib/algolia/models/search/fetched_index_ab_test.rb +253 -0
  20. data/lib/algolia/models/search/fetched_index_ab_test_target.rb +210 -0
  21. data/lib/algolia/models/search/fetched_index_ab_test_variant.rb +242 -0
  22. data/lib/algolia/models/search/index_settings.rb +2 -1
  23. data/lib/algolia/models/search/search_for_facets.rb +2 -1
  24. data/lib/algolia/models/search/search_for_hits.rb +2 -1
  25. data/lib/algolia/models/search/search_params_object.rb +2 -1
  26. data/lib/algolia/models/search/search_response_partial.rb +587 -0
  27. data/lib/algolia/models/search/search_result.rb +2 -1
  28. data/lib/algolia/models/search/settings_response.rb +2 -1
  29. data/lib/algolia/version.rb +1 -1
  30. data/lib/algolia.rb +1 -2
  31. metadata +7 -2
@@ -12,7 +12,8 @@ module Algolia
12
12
  :write_timeout,
13
13
  :connect_timeout,
14
14
  :compression_type,
15
- :requester
15
+ :requester,
16
+ :transformation_options
16
17
  )
17
18
 
18
19
  # Set this to false to skip client side validation in the operation.
@@ -30,6 +31,7 @@ module Algolia
30
31
  @write_timeout = opts[:write_timeout]
31
32
  @compression_type = opts[:compression_type] || "none"
32
33
  @requester = opts[:requester]
34
+ @transformation_options = opts[:transformation_options]
33
35
 
34
36
  @user_agent = UserAgent.new.add(client_name, VERSION)
35
37
 
@@ -11,14 +11,19 @@ module Algolia
11
11
  # Unique A/B test identifier.
12
12
  attr_accessor :ab_test_id
13
13
 
14
+ # A/B test significance calculated from click events. Values of 0.95 or higher can be considered significant, that is, the difference between A and B variants is _not_ due to random variations. Lower values have a.
14
15
  attr_accessor :click_significance
15
16
 
17
+ # A/B test significance calculated from conversion events. Values of 0.95 or higher can be considered significant, that is, the difference between A and B variants is _not_ due to random variations.
16
18
  attr_accessor :conversion_significance
17
19
 
20
+ # A/B test significance calculated from add-to-cart events. Values of 0.95 or higher can be considered significant, that is, the difference between A and B variants is _not_ due to random variations.
18
21
  attr_accessor :add_to_cart_significance
19
22
 
23
+ # A/B test significance calculated from purchase events. Values of 0.95 or higher can be considered significant, that is, the difference between A and B variants is _not_ due to random variations.
20
24
  attr_accessor :purchase_significance
21
25
 
26
+ # A/B test significance calculated from revenue data. Values of 0.95 or higher can be considered significant, that is, the difference between A and B variants is _not_ due to random variations.
22
27
  attr_accessor :revenue_significance
23
28
 
24
29
  # Date and time when the A/B test was last updated, in RFC 3339 format.
@@ -14,6 +14,7 @@ module Algolia
14
14
 
15
15
  attr_accessor :languages
16
16
 
17
+ # Words or regular expressions to exclude from the suggestions.
17
18
  attr_accessor :exclude
18
19
 
19
20
  # Whether to turn on personalized query suggestions.
@@ -20,6 +20,7 @@ module Algolia
20
20
 
21
21
  attr_accessor :languages
22
22
 
23
+ # Words or regular expressions to exclude from the suggestions.
23
24
  attr_accessor :exclude
24
25
 
25
26
  # Whether to turn on personalized query suggestions.
@@ -14,6 +14,7 @@ module Algolia
14
14
 
15
15
  attr_accessor :languages
16
16
 
17
+ # Words or regular expressions to exclude from the suggestions.
17
18
  attr_accessor :exclude
18
19
 
19
20
  # Whether to turn on personalized query suggestions.
@@ -15,8 +15,10 @@ module Algolia
15
15
  # If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
16
16
  attr_accessor :replicas
17
17
 
18
+ # Analytics tags for filtering the popular searches. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments).
18
19
  attr_accessor :analytics_tags
19
20
 
21
+ # Facets to use as top categories with your suggestions. If provided, Query Suggestions adds the top facet values to each suggestion.
20
22
  attr_accessor :facets
21
23
 
22
24
  # Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
@@ -25,8 +27,10 @@ module Algolia
25
27
  # Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
26
28
  attr_accessor :min_letters
27
29
 
30
+ # Facets used for generating query suggestions from facet values. For example, if you set `generate: [\"color\", \"brand\"]`, combinations from the facet values are added as query suggestions, such as \"blue adidas\", \"red adidas\", \"blue nike\", \"red nike\", etc. You can include nested lists.
28
31
  attr_accessor :generate
29
32
 
33
+ # Algolia indices with popular searches to use as query suggestions. Records of these indices must have these attributes: - `query`: search query which will be added as a suggestion - `count`: measure of popularity of that search query For example, you can export popular searches from an external analytics provider, such as Google Analytics or Adobe Analytics, and feed this data into an Algolia index. You can use this index to generate query suggestions until your Algolia Analytics has collected enough data.
30
34
  attr_accessor :external
31
35
 
32
36
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -444,7 +444,8 @@ module Algolia
444
444
  [
445
445
  :inside_bounding_box,
446
446
  :user_data,
447
- :optional_words
447
+ :optional_words,
448
+ :re_ranking_apply_filter
448
449
  ]
449
450
  )
450
451
  end
@@ -445,7 +445,8 @@ module Algolia
445
445
  [
446
446
  :inside_bounding_box,
447
447
  :user_data,
448
- :optional_words
448
+ :optional_words,
449
+ :re_ranking_apply_filter
449
450
  ]
450
451
  )
451
452
  end
@@ -376,7 +376,8 @@ module Algolia
376
376
  Set.new(
377
377
  [
378
378
  :inside_bounding_box,
379
- :optional_words
379
+ :optional_words,
380
+ :re_ranking_apply_filter
380
381
  ]
381
382
  )
382
383
  end
@@ -378,7 +378,8 @@ module Algolia
378
378
  Set.new(
379
379
  [
380
380
  :inside_bounding_box,
381
- :optional_words
381
+ :optional_words,
382
+ :re_ranking_apply_filter
382
383
  ]
383
384
  )
384
385
  end
@@ -44,6 +44,11 @@ module Algolia
44
44
  # Only present if the index is a [virtual replica](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/sort-an-index-alphabetically/#virtual-replicas).
45
45
  attr_accessor :virtual
46
46
 
47
+ attr_accessor :ab_test
48
+
49
+ # Name of the index that owns the A/B test configuration. Only present when this index participates in an A/B test configured on another index.
50
+ attr_accessor :source_ab_test
51
+
47
52
  # Attribute mapping from ruby-style variable name to JSON key.
48
53
  def self.attribute_map
49
54
  {
@@ -58,7 +63,9 @@ module Algolia
58
63
  :pending_task => :pendingTask,
59
64
  :primary => :primary,
60
65
  :replicas => :replicas,
61
- :virtual => :virtual
66
+ :virtual => :virtual,
67
+ :ab_test => :abTest,
68
+ :source_ab_test => :sourceABTest
62
69
  }
63
70
  end
64
71
 
@@ -76,7 +83,9 @@ module Algolia
76
83
  :pending_task => :"Boolean",
77
84
  :primary => :"String",
78
85
  :replicas => :"Array<String>",
79
- :virtual => :"Boolean"
86
+ :virtual => :"Boolean",
87
+ :ab_test => :"FetchedIndexAbTest",
88
+ :source_ab_test => :"String"
80
89
  }
81
90
  end
82
91
 
@@ -177,6 +186,14 @@ module Algolia
177
186
  if attributes.key?(:virtual)
178
187
  self.virtual = attributes[:virtual]
179
188
  end
189
+
190
+ if attributes.key?(:ab_test)
191
+ self.ab_test = attributes[:ab_test]
192
+ end
193
+
194
+ if attributes.key?(:source_ab_test)
195
+ self.source_ab_test = attributes[:source_ab_test]
196
+ end
180
197
  end
181
198
 
182
199
  # Checks equality by comparing each attribute.
@@ -195,7 +212,9 @@ module Algolia
195
212
  pending_task == other.pending_task &&
196
213
  primary == other.primary &&
197
214
  replicas == other.replicas &&
198
- virtual == other.virtual
215
+ virtual == other.virtual &&
216
+ ab_test == other.ab_test &&
217
+ source_ab_test == other.source_ab_test
199
218
  end
200
219
 
201
220
  # @see the `==` method
@@ -219,7 +238,9 @@ module Algolia
219
238
  pending_task,
220
239
  primary,
221
240
  replicas,
222
- virtual
241
+ virtual,
242
+ ab_test,
243
+ source_ab_test
223
244
  ].hash
224
245
  end
225
246
 
@@ -0,0 +1,253 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 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.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Search
10
+ # A/B test metadata. Only present if the index is part of an active A/B test.
11
+ class FetchedIndexAbTest
12
+ # A/B test ID.
13
+ attr_accessor :id
14
+
15
+ # A/B test schema version. Only present for v2 and later tests.
16
+ attr_accessor :version
17
+
18
+ # A/B test type. Only present for v2 and later tests. Currently always `index-configuration`.
19
+ attr_accessor :type
20
+
21
+ attr_accessor :target
22
+
23
+ # A/B test variants.
24
+ attr_accessor :variants
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :id => :id,
30
+ :version => :version,
31
+ :type => :type,
32
+ :target => :target,
33
+ :variants => :variants
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.types_mapping
39
+ {
40
+ :id => :"Integer",
41
+ :version => :"Integer",
42
+ :type => :"String",
43
+ :target => :"FetchedIndexAbTestTarget",
44
+ :variants => :"Array<FetchedIndexAbTestVariant>"
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new(
51
+ []
52
+ )
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ raise(
60
+ ArgumentError,
61
+ "The input argument (attributes) must be a hash in `Algolia::FetchedIndexAbTest` initialize method"
62
+ )
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!self.class.attribute_map.key?(k.to_sym))
68
+ raise(
69
+ ArgumentError,
70
+ "`#{k}` is not a valid attribute in `Algolia::FetchedIndexAbTest`. Please check the name to make sure it's valid. List of attributes: " +
71
+ self.class.attribute_map.keys.inspect
72
+ )
73
+ end
74
+
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:id)
79
+ self.id = attributes[:id]
80
+ else
81
+ self.id = nil
82
+ end
83
+
84
+ if attributes.key?(:version)
85
+ self.version = attributes[:version]
86
+ end
87
+
88
+ if attributes.key?(:type)
89
+ self.type = attributes[:type]
90
+ end
91
+
92
+ if attributes.key?(:target)
93
+ self.target = attributes[:target]
94
+ end
95
+
96
+ if attributes.key?(:variants)
97
+ if (value = attributes[:variants]).is_a?(Array)
98
+ self.variants = value
99
+ end
100
+ else
101
+ self.variants = nil
102
+ end
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(other)
108
+ return true if self.equal?(other)
109
+ self.class == other.class &&
110
+ id == other.id &&
111
+ version == other.version &&
112
+ type == other.type &&
113
+ target == other.target &&
114
+ variants == other.variants
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(other)
120
+ self == other
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [id, version, type, target, variants].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ return nil unless attributes.is_a?(Hash)
134
+ attributes = attributes.transform_keys(&:to_sym)
135
+ transformed_hash = {}
136
+ types_mapping.each_pair do |key, type|
137
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
138
+ transformed_hash[key.to_sym] = nil
139
+ elsif type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[attribute_map[key]].is_a?(Array)
143
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
144
+ _deserialize(::Regexp.last_match(1), v)
145
+ }
146
+ end
147
+ elsif !attributes[attribute_map[key]].nil?
148
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
149
+ end
150
+ end
151
+
152
+ new(transformed_hash)
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def self._deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ # model
193
+ else
194
+ # models (e.g. Pet) or oneOf
195
+ klass = Algolia::Search.const_get(type)
196
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
197
+ .build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ def to_json(*_args)
214
+ to_hash.to_json
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = send(attr)
223
+ if value.nil?
224
+ is_nullable = self.class.openapi_nullable.include?(attr)
225
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
226
+ end
227
+
228
+ hash[param] = _to_hash(value)
229
+ end
230
+
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to?(:to_hash)
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
@@ -0,0 +1,210 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 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.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Search
10
+ # A/B test target criteria. Only present for v2 and later tests.
11
+ class FetchedIndexAbTestTarget
12
+ # Index name to match. Use `*` to target the entire application.
13
+ attr_accessor :index_name
14
+
15
+ # Attribute mapping from ruby-style variable name to JSON key.
16
+ def self.attribute_map
17
+ {
18
+ :index_name => :indexName
19
+ }
20
+ end
21
+
22
+ # Attribute type mapping.
23
+ def self.types_mapping
24
+ {
25
+ :index_name => :"String"
26
+ }
27
+ end
28
+
29
+ # List of attributes with nullable: true
30
+ def self.openapi_nullable
31
+ Set.new(
32
+ []
33
+ )
34
+ end
35
+
36
+ # Initializes the object
37
+ # @param [Hash] attributes Model attributes in the form of hash
38
+ def initialize(attributes = {})
39
+ if (!attributes.is_a?(Hash))
40
+ raise(
41
+ ArgumentError,
42
+ "The input argument (attributes) must be a hash in `Algolia::FetchedIndexAbTestTarget` initialize method"
43
+ )
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ raise(
50
+ ArgumentError,
51
+ "`#{k}` is not a valid attribute in `Algolia::FetchedIndexAbTestTarget`. Please check the name to make sure it's valid. List of attributes: " +
52
+ self.class.attribute_map.keys.inspect
53
+ )
54
+ end
55
+
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:index_name)
60
+ self.index_name = attributes[:index_name]
61
+ else
62
+ self.index_name = nil
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
+ index_name == other.index_name
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
+ [index_name].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
+ end
209
+ end
210
+ end