lingara 0.2.0.pre.alpha.4 → 0.2.0.pre.alpha.6

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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +90 -0
  3. data/lib/lingara/canvas.rb +101 -0
  4. data/lib/lingara/client.rb +8 -5
  5. data/lib/lingara/dialogue.rb +143 -0
  6. data/lib/lingara/models/activate_canvas_request.rb +313 -0
  7. data/lib/lingara/models/activate_dialogue_request.rb +237 -0
  8. data/lib/lingara/models/allowance_row.rb +1 -1
  9. data/lib/lingara/models/app_context_slice.rb +1 -1
  10. data/lib/lingara/models/app_disabled_data.rb +1 -1
  11. data/lib/lingara/models/app_enabled_data.rb +1 -1
  12. data/lib/lingara/models/app_installed_data.rb +1 -1
  13. data/lib/lingara/models/app_uninstalled_data.rb +1 -1
  14. data/lib/lingara/models/canvas.rb +339 -0
  15. data/lib/lingara/models/canvas_activation_outcome.rb +41 -0
  16. data/lib/lingara/models/canvas_active.rb +317 -0
  17. data/lib/lingara/models/canvas_definition.rb +323 -0
  18. data/lib/lingara/models/canvas_draft.rb +317 -0
  19. data/lib/lingara/models/canvas_dry_run.rb +265 -0
  20. data/lib/lingara/models/canvas_edge.rb +263 -0
  21. data/lib/lingara/models/canvas_made_object.rb +311 -0
  22. data/lib/lingara/models/canvas_node.rb +397 -0
  23. data/lib/lingara/models/canvas_node_kind.rb +43 -0
  24. data/lib/lingara/models/canvas_object_ref.rb +237 -0
  25. data/lib/lingara/models/canvas_page.rb +289 -0
  26. data/lib/lingara/models/canvas_param.rb +105 -0
  27. data/lib/lingara/models/canvas_plan.rb +248 -0
  28. data/lib/lingara/models/canvas_recipe.rb +43 -0
  29. data/lib/lingara/models/canvas_summary.rb +511 -0
  30. data/lib/lingara/models/canvas_verdict.rb +389 -0
  31. data/lib/lingara/models/canvas_verdict_kind.rb +42 -0
  32. data/lib/lingara/models/create_canvas_request.rb +279 -0
  33. data/lib/lingara/models/create_dialogue_request.rb +248 -0
  34. data/lib/lingara/models/create_lesson_plan_event_error.rb +1 -1
  35. data/lib/lingara/models/create_lesson_plan_event_phase.rb +1 -1
  36. data/lib/lingara/models/create_lesson_plan_event_result.rb +1 -1
  37. data/lib/lingara/models/create_lesson_plan_event_started.rb +1 -1
  38. data/lib/lingara/models/dialogue.rb +367 -0
  39. data/lib/lingara/models/dialogue_active.rb +290 -0
  40. data/lib/lingara/models/dialogue_draft.rb +290 -0
  41. data/lib/lingara/models/dialogue_entry.rb +1 -1
  42. data/lib/lingara/models/dialogue_npc.rb +326 -0
  43. data/lib/lingara/models/dialogue_page.rb +277 -0
  44. data/lib/lingara/models/dialogue_rule.rb +55 -0
  45. data/lib/lingara/models/dialogue_summary.rb +431 -0
  46. data/lib/lingara/models/dialogue_transition.rb +264 -0
  47. data/lib/lingara/models/dialogue_turn_request.rb +110 -6
  48. data/lib/lingara/models/dialogue_warning.rb +285 -0
  49. data/lib/lingara/models/dialogue_warning_code.rb +42 -0
  50. data/lib/lingara/models/embed_player_link.rb +1 -1
  51. data/lib/lingara/models/embed_token.rb +1 -1
  52. data/lib/lingara/models/embed_token_request.rb +1 -1
  53. data/lib/lingara/models/error_envelope.rb +2 -2
  54. data/lib/lingara/models/event_envelope.rb +1 -1
  55. data/lib/lingara/models/event_page.rb +1 -1
  56. data/lib/lingara/models/fact_value.rb +105 -0
  57. data/lib/lingara/models/generate_vocabulary_event_done.rb +1 -1
  58. data/lib/lingara/models/generate_vocabulary_event_error.rb +1 -1
  59. data/lib/lingara/models/generate_vocabulary_event_item.rb +1 -1
  60. data/lib/lingara/models/generate_vocabulary_event_started.rb +1 -1
  61. data/lib/lingara/models/graph_checkpoint.rb +322 -0
  62. data/lib/lingara/models/graph_edge.rb +329 -0
  63. data/lib/lingara/models/inbound_event_accepted.rb +1 -1
  64. data/lib/lingara/models/lesson_plan.rb +1 -1
  65. data/lib/lingara/models/lesson_plan_content.rb +1 -1
  66. data/lib/lingara/models/lesson_plan_create_request.rb +1 -1
  67. data/lib/lingara/models/lesson_plan_failed_data.rb +1 -1
  68. data/lib/lingara/models/lesson_plan_ready_data.rb +1 -1
  69. data/lib/lingara/models/link_status.rb +1 -1
  70. data/lib/lingara/models/notice.rb +1 -1
  71. data/lib/lingara/models/npc.rb +1 -1
  72. data/lib/lingara/models/npc_language.rb +345 -0
  73. data/lib/lingara/models/pedagogy.rb +41 -0
  74. data/lib/lingara/models/plan_fail_reason.rb +1 -1
  75. data/lib/lingara/models/plan_pending.rb +1 -1
  76. data/lib/lingara/models/plan_phase.rb +1 -1
  77. data/lib/lingara/models/plan_question.rb +1 -1
  78. data/lib/lingara/models/plan_ready_status.rb +1 -1
  79. data/lib/lingara/models/plan_result.rb +1 -1
  80. data/lib/lingara/models/plan_set.rb +1 -1
  81. data/lib/lingara/models/plan_started.rb +1 -1
  82. data/lib/lingara/models/plan_status.rb +1 -1
  83. data/lib/lingara/models/plan_word.rb +1 -1
  84. data/lib/lingara/models/practice_completed_data.rb +1 -1
  85. data/lib/lingara/models/practice_item.rb +1 -1
  86. data/lib/lingara/models/practice_outcome.rb +1 -1
  87. data/lib/lingara/models/reaction_report.rb +1 -1
  88. data/lib/lingara/models/reaction_status.rb +1 -1
  89. data/lib/lingara/models/rename_canvas_request.rb +237 -0
  90. data/lib/lingara/models/rename_dialogue_request.rb +237 -0
  91. data/lib/lingara/models/save_canvas_draft_request.rb +273 -0
  92. data/lib/lingara/models/save_dialogue_draft_request.rb +274 -0
  93. data/lib/lingara/models/send_dialogue_turn_event_delta.rb +1 -1
  94. data/lib/lingara/models/send_dialogue_turn_event_done.rb +1 -1
  95. data/lib/lingara/models/send_dialogue_turn_event_error.rb +1 -1
  96. data/lib/lingara/models/send_dialogue_turn_event_notice.rb +1 -1
  97. data/lib/lingara/models/send_dialogue_turn_event_transition.rb +287 -0
  98. data/lib/lingara/models/send_tutor_message_event_delta.rb +1 -1
  99. data/lib/lingara/models/send_tutor_message_event_done.rb +1 -1
  100. data/lib/lingara/models/send_tutor_message_event_error.rb +1 -1
  101. data/lib/lingara/models/send_tutor_message_event_notice.rb +1 -1
  102. data/lib/lingara/models/speaker.rb +1 -1
  103. data/lib/lingara/models/stream_error.rb +1 -1
  104. data/lib/lingara/models/stream_events_event_done.rb +1 -1
  105. data/lib/lingara/models/stream_events_event_error.rb +1 -1
  106. data/lib/lingara/models/stream_events_event_event.rb +1 -1
  107. data/lib/lingara/models/stream_lesson_plan_event_error.rb +1 -1
  108. data/lib/lingara/models/stream_lesson_plan_event_pending.rb +1 -1
  109. data/lib/lingara/models/stream_lesson_plan_event_phase.rb +1 -1
  110. data/lib/lingara/models/stream_lesson_plan_event_result.rb +1 -1
  111. data/lib/lingara/models/stream_lesson_plan_event_started.rb +1 -1
  112. data/lib/lingara/models/threshold_scope.rb +1 -1
  113. data/lib/lingara/models/turn_delta.rb +1 -1
  114. data/lib/lingara/models/turn_entry.rb +1 -1
  115. data/lib/lingara/models/turn_role.rb +1 -1
  116. data/lib/lingara/models/tutor_turn_request.rb +1 -1
  117. data/lib/lingara/models/usage.rb +1 -1
  118. data/lib/lingara/models/usage_ledger.rb +1 -1
  119. data/lib/lingara/models/usage_threshold_reached_data.rb +1 -1
  120. data/lib/lingara/models/version_detail.rb +1 -1
  121. data/lib/lingara/models/version_history_entry.rb +1 -1
  122. data/lib/lingara/models/version_list.rb +1 -1
  123. data/lib/lingara/models/version_spec.rb +1 -1
  124. data/lib/lingara/models/version_state.rb +1 -1
  125. data/lib/lingara/models/version_summary.rb +1 -1
  126. data/lib/lingara/models/vocab_example.rb +1 -1
  127. data/lib/lingara/models/vocab_item.rb +1 -1
  128. data/lib/lingara/models/vocab_meta.rb +1 -1
  129. data/lib/lingara/models/vocab_request.rb +1 -1
  130. data/lib/lingara/models/vocab_started.rb +1 -1
  131. data/lib/lingara/models/world_context_changed.rb +1 -1
  132. data/lib/lingara/models/world_practice_completed.rb +1 -1
  133. data/lib/lingara/models/world_practice_requested.rb +1 -1
  134. data/lib/lingara/operations.rb +127 -1
  135. data/lib/lingara/streams.rb +1 -0
  136. data/lib/lingara/version.rb +3 -3
  137. data/lib/lingara.rb +2 -0
  138. data/sig/lingara.rbs +50 -0
  139. metadata +46 -2
