algolia 3.0.0.beta.4 → 3.0.0.beta.5

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/VERSION +1 -1
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/ingestion_client.rb +424 -58
  6. data/lib/algolia/api/search_client.rb +100 -3
  7. data/lib/algolia/models/ingestion/authentication.rb +2 -2
  8. data/lib/algolia/models/ingestion/authentication_create_response.rb +1 -1
  9. data/lib/algolia/models/ingestion/authentication_update_response.rb +1 -1
  10. data/lib/algolia/models/ingestion/delete_response.rb +1 -1
  11. data/lib/algolia/models/ingestion/destination.rb +2 -2
  12. data/lib/algolia/models/ingestion/destination_create_response.rb +1 -1
  13. data/lib/algolia/models/ingestion/destination_update_response.rb +1 -1
  14. data/lib/algolia/models/ingestion/event.rb +1 -1
  15. data/lib/algolia/models/ingestion/list_transformations_response.rb +212 -0
  16. data/lib/algolia/models/ingestion/on_demand_date_utils_input.rb +2 -2
  17. data/lib/algolia/models/ingestion/on_demand_trigger.rb +1 -1
  18. data/lib/algolia/models/ingestion/run.rb +3 -3
  19. data/lib/algolia/models/ingestion/run_response.rb +1 -1
  20. data/lib/algolia/models/ingestion/schedule_trigger.rb +2 -2
  21. data/lib/algolia/models/ingestion/sort_keys.rb +35 -0
  22. data/lib/algolia/models/ingestion/source.rb +2 -2
  23. data/lib/algolia/models/ingestion/source_create_response.rb +1 -1
  24. data/lib/algolia/models/ingestion/source_update_response.rb +1 -1
  25. data/lib/algolia/models/ingestion/source_watch_response.rb +233 -0
  26. data/lib/algolia/models/ingestion/task.rb +13 -3
  27. data/lib/algolia/models/ingestion/task_create.rb +14 -4
  28. data/lib/algolia/models/ingestion/task_create_response.rb +1 -1
  29. data/lib/algolia/models/ingestion/task_update_response.rb +1 -1
  30. data/lib/algolia/models/ingestion/transformation.rb +257 -0
  31. data/lib/algolia/models/ingestion/transformation_create.rb +224 -0
  32. data/lib/algolia/models/ingestion/{docker_source_discover.rb → transformation_create_response.rb} +14 -13
  33. data/lib/algolia/models/ingestion/{docker_source_streams.rb → transformation_search.rb} +12 -12
  34. data/lib/algolia/models/ingestion/transformation_try.rb +211 -0
  35. data/lib/algolia/models/ingestion/transformation_try_response.rb +210 -0
  36. data/lib/algolia/models/ingestion/transformation_try_response_error.rb +208 -0
  37. data/lib/algolia/models/ingestion/transformation_update_response.rb +212 -0
  38. data/lib/algolia/models/ingestion/window.rb +2 -2
  39. data/lib/algolia/models/recommend/base_search_response.rb +2 -4
  40. data/lib/algolia/models/recommend/fallback_params.rb +3 -1
  41. data/lib/algolia/models/recommend/recommendations_results.rb +1 -1
  42. data/lib/algolia/models/recommend/search_params.rb +3 -1
  43. data/lib/algolia/models/recommend/search_params_object.rb +3 -1
  44. data/lib/algolia/models/recommend/trending_facets_query.rb +3 -1
  45. data/lib/algolia/models/search/base_index_settings.rb +2 -4
  46. data/lib/algolia/models/search/base_search_response.rb +2 -4
  47. data/lib/algolia/models/search/browse_params_object.rb +3 -1
  48. data/lib/algolia/models/search/browse_response.rb +1 -1
  49. data/lib/algolia/models/search/consequence_params.rb +3 -1
  50. data/lib/algolia/models/search/index_settings.rb +4 -2
  51. data/lib/algolia/models/search/search_for_facets.rb +3 -1
  52. data/lib/algolia/models/search/search_for_hits.rb +3 -1
  53. data/lib/algolia/models/search/search_params_object.rb +3 -1
  54. data/lib/algolia/models/search/search_response.rb +1 -1
  55. data/lib/algolia/models/search/secured_api_key_restrictions.rb +3 -3
  56. data/lib/algolia/version.rb +1 -1
  57. metadata +13 -4
