ragie_ruby_sdk 1.0.16 → 1.0.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -5
  3. data/docs/CodeInterpreterOutput.md +28 -0
  4. data/docs/CodeInterpreterOutputLogs.md +20 -0
  5. data/docs/FileSearchOutput.md +26 -0
  6. data/docs/FileSearchResult.md +26 -0
  7. data/docs/FinalAnswerStepsInner.md +4 -0
  8. data/docs/QueryDetails.md +24 -0
  9. data/docs/ReasoningOutput.md +28 -0
  10. data/docs/ReasoningSummary.md +20 -0
  11. data/docs/ReasoningText.md +20 -0
  12. data/docs/Response.md +1 -1
  13. data/docs/ResponseOutputInner.md +40 -0
  14. data/docs/{ResponseOutput.md → ResponseOutputMessage.md} +2 -2
  15. data/docs/SearchEffort.md +15 -0
  16. data/docs/SearchStep.md +1 -1
  17. data/docs/SearchStepWithQueryDetails.md +24 -0
  18. data/lib/ragie_ruby_sdk/models/code_interpreter_output.rb +389 -0
  19. data/lib/ragie_ruby_sdk/models/code_interpreter_output_logs.rb +283 -0
  20. data/lib/ragie_ruby_sdk/models/file_search_output.rb +368 -0
  21. data/lib/ragie_ruby_sdk/models/file_search_result.rb +348 -0
  22. data/lib/ragie_ruby_sdk/models/final_answer_steps_inner.rb +1 -0
  23. data/lib/ragie_ruby_sdk/models/query_details.rb +341 -0
  24. data/lib/ragie_ruby_sdk/models/reasoning_output.rb +391 -0
  25. data/lib/ragie_ruby_sdk/models/reasoning_summary.rb +283 -0
  26. data/lib/ragie_ruby_sdk/models/reasoning_text.rb +283 -0
  27. data/lib/ragie_ruby_sdk/models/response.rb +1 -1
  28. data/lib/ragie_ruby_sdk/models/response_output_inner.rb +105 -0
  29. data/lib/ragie_ruby_sdk/models/{response_output.rb → response_output_message.rb} +3 -3
  30. data/lib/ragie_ruby_sdk/models/search_effort.rb +41 -0
  31. data/lib/ragie_ruby_sdk/models/search_step.rb +3 -3
  32. data/lib/ragie_ruby_sdk/models/search_step_with_query_details.rb +306 -0
  33. data/lib/ragie_ruby_sdk/version.rb +1 -1
  34. data/lib/ragie_ruby_sdk.rb +12 -1
  35. data/spec/models/code_interpreter_output_logs_spec.rb +46 -0
  36. data/spec/models/code_interpreter_output_spec.rb +74 -0
  37. data/spec/models/file_search_output_spec.rb +68 -0
  38. data/spec/models/file_search_result_spec.rb +60 -0
  39. data/spec/models/query_details_spec.rb +54 -0
  40. data/spec/models/reasoning_output_spec.rb +74 -0
  41. data/spec/models/reasoning_summary_spec.rb +46 -0
  42. data/spec/models/reasoning_text_spec.rb +46 -0
  43. data/spec/models/response_output_inner_spec.rb +21 -0
  44. data/spec/models/{response_output_spec.rb → response_output_message_spec.rb} +6 -6
  45. data/spec/models/search_effort_spec.rb +30 -0
  46. data/spec/models/search_step_spec.rb +1 -1
  47. data/spec/models/search_step_with_query_details_spec.rb +58 -0
  48. metadata +49 -5