@@ -0,0 +1,511 @@
1
+ =begin
2
+ #Lingara API
3
+
4
+ #Generate vocabulary lists and lesson plans, and hold tutor conversations, in the languages Lingara teaches. Each call is paid for by the client that makes it: an `allowance` client spends its owner's allowance, and a `metered` client is billed for its usage.
5
+
6
+ The version of the OpenAPI document: 2026-10-simple-tarpon
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.14.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Lingara
17
+ class CanvasSummary
18
+ attr_accessor :id
19
+
20
+ attr_accessor :name
21
+
22
+ attr_accessor :recipe
23
+
24
+ attr_accessor :created_at
25
+
26
+ attr_accessor :updated_at
27
+
28
+ attr_accessor :has_draft
29
+
30
+ attr_accessor :active_revision
31
+
32
+ attr_accessor :node_count
33
+
34
+ attr_accessor :node_kinds
35
+
36
+ attr_accessor :scopes
37
+
38
+ attr_accessor :objects
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'id' => :'id',
66
+ :'name' => :'name',
67
+ :'recipe' => :'recipe',
68
+ :'created_at' => :'created_at',
69
+ :'updated_at' => :'updated_at',
70
+ :'has_draft' => :'has_draft',
71
+ :'active_revision' => :'active_revision',
72
+ :'node_count' => :'node_count',
73
+ :'node_kinds' => :'node_kinds',
74
+ :'scopes' => :'scopes',
75
+ :'objects' => :'objects'
76
+ }
77
+ end
78
+
79
+ # Returns attribute mapping this model knows about
80
+ def self.acceptable_attribute_map
81
+ attribute_map
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ acceptable_attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.openapi_types
91
+ {
92
+ :'id' => :'String',
93
+ :'name' => :'String',
94
+ :'recipe' => :'CanvasRecipe',
95
+ :'created_at' => :'Time',
96
+ :'updated_at' => :'Time',
97
+ :'has_draft' => :'Boolean',
98
+ :'active_revision' => :'Integer',
99
+ :'node_count' => :'Integer',
100
+ :'node_kinds' => :'Array<CanvasNodeKind>',
101
+ :'scopes' => :'Array<String>',
102
+ :'objects' => :'Array<CanvasMadeObject>'
103
+ }
104
+ end
105
+
106
+ # List of attributes with nullable: true
107
+ def self.openapi_nullable
108
+ Set.new([
109
+ :'active_revision',
110
+ ])
111
+ end
112
+
113
+ # Initializes the object
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ def initialize(attributes = {})
116
+ if (!attributes.is_a?(Hash))
117
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::CanvasSummary` initialize method"
118
+ end
119
+
120
+ # check to see if the attribute exists and convert string to symbol for hash key
121
+ acceptable_attribute_map = self.class.acceptable_attribute_map
122
+ attributes = attributes.each_with_object({}) { |(k, v), h|
123
+ if (!acceptable_attribute_map.key?(k.to_sym))
124
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::CanvasSummary`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
125
+ end
126
+ h[k.to_sym] = v
127
+ }
128
+
129
+ if attributes.key?(:'id')
130
+ self.id = attributes[:'id']
131
+ else
132
+ self.id = nil
133
+ end
134
+
135
+ if attributes.key?(:'name')
136
+ self.name = attributes[:'name']
137
+ else
138
+ self.name = nil
139
+ end
140
+
141
+ if attributes.key?(:'recipe')
142
+ self.recipe = attributes[:'recipe']
143
+ else
144
+ self.recipe = nil
145
+ end
146
+
147
+ if attributes.key?(:'created_at')
148
+ self.created_at = attributes[:'created_at']
149
+ else
150
+ self.created_at = nil
151
+ end
152
+
153
+ if attributes.key?(:'updated_at')
154
+ self.updated_at = attributes[:'updated_at']
155
+ else
156
+ self.updated_at = nil
157
+ end
158
+
159
+ if attributes.key?(:'has_draft')
160
+ self.has_draft = attributes[:'has_draft']
161
+ else
162
+ self.has_draft = nil
163
+ end
164
+
165
+ if attributes.key?(:'active_revision')
166
+ self.active_revision = attributes[:'active_revision']
167
+ else
168
+ self.active_revision = nil
169
+ end
170
+
171
+ if attributes.key?(:'node_count')
172
+ self.node_count = attributes[:'node_count']
173
+ else
174
+ self.node_count = nil
175
+ end
176
+
177
+ if attributes.key?(:'node_kinds')
178
+ if (value = attributes[:'node_kinds']).is_a?(Array)
179
+ self.node_kinds = value
180
+ end
181
+ else
182
+ self.node_kinds = nil
183
+ end
184
+
185
+ if attributes.key?(:'scopes')
186
+ if (value = attributes[:'scopes']).is_a?(Array)
187
+ self.scopes = value
188
+ end
189
+ else
190
+ self.scopes = nil
191
+ end
192
+
193
+ if attributes.key?(:'objects')
194
+ if (value = attributes[:'objects']).is_a?(Array)
195
+ self.objects = value
196
+ end
197
+ else
198
+ self.objects = nil
199
+ end
200
+ end
201
+
202
+ # Show invalid properties with the reasons. Usually used together with valid?
203
+ # @return Array for valid properties with the reasons
204
+ def list_invalid_properties
205
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
206
+ invalid_properties = Array.new
207
+ if @id.nil?
208
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
209
+ end
210
+
211
+ if @name.nil?
212
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
213
+ end
214
+
215
+ if @recipe.nil?
216
+ invalid_properties.push('invalid value for "recipe", recipe cannot be nil.')
217
+ end
218
+
219
+ if @created_at.nil?
220
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
221
+ end
222
+
223
+ if @updated_at.nil?
224
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
225
+ end
226
+
227
+ if @has_draft.nil?
228
+ invalid_properties.push('invalid value for "has_draft", has_draft cannot be nil.')
229
+ end
230
+
231
+ if @node_count.nil?
232
+ invalid_properties.push('invalid value for "node_count", node_count cannot be nil.')
233
+ end
234
+
235
+ if @node_kinds.nil?
236
+ invalid_properties.push('invalid value for "node_kinds", node_kinds cannot be nil.')
237
+ end
238
+
239
+ if @scopes.nil?
240
+ invalid_properties.push('invalid value for "scopes", scopes cannot be nil.')
241
+ end
242
+
243
+ if @objects.nil?
244
+ invalid_properties.push('invalid value for "objects", objects cannot be nil.')
245
+ end
246
+
247
+ invalid_properties
248
+ end
249
+
250
+ # Check to see if the all the properties in the model are valid
251
+ # @return true if the model is valid
252
+ def valid?
253
+ warn '[DEPRECATED] the `valid?` method is obsolete'
254
+ return false if @id.nil?
255
+ return false if @name.nil?
256
+ return false if @recipe.nil?
257
+ return false if @created_at.nil?
258
+ return false if @updated_at.nil?
259
+ return false if @has_draft.nil?
260
+ return false if @node_count.nil?
261
+ return false if @node_kinds.nil?
262
+ return false if @scopes.nil?
263
+ return false if @objects.nil?
264
+ true
265
+ end
266
+
267
+ # Custom attribute writer method with validation
268
+ # @param [Object] id Value to be assigned
269
+ def id=(id)
270
+ if id.nil?
271
+ fail ArgumentError, 'id cannot be nil'
272
+ end
273
+
274
+ @id = id
275
+ end
276
+
277
+ # Custom attribute writer method with validation
278
+ # @param [Object] name Value to be assigned
279
+ def name=(name)
280
+ if name.nil?
281
+ fail ArgumentError, 'name cannot be nil'
282
+ end
283
+
284
+ @name = name
285
+ end
286
+
287
+ # Custom attribute writer method with validation
288
+ # @param [Object] recipe Value to be assigned
289
+ def recipe=(recipe)
290
+ if recipe.nil?
291
+ fail ArgumentError, 'recipe cannot be nil'
292
+ end
293
+
294
+ @recipe = recipe
295
+ end
296
+
297
+ # Custom attribute writer method with validation
298
+ # @param [Object] created_at Value to be assigned
299
+ def created_at=(created_at)
300
+ if created_at.nil?
301
+ fail ArgumentError, 'created_at cannot be nil'
302
+ end
303
+
304
+ @created_at = created_at
305
+ end
306
+
307
+ # Custom attribute writer method with validation
308
+ # @param [Object] updated_at Value to be assigned
309
+ def updated_at=(updated_at)
310
+ if updated_at.nil?
311
+ fail ArgumentError, 'updated_at cannot be nil'
312
+ end
313
+
314
+ @updated_at = updated_at
315
+ end
316
+
317
+ # Custom attribute writer method with validation
318
+ # @param [Object] has_draft Value to be assigned
319
+ def has_draft=(has_draft)
320
+ if has_draft.nil?
321
+ fail ArgumentError, 'has_draft cannot be nil'
322
+ end
323
+
324
+ @has_draft = has_draft
325
+ end
326
+
327
+ # Custom attribute writer method with validation
328
+ # @param [Object] node_count Value to be assigned
329
+ def node_count=(node_count)
330
+ if node_count.nil?
331
+ fail ArgumentError, 'node_count cannot be nil'
332
+ end
333
+
334
+ @node_count = node_count
335
+ end
336
+
337
+ # Custom attribute writer method with validation
338
+ # @param [Object] node_kinds Value to be assigned
339
+ def node_kinds=(node_kinds)
340
+ if node_kinds.nil?
341
+ fail ArgumentError, 'node_kinds cannot be nil'
342
+ end
343
+
344
+ @node_kinds = node_kinds
345
+ end
346
+
347
+ # Custom attribute writer method with validation
348
+ # @param [Object] scopes Value to be assigned
349
+ def scopes=(scopes)
350
+ if scopes.nil?
351
+ fail ArgumentError, 'scopes cannot be nil'
352
+ end
353
+
354
+ @scopes = scopes
355
+ end
356
+
357
+ # Custom attribute writer method with validation
358
+ # @param [Object] objects Value to be assigned
359
+ def objects=(objects)
360
+ if objects.nil?
361
+ fail ArgumentError, 'objects cannot be nil'
362
+ end
363
+
364
+ @objects = objects
365
+ end
366
+
367
+ # Checks equality by comparing each attribute.
368
+ # @param [Object] Object to be compared
369
+ def ==(o)
370
+ return true if self.equal?(o)
371
+ self.class == o.class &&
372
+ id == o.id &&
373
+ name == o.name &&
374
+ recipe == o.recipe &&
375
+ created_at == o.created_at &&
376
+ updated_at == o.updated_at &&
377
+ has_draft == o.has_draft &&
378
+ active_revision == o.active_revision &&
379
+ node_count == o.node_count &&
380
+ node_kinds == o.node_kinds &&
381
+ scopes == o.scopes &&
382
+ objects == o.objects
383
+ end
384
+
385
+ # @see the `==` method
386
+ # @param [Object] Object to be compared
387
+ def eql?(o)
388
+ self == o
389
+ end
390
+
391
+ # Calculates hash code according to all attributes.
392
+ # @return [Integer] Hash code
393
+ def hash
394
+ [id, name, recipe, created_at, updated_at, has_draft, active_revision, node_count, node_kinds, scopes, objects].hash
395
+ end
396
+
397
+ # Builds the object from hash
398
+ # @param [Hash] attributes Model attributes in the form of hash
399
+ # @return [Object] Returns the model itself
400
+ def self.build_from_hash(attributes)
401
+ return nil unless attributes.is_a?(Hash)
402
+ attributes = attributes.transform_keys(&:to_sym)
403
+ transformed_hash = {}
404
+ openapi_types.each_pair do |key, type|
405
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
406
+ transformed_hash["#{key}"] = nil
407
+ elsif type =~ /\AArray<(.*)>/i
408
+ # check to ensure the input is an array given that the attribute
409
+ # is documented as an array but the input is not
410
+ if attributes[attribute_map[key]].is_a?(Array)
411
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
412
+ end
413
+ elsif !attributes[attribute_map[key]].nil?
414
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
415
+ end
416
+ end
417
+ new(transformed_hash)
418
+ end
419
+
420
+ # Deserializes the data based on type
421
+ # @param string type Data type
422
+ # @param string value Value to be deserialized
423
+ # @return [Object] Deserialized data
424
+ def self._deserialize(type, value)
425
+ case type.to_sym
426
+ when :Time
427
+ Time.parse(value)
428
+ when :Date
429
+ Date.parse(value)
430
+ when :String
431
+ value.to_s
432
+ when :Integer
433
+ value.to_i
434
+ when :Float
435
+ value.to_f
436
+ when :Boolean
437
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
438
+ true
439
+ else
440
+ false
441
+ end
442
+ when :Object
443
+ # generic object (usually a Hash), return directly
444
+ value
445
+ when /\AArray<(?<inner_type>.+)>\z/
446
+ inner_type = Regexp.last_match[:inner_type]
447
+ value.map { |v| _deserialize(inner_type, v) }
448
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
449
+ k_type = Regexp.last_match[:k_type]
450
+ v_type = Regexp.last_match[:v_type]
451
+ {}.tap do |hash|
452
+ value.each do |k, v|
453
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
454
+ end
455
+ end
456
+ else # model
457
+ # models (e.g. Pet) or oneOf
458
+ klass = Lingara.const_get(type)
459
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
460
+ end
461
+ end
462
+
463
+ # Returns the string representation of the object
464
+ # @return [String] String presentation of the object
465
+ def to_s
466
+ to_hash.to_s
467
+ end
468
+
469
+ # to_body is an alias to to_hash (backward compatibility)
470
+ # @return [Hash] Returns the object in the form of hash
471
+ def to_body
472
+ to_hash
473
+ end
474
+
475
+ # Returns the object in the form of hash
476
+ # @return [Hash] Returns the object in the form of hash
477
+ def to_hash
478
+ hash = {}
479
+ self.class.attribute_map.each_pair do |attr, param|
480
+ value = self.send(attr)
481
+ if value.nil?
482
+ is_nullable = self.class.openapi_nullable.include?(attr)
483
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
484
+ end
485
+
486
+ hash[param] = _to_hash(value)
487
+ end
488
+ hash
489
+ end
490
+
491
+ # Outputs non-array value in the form of hash
492
+ # For object, use to_hash. Otherwise, just return the value
493
+ # @param [Object] value Any valid value
494
+ # @return [Hash] Returns the value in the form of hash
495
+ def _to_hash(value)
496
+ if value.is_a?(Array)
497
+ value.compact.map { |v| _to_hash(v) }
498
+ elsif value.is_a?(Hash)
499
+ {}.tap do |hash|
500
+ value.each { |k, v| hash[k] = _to_hash(v) }
501
+ end
502
+ elsif value.respond_to? :to_hash
503
+ value.to_hash
504
+ else
505
+ value
506
+ end
507
+ end
508
+
509
+ end
510
+
511
+ end