@@ -0,0 +1,224 @@
1
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
+
3
+ require 'date'
4
+ require 'time'
5
+
6
+ module Algolia
7
+ module Ingestion
8
+ # API request body for creating a transformation.
9
+ class TransformationCreate
10
+ # The source code of the transformation.
11
+ attr_accessor :code
12
+
13
+ # The uniquely identified name of your transformation.
14
+ attr_accessor :name
15
+
16
+ # A descriptive name for your transformation of what it does.
17
+ attr_accessor :description
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :code => :code,
23
+ :name => :name,
24
+ :description => :description
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
+ :code => :String,
37
+ :name => :String,
38
+ :description => :String
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::TransformationCreate` 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::TransformationCreate`. 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?(:code)
65
+ self.code = attributes[:code]
66
+ else
67
+ self.code = nil
68
+ end
69
+
70
+ if attributes.key?(:name)
71
+ self.name = attributes[:name]
72
+ else
73
+ self.name = nil
74
+ end
75
+
76
+ if attributes.key?(:description)
77
+ self.description = attributes[:description]
78
+ else
79
+ self.description = nil
80
+ end
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(other)
86
+ return true if equal?(other)
87
+
88
+ self.class == other.class &&
89
+ code == other.code &&
90
+ name == other.name &&
91
+ description == other.description
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(other)
97
+ self == other
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Integer] Hash code
102
+ def hash
103
+ [code, name, description].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def self.build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ types_mapping.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash[key.to_sym] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def self._deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ # models (e.g. Pet) or oneOf
168
+ klass = Algolia::Ingestion.const_get(type)
169
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ def to_json(*_args)
186
+ to_hash.to_json
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
@@ -5,17 +5,18 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Ingestion
8
- class DockerSourceDiscover
9
- # Universally unique identifier (UUID) of a task run.
10
- attr_accessor :run_id
8
+ # API response for creating a transformation.
9
+ class TransformationCreateResponse
10
+ # Universally unique identifier (UUID) of a transformation.
11
+ attr_accessor :transformation_id
11
12
 
12
- # Date of creation in RFC3339 format.
13
+ # Date of creation in RFC 3339 format.
13
14
  attr_accessor :created_at
14
15
 
15
16
  # Attribute mapping from ruby-style variable name to JSON key.
16
17
  def self.attribute_map
17
18
  {
18
- :run_id => :runID,
19
+ :transformation_id => :transformationID,
19
20
  :created_at => :createdAt
20
21
  }
21
22
  end
@@ -28,7 +29,7 @@ module Algolia
28
29
  # Attribute type mapping.
29
30
  def self.types_mapping
30
31
  {
31
- :run_id => :String,
32
+ :transformation_id => :String,
32
33
  :created_at => :String
33
34
  }
34
35
  end
@@ -42,23 +43,23 @@ module Algolia
42
43
  # @param [Hash] attributes Model attributes in the form of hash
43
44
  def initialize(attributes = {})
44
45
  unless attributes.is_a?(Hash)
45
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DockerSourceDiscover` initialize method"
46
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TransformationCreateResponse` initialize method"
46
47
  end
47
48
 
48
49
  # check to see if the attribute exists and convert string to symbol for hash key
49
50
  attributes = attributes.each_with_object({}) do |(k, v), h|
50
51
  unless self.class.attribute_map.key?(k.to_sym)
51
52
  raise ArgumentError,
52
- "`#{k}` is not a valid attribute in `Algolia::DockerSourceDiscover`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
+ "`#{k}` is not a valid attribute in `Algolia::TransformationCreateResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
54
  end
54
55
 
55
56
  h[k.to_sym] = v
56
57
  end
57
58
 
58
- if attributes.key?(:run_id)
59
- self.run_id = attributes[:run_id]
59
+ if attributes.key?(:transformation_id)
60
+ self.transformation_id = attributes[:transformation_id]
60
61
  else
61
- self.run_id = nil
62
+ self.transformation_id = nil
62
63
  end
63
64
 
64
65
  if attributes.key?(:created_at)
@@ -74,7 +75,7 @@ module Algolia
74
75
  return true if equal?(other)