@@ -0,0 +1,368 @@
1
+ =begin
2
+ #Ragie API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module RagieRubySdk
17
+ class FileSearchOutput
18
+ attr_accessor :id
19
+
20
+ # The queries used to search for files.
21
+ attr_accessor :queries
22
+
23
+ attr_accessor :status
24
+
25
+ attr_accessor :type
26
+
27
+ # The results of the file search tool call.
28
+ attr_accessor :results
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'id' => :'id',
56
+ :'queries' => :'queries',
57
+ :'status' => :'status',
58
+ :'type' => :'type',
59
+ :'results' => :'results'
60
+ }
61
+ end
62
+
63
+ # Returns attribute mapping this model knows about
64
+ def self.acceptable_attribute_map
65
+ attribute_map
66
+ end
67
+
68
+ # Returns all the JSON keys this model knows about
69
+ def self.acceptable_attributes
70
+ acceptable_attribute_map.values
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.openapi_types
75
+ {
76
+ :'id' => :'String',
77
+ :'queries' => :'Array<String>',
78
+ :'status' => :'String',
79
+ :'type' => :'String',
80
+ :'results' => :'Array<FileSearchResult>'
81
+ }
82
+ end
83
+
84
+ # List of attributes with nullable: true
85
+ def self.openapi_nullable
86
+ Set.new([
87
+ ])
88
+ end
89
+
90
+ # Initializes the object
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ def initialize(attributes = {})
93
+ if (!attributes.is_a?(Hash))
94
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RagieRubySdk::FileSearchOutput` initialize method"
95
+ end
96
+
97
+ # check to see if the attribute exists and convert string to symbol for hash key
98
+ acceptable_attribute_map = self.class.acceptable_attribute_map
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!acceptable_attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RagieRubySdk::FileSearchOutput`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'id')
107
+ self.id = attributes[:'id']
108
+ else
109
+ self.id = nil
110
+ end
111
+
112
+ if attributes.key?(:'queries')
113
+ if (value = attributes[:'queries']).is_a?(Array)
114
+ self.queries = value
115
+ end
116
+ else
117
+ self.queries = nil
118
+ end
119
+
120
+ if attributes.key?(:'status')
121
+ self.status = attributes[:'status']
122
+ else
123
+ self.status = 'searching'
124
+ end
125
+
126
+ if attributes.key?(:'type')
127
+ self.type = attributes[:'type']
128
+ else
129
+ self.type = nil
130
+ end
131
+
132
+ if attributes.key?(:'results')
133
+ if (value = attributes[:'results']).is_a?(Array)
134
+ self.results = value
135
+ end
136
+ else
137
+ self.results = nil
138
+ end
139
+ end
140
+
141
+ # Show invalid properties with the reasons. Usually used together with valid?
142
+ # @return Array for valid properties with the reasons
143
+ def list_invalid_properties
144
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
145
+ invalid_properties = Array.new
146
+ if @id.nil?
147
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
148
+ end
149
+
150
+ if @queries.nil?
151
+ invalid_properties.push('invalid value for "queries", queries cannot be nil.')
152
+ end
153
+
154
+ if @type.nil?
155
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
156
+ end
157
+
158
+ if @results.nil?
159
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
160
+ end
161
+
162
+ invalid_properties
163
+ end
164
+
165
+ # Check to see if the all the properties in the model are valid
166
+ # @return true if the model is valid
167
+ def valid?
168
+ warn '[DEPRECATED] the `valid?` method is obsolete'
169
+ return false if @id.nil?
170
+ return false if @queries.nil?
171
+ status_validator = EnumAttributeValidator.new('String', ["in_progress", "searching", "incomplete", "completed", "failed"])
172
+ return false unless status_validator.valid?(@status)
173
+ return false if @type.nil?
174
+ type_validator = EnumAttributeValidator.new('String', ["file_search_call"])
175
+ return false unless type_validator.valid?(@type)
176
+ return false if @results.nil?
177
+ true
178
+ end
179
+
180
+ # Custom attribute writer method with validation
181
+ # @param [Object] id Value to be assigned
182
+ def id=(id)
183
+ if id.nil?
184
+ fail ArgumentError, 'id cannot be nil'
185
+ end
186
+
187
+ @id = id
188
+ end
189
+
190
+ # Custom attribute writer method with validation
191
+ # @param [Object] queries Value to be assigned
192
+ def queries=(queries)
193
+ if queries.nil?
194
+ fail ArgumentError, 'queries cannot be nil'
195
+ end
196
+
197
+ @queries = queries
198
+ end
199
+
200
+ # Custom attribute writer method checking allowed values (enum).
201
+ # @param [Object] status Object to be assigned
202
+ def status=(status)
203
+ validator = EnumAttributeValidator.new('String', ["in_progress", "searching", "incomplete", "completed", "failed"])
204
+ unless validator.valid?(status)
205
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
206
+ end
207
+ @status = status
208
+ end
209
+
210
+ # Custom attribute writer method checking allowed values (enum).
211
+ # @param [Object] type Object to be assigned
212
+ def type=(type)
213
+ validator = EnumAttributeValidator.new('String', ["file_search_call"])
214
+ unless validator.valid?(type)
215
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
216
+ end
217
+ @type = type
218
+ end
219
+
220
+ # Custom attribute writer method with validation
221
+ # @param [Object] results Value to be assigned
222
+ def results=(results)
223
+ if results.nil?
224
+ fail ArgumentError, 'results cannot be nil'
225
+ end
226
+
227
+ @results = results
228
+ end
229
+
230
+ # Checks equality by comparing each attribute.
231
+ # @param [Object] Object to be compared
232
+ def ==(o)
233
+ return true if self.equal?(o)
234
+ self.class == o.class &&
235
+ id == o.id &&
236
+ queries == o.queries &&
237
+ status == o.status &&
238
+ type == o.type &&
239
+ results == o.results
240
+ end
241
+
242
+ # @see the `==` method
243
+ # @param [Object] Object to be compared
244
+ def eql?(o)
245
+ self == o
246
+ end
247
+
248
+ # Calculates hash code according to all attributes.
249
+ # @return [Integer] Hash code
250
+ def hash
251
+ [id, queries, status, type, results].hash
252
+ end
253
+
254
+ # Builds the object from hash
255
+ # @param [Hash] attributes Model attributes in the form of hash
256
+ # @return [Object] Returns the model itself
257
+ def self.build_from_hash(attributes)
258
+ return nil unless attributes.is_a?(Hash)
259
+ attributes = attributes.transform_keys(&:to_sym)
260
+ transformed_hash = {}
261
+ openapi_types.each_pair do |key, type|
262
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
263
+ transformed_hash["#{key}"] = nil
264
+ elsif type =~ /\AArray<(.*)>/i
265
+ # check to ensure the input is an array given that the attribute
266
+ # is documented as an array but the input is not
267
+ if attributes[attribute_map[key]].is_a?(Array)
268
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
269
+ end
270
+ elsif !attributes[attribute_map[key]].nil?
271
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
272
+ end
273
+ end
274
+ new(transformed_hash)
275
+ end
276
+
277
+ # Deserializes the data based on type
278
+ # @param string type Data type
279
+ # @param string value Value to be deserialized
280
+ # @return [Object] Deserialized data
281
+ def self._deserialize(type, value)
282
+ case type.to_sym
283
+ when :Time
284
+ Time.parse(value)
285
+ when :Date
286
+ Date.parse(value)
287
+ when :String
288
+ value.to_s
289
+ when :Integer
290
+ value.to_i
291
+ when :Float
292
+ value.to_f
293
+ when :Boolean
294
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
295
+ true
296
+ else
297
+ false
298
+ end
299
+ when :Object
300
+ # generic object (usually a Hash), return directly
301
+ value
302
+ when /\AArray<(?<inner_type>.+)>\z/
303
+ inner_type = Regexp.last_match[:inner_type]
304
+ value.map { |v| _deserialize(inner_type, v) }
305
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
306
+ k_type = Regexp.last_match[:k_type]
307
+ v_type = Regexp.last_match[:v_type]
308
+ {}.tap do |hash|
309
+ value.each do |k, v|
310
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
311
+ end
312
+ end
313
+ else # model
314
+ # models (e.g. Pet) or oneOf
315
+ klass = RagieRubySdk.const_get(type)
316
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
317
+ end
318
+ end
319
+
320
+ # Returns the string representation of the object
321
+ # @return [String] String presentation of the object
322
+ def to_s
323
+ to_hash.to_s
324
+ end
325
+
326
+ # to_body is an alias to to_hash (backward compatibility)
327
+ # @return [Hash] Returns the object in the form of hash
328
+ def to_body
329
+ to_hash
330
+ end
331
+
332
+ # Returns the object in the form of hash
333
+ # @return [Hash] Returns the object in the form of hash
334
+ def to_hash
335
+ hash = {}
336
+ self.class.attribute_map.each_pair do |attr, param|
337
+ value = self.send(attr)
338
+ if value.nil?
339
+ is_nullable = self.class.openapi_nullable.include?(attr)
340
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
341
+ end
342
+
343
+ hash[param] = _to_hash(value)
344
+ end
345
+ hash
346
+ end
347
+
348
+ # Outputs non-array value in the form of hash
349
+ # For object, use to_hash. Otherwise, just return the value
350
+ # @param [Object] value Any valid value
351
+ # @return [Hash] Returns the value in the form of hash
352
+ def _to_hash(value)
353
+ if value.is_a?(Array)
354
+ value.compact.map { |v| _to_hash(v) }
355
+ elsif value.is_a?(Hash)
356
+ {}.tap do |hash|
357
+ value.each { |k, v| hash[k] = _to_hash(v) }
358
+ end
359
+ elsif value.respond_to? :to_hash
360
+ value.to_hash
361
+ else
362
+ value
363
+ end
364
+ end
365
+
366
+ end
367
+
368
+ end
@@ -0,0 +1,348 @@
1
+ =begin
2
+ #Ragie API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module RagieRubySdk
17
+ class FileSearchResult
18
+ # The unique ID of the document.
19
+ attr_accessor :file_id
20
+
21
+ # The name of the document.
22
+ attr_accessor :filename
23
+
24
+ # The relevance score of the chunk - a value between 0 and 1.
25
+ attr_accessor :score
26
+
27
+ # The text content of the chunk.
28
+ attr_accessor :text
29
+
30
+ # The attributes of the chunk.
31
+ attr_accessor :attributes
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'file_id' => :'file_id',
37
+ :'filename' => :'filename',
38
+ :'score' => :'score',
39
+ :'text' => :'text',
40
+ :'attributes' => :'attributes'
41
+ }
42
+ end
43
+
44
+ # Returns attribute mapping this model knows about
45
+ def self.acceptable_attribute_map
46
+ attribute_map
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ acceptable_attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'file_id' => :'String',
58
+ :'filename' => :'String',
59
+ :'score' => :'Float',
60
+ :'text' => :'String',
61
+ :'attributes' => :'Hash<String, Object>'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RagieRubySdk::FileSearchResult` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ acceptable_attribute_map = self.class.acceptable_attribute_map
80
+ attributes = attributes.each_with_object({}) { |(k, v), h|
81
+ if (!acceptable_attribute_map.key?(k.to_sym))
82
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RagieRubySdk::FileSearchResult`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
83
+ end
84
+ h[k.to_sym] = v
85
+ }
86
+
87
+ if attributes.key?(:'file_id')
88
+ self.file_id = attributes[:'file_id']
89
+ else
90
+ self.file_id = nil
91
+ end
92
+
93
+ if attributes.key?(:'filename')
94
+ self.filename = attributes[:'filename']
95
+ else
96
+ self.filename = nil
97
+ end
98
+
99
+ if attributes.key?(:'score')
100
+ self.score = attributes[:'score']
101
+ else
102
+ self.score = nil
103
+ end
104
+
105
+ if attributes.key?(:'text')
106
+ self.text = attributes[:'text']
107
+ else
108
+ self.text = nil
109
+ end
110
+
111
+ if attributes.key?(:'attributes')
112
+ if (value = attributes[:'attributes']).is_a?(Hash)
113
+ self.attributes = value
114
+ end
115
+ else
116
+ self.attributes = nil
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
124
+ invalid_properties = Array.new
125
+ if @file_id.nil?
126
+ invalid_properties.push('invalid value for "file_id", file_id cannot be nil.')
127
+ end
128
+
129
+ if @filename.nil?
130
+ invalid_properties.push('invalid value for "filename", filename cannot be nil.')
131
+ end
132
+
133
+ if @score.nil?
134
+ invalid_properties.push('invalid value for "score", score cannot be nil.')
135
+ end
136
+
137
+ if @text.nil?
138
+ invalid_properties.push('invalid value for "text", text cannot be nil.')
139
+ end
140
+
141
+ if @attributes.nil?
142
+ invalid_properties.push('invalid value for "attributes", attributes cannot be nil.')
143
+ end
144
+
145
+ invalid_properties
146
+ end
147
+
148
+ # Check to see if the all the properties in the model are valid
149
+ # @return true if the model is valid
150
+ def valid?
151
+ warn '[DEPRECATED] the `valid?` method is obsolete'
152
+ return false if @file_id.nil?
153
+ return false if @filename.nil?
154
+ return false if @score.nil?
155
+ return false if @text.nil?
156
+ return false if @attributes.nil?
157
+ true
158
+ end
159
+
160
+ # Custom attribute writer method with validation
161
+ # @param [Object] file_id Value to be assigned
162
+ def file_id=(file_id)
163
+ if file_id.nil?
164
+ fail ArgumentError, 'file_id cannot be nil'
165
+ end
166
+
167
+ @file_id = file_id
168
+ end
169
+
170
+ # Custom attribute writer method with validation
171
+ # @param [Object] filename Value to be assigned
172
+ def filename=(filename)
173
+ if filename.nil?
174
+ fail ArgumentError, 'filename cannot be nil'
175
+ end
176
+
177
+ @filename = filename
178
+ end
179
+
180
+ # Custom attribute writer method with validation
181
+ # @param [Object] score Value to be assigned
182
+ def score=(score)
183
+ if score.nil?
184
+ fail ArgumentError, 'score cannot be nil'
185
+ end
186
+
187
+ @score = score
188
+ end
189
+
190
+ # Custom attribute writer method with validation
191
+ # @param [Object] text Value to be assigned
192
+ def text=(text)
193
+ if text.nil?
194
+ fail ArgumentError, 'text cannot be nil'
195
+ end
196
+
197
+ @text = text
198
+ end
199
+
200
+ # Custom attribute writer method with validation
201
+ # @param [Object] attributes Value to be assigned
202
+ def attributes=(attributes)
203
+ if attributes.nil?
204
+ fail ArgumentError, 'attributes cannot be nil'
205
+ end
206
+
207
+ @attributes = attributes
208
+ end
209
+
210
+ # Checks equality by comparing each attribute.
211
+ # @param [Object] Object to be compared
212
+ def ==(o)
213
+ return true if self.equal?(o)
214
+ self.class == o.class &&
215
+ file_id == o.file_id &&
216
+ filename == o.filename &&
217
+ score == o.score &&
218
+ text == o.text &&
219
+ attributes == o.attributes
220
+ end
221
+
222
+ # @see the `==` method
223
+ # @param [Object] Object to be compared
224
+ def eql?(o)
225
+ self == o
226
+ end
227
+
228
+ # Calculates hash code according to all attributes.
229
+ # @return [Integer] Hash code
230
+ def hash
231
+ [file_id, filename, score, text, attributes].hash
232
+ end
233
+
234
+ # Builds the object from hash
235
+ # @param [Hash] attributes Model attributes in the form of hash
236
+ # @return [Object] Returns the model itself
237
+ def self.build_from_hash(attributes)
238
+ return nil unless attributes.is_a?(Hash)
239
+ attributes = attributes.transform_keys(&:to_sym)
240
+ transformed_hash = {}
241
+ openapi_types.each_pair do |key, type|
242
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
243
+ transformed_hash["#{key}"] = nil
244
+ elsif type =~ /\AArray<(.*)>/i
245
+ # check to ensure the input is an array given that the attribute
246
+ # is documented as an array but the input is not
247
+ if attributes[attribute_map[key]].is_a?(Array)
248
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
249
+ end
250
+ elsif !attributes[attribute_map[key]].nil?
251
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
252
+ end
253
+ end
254
+ new(transformed_hash)
255
+ end
256
+
257
+ # Deserializes the data based on type
258
+ # @param string type Data type
259
+ # @param string value Value to be deserialized
260
+ # @return [Object] Deserialized data
261
+ def self._deserialize(type, value)
262
+ case type.to_sym
263
+ when :Time
264
+ Time.parse(value)
265
+ when :Date
266
+ Date.parse(value)
267
+ when :String
268
+ value.to_s
269
+ when :Integer
270
+ value.to_i
271
+ when :Float
272
+ value.to_f
273
+ when :Boolean
274
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
275
+ true
276
+ else
277
+ false
278
+ end
279
+ when :Object
280
+ # generic object (usually a Hash), return directly
281
+ value
282
+ when /\AArray<(?<inner_type>.+)>\z/
283
+ inner_type = Regexp.last_match[:inner_type]
284
+ value.map { |v| _deserialize(inner_type, v) }
285
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
286
+ k_type = Regexp.last_match[:k_type]
287
+ v_type = Regexp.last_match[:v_type]
288
+ {}.tap do |hash|
289
+ value.each do |k, v|
290
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
291
+ end
292
+ end
293
+ else # model
294
+ # models (e.g. Pet) or oneOf
295
+ klass = RagieRubySdk.const_get(type)
296
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
297
+ end
298
+ end
299
+
300
+ # Returns the string representation of the object
301
+ # @return [String] String presentation of the object
302
+ def to_s
303
+ to_hash.to_s
304
+ end
305
+
306
+ # to_body is an alias to to_hash (backward compatibility)
307
+ # @return [Hash] Returns the object in the form of hash
308
+ def to_body
309
+ to_hash
310
+ end
311
+
312
+ # Returns the object in the form of hash
313
+ # @return [Hash] Returns the object in the form of hash
314
+ def to_hash
315
+ hash = {}
316
+ self.class.attribute_map.each_pair do |attr, param|
317
+ value = self.send(attr)
318
+ if value.nil?
319
+ is_nullable = self.class.openapi_nullable.include?(attr)
320
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
321
+ end
322
+
323
+ hash[param] = _to_hash(value)
324
+ end
325
+ hash
326
+ end
327
+
328
+ # Outputs non-array value in the form of hash
329
+ # For object, use to_hash. Otherwise, just return the value
330
+ # @param [Object] value Any valid value
331
+ # @return [Hash] Returns the value in the form of hash
332
+ def _to_hash(value)
333
+ if value.is_a?(Array)
334
+ value.compact.map { |v| _to_hash(v) }
335
+ elsif value.is_a?(Hash)
336
+ {}.tap do |hash|
337
+ value.each { |k, v| hash[k] = _to_hash(v) }
338
+ end
339
+ elsif value.respond_to? :to_hash
340
+ value.to_hash
341
+ else
342
+ value
343
+ end
344
+ end
345
+
346
+ end
347
+
348
+ end