75
76
 
76
77
  self.class == other.class &&
77
- run_id == other.run_id &&
78
+ transformation_id == other.transformation_id &&
78
79
  created_at == other.created_at
79
80
  end
80
81
 
@@ -87,7 +88,7 @@ module Algolia
87
88
  # Calculates hash code according to all attributes.
88
89
  # @return [Integer] Hash code
89
90
  def hash
90
- [run_id, created_at].hash
91
+ [transformation_id, created_at].hash
91
92
  end
92
93
 
93
94
  # Builds the object from hash
@@ -5,13 +5,13 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Ingestion
8
- class DockerSourceStreams
9
- attr_accessor :streams
8
+ class TransformationSearch
9
+ attr_accessor :transformations_ids
10
10
 
11
11
  # Attribute mapping from ruby-style variable name to JSON key.
12
12
  def self.attribute_map
13
13
  {
14
- :streams => :streams
14
+ :transformations_ids => :transformationsIDs
15
15
  }
16
16
  end
17
17
 
@@ -23,7 +23,7 @@ module Algolia
23
23
  # Attribute type mapping.
24
24
  def self.types_mapping
25
25
  {
26
- :streams => :'Array<Object>'
26
+ :transformations_ids => :'Array<String>'
27
27
  }
28
28
  end
29
29
 
@@ -36,25 +36,25 @@ module Algolia
36
36
  # @param [Hash] attributes Model attributes in the form of hash
37
37
  def initialize(attributes = {})
38
38
  unless attributes.is_a?(Hash)
39
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DockerSourceStreams` initialize method"
39
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TransformationSearch` initialize method"
40
40
  end
41
41
 
42
42
  # check to see if the attribute exists and convert string to symbol for hash key
43
43
  attributes = attributes.each_with_object({}) do |(k, v), h|
44
44
  unless self.class.attribute_map.key?(k.to_sym)
45
45
  raise ArgumentError,
46
- "`#{k}` is not a valid attribute in `Algolia::DockerSourceStreams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46
+ "`#{k}` is not a valid attribute in `Algolia::TransformationSearch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
47
47
  end
48
48
 
49
49
  h[k.to_sym] = v
50
50
  end
51
51
 
52
- if attributes.key?(:streams)
53
- if (value = attributes[:streams]).is_a?(Array)
54
- self.streams = value
52
+ if attributes.key?(:transformations_ids)
53
+ if (value = attributes[:transformations_ids]).is_a?(Array)
54
+ self.transformations_ids = value
55
55
  end
56
56
  else
57
- self.streams = nil
57
+ self.transformations_ids = nil
58
58
  end
59
59
  end
60
60
 
@@ -64,7 +64,7 @@ module Algolia
64
64
  return true if equal?(other)
65
65
 
66
66
  self.class == other.class &&
67
- streams == other.streams
67
+ transformations_ids == other.transformations_ids
68
68
  end
69
69
 
70
70
  # @see the `==` method
@@ -76,7 +76,7 @@ module Algolia
76
76
  # Calculates hash code according to all attributes.
77
77
  # @return [Integer] Hash code
78
78
  def hash
79
- [streams].hash
79
+ [transformations_ids].hash
80
80
  end
81
81
 
82
82
  # Builds the object from hash
@@ -0,0 +1,211 @@
1
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
+
3
+ require 'date'
4
+ require 'time'
5
+
6
+ module Algolia
7
+ module Ingestion
8
+ class TransformationTry
9
+ # The source code of the transformation.
10
+ attr_accessor :code
11
+
12
+ # The record to apply the given code to.
13
+ attr_accessor :sample_record
14
+
15
+ # Attribute mapping from ruby-style variable name to JSON key.
16
+ def self.attribute_map
17
+ {
18
+ :code => :code,
19
+ :sample_record => :sampleRecord
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
+ :code => :String,
32
+ :sample_record => :Object
33
+ }
34
+ end
35
+
36
+ # List of attributes with nullable: true
37
+ def self.openapi_nullable
38
+ Set.new([])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ unless attributes.is_a?(Hash)
45
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TransformationTry` initialize method"
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({}) do |(k, v), h|
50
+ unless self.class.attribute_map.key?(k.to_sym)
51
+ raise ArgumentError,
52
+ "`#{k}` is not a valid attribute in `Algolia::TransformationTry`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
+ end
54
+
55
+ h[k.to_sym] = v
56
+ end
57
+
58
+ if attributes.key?(:code)
59
+ self.code = attributes[:code]
60
+ else
61
+ self.code = nil
62
+ end
63
+
64
+ if attributes.key?(:sample_record)
65
+ self.sample_record = attributes[:sample_record]
66
+ else
67
+ self.sample_record = nil
68
+ end
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(other)
74
+ return true if equal?(other)
75
+
76
+ self.class == other.class &&
77
+ code == other.code &&
78
+ sample_record == other.sample_record
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(other)
84
+ self == other
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Integer] Hash code
89
+ def hash
90
+ [code, sample_record].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def self.build_from_hash(attributes)
97
+ return nil unless attributes.is_a?(Hash)
98
+
99
+ attributes = attributes.transform_keys(&:to_sym)
100
+ transformed_hash = {}
101
+ types_mapping.each_pair do |key, type|
102
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
103
+ transformed_hash[key.to_sym] = nil
104
+ elsif type =~ /\AArray<(.*)>/i
105
+ # check to ensure the input is an array given that the attribute
106
+ # is documented as an array but the input is not
107
+ if attributes[attribute_map[key]].is_a?(Array)
108
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
109
+ end
110
+ elsif !attributes[attribute_map[key]].nil?
111
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
112
+ end
113
+ end
114
+ new(transformed_hash)
115
+ end
116
+
117
+ # Deserializes the data based on type
118
+ # @param string type Data type
119
+ # @param string value Value to be deserialized
120
+ # @return [Object] Deserialized data
121
+ def self._deserialize(type, value)
122
+ case type.to_sym
123
+ when :Time
124
+ Time.parse(value)
125
+ when :Date
126
+ Date.parse(value)
127
+ when :String
128
+ value.to_s
129
+ when :Integer
130
+ value.to_i
131
+ when :Float
132
+ value.to_f
133
+ when :Boolean
134
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
135
+ true
136
+ else
137
+ false
138
+ end
139
+ when :Object
140
+ # generic object (usually a Hash), return directly
141
+ value
142
+ when /\AArray<(?<inner_type>.+)>\z/
143
+ inner_type = Regexp.last_match[:inner_type]
144
+ value.map { |v| _deserialize(inner_type, v) }
145
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
146
+ k_type = Regexp.last_match[:k_type]
147
+ v_type = Regexp.last_match[:v_type]
148
+ {}.tap do |hash|
149
+ value.each do |k, v|
150
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
151
+ end
152
+ end
153
+ else # model
154
+ # models (e.g. Pet) or oneOf
155
+ klass = Algolia::Ingestion.const_get(type)
156
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
157
+ end
158
+ end
159
+
160
+ # Returns the string representation of the object
161
+ # @return [String] String presentation of the object
162
+ def to_s
163
+ to_hash.to_s
164
+ end
165
+
166
+ # to_body is an alias to to_hash (backward compatibility)
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_body
169
+ to_hash
170
+ end
171
+
172
+ def to_json(*_args)
173
+ to_hash.to_json
174
+ end
175
+
176
+ # Returns the object in the form of hash
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_hash
179
+ hash = {}
180
+ self.class.attribute_map.each_pair do |attr, param|
181
+ value = send(attr)
182
+ if value.nil?
183
+ is_nullable = self.class.openapi_nullable.include?(attr)
184
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
185
+ end
186
+
187
+ hash[param] = _to_hash(value)
188
+ end
189
+ hash
190
+ end
191
+
192
+ # Outputs non-array value in the form of hash
193
+ # For object, use to_hash. Otherwise, just return the value
194
+ # @param [Object] value Any valid value
195
+ # @return [Hash] Returns the value in the form of hash
196
+ def _to_hash(value)
197
+ if value.is_a?(Array)
198
+ value.compact.map { |v| _to_hash(v) }
199
+ elsif value.is_a?(Hash)
200
+ {}.tap do |hash|
201
+ value.each { |k, v| hash[k] = _to_hash(v) }
202
+ end
203
+ elsif value.respond_to? :to_hash
204
+ value.to_hash
205
+ else
206
+ value
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end