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,323 @@
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
+ # A canvas: its nodes and the edges between them. `fields` is the editor's own state; the dry-run, not this schema, judges content.
18
+ class CanvasDefinition
19
+ attr_accessor :schema
20
+
21
+ attr_accessor :nodes
22
+
23
+ attr_accessor :edges
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'schema' => :'schema',
29
+ :'nodes' => :'nodes',
30
+ :'edges' => :'edges'
31
+ }
32
+ end
33
+
34
+ # Returns attribute mapping this model knows about
35
+ def self.acceptable_attribute_map
36
+ attribute_map
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ acceptable_attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'schema' => :'Integer',
48
+ :'nodes' => :'Array<CanvasNode>',
49
+ :'edges' => :'Array<CanvasEdge>'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::CanvasDefinition` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ acceptable_attribute_map = self.class.acceptable_attribute_map
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!acceptable_attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::CanvasDefinition`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'schema')
76
+ self.schema = attributes[:'schema']
77
+ else
78
+ self.schema = nil
79
+ end
80
+
81
+ if attributes.key?(:'nodes')
82
+ if (value = attributes[:'nodes']).is_a?(Array)
83
+ self.nodes = value
84
+ end
85
+ else
86
+ self.nodes = nil
87
+ end
88
+
89
+ if attributes.key?(:'edges')
90
+ if (value = attributes[:'edges']).is_a?(Array)
91
+ self.edges = value
92
+ end
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
100
+ invalid_properties = Array.new
101
+ if @schema.nil?
102
+ invalid_properties.push('invalid value for "schema", schema cannot be nil.')
103
+ end
104
+
105
+ if @schema > 32767
106
+ invalid_properties.push('invalid value for "schema", must be smaller than or equal to 32767.')
107
+ end
108
+
109
+ if @schema < 1
110
+ invalid_properties.push('invalid value for "schema", must be greater than or equal to 1.')
111
+ end
112
+
113
+ if @nodes.nil?
114
+ invalid_properties.push('invalid value for "nodes", nodes cannot be nil.')
115
+ end
116
+
117
+ if @nodes.length > 32
118
+ invalid_properties.push('invalid value for "nodes", number of items must be less than or equal to 32.')
119
+ end
120
+
121
+ if !@edges.nil? && @edges.length > 64
122
+ invalid_properties.push('invalid value for "edges", number of items must be less than or equal to 64.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ warn '[DEPRECATED] the `valid?` method is obsolete'
132
+ return false if @schema.nil?
133
+ return false if @schema > 32767
134
+ return false if @schema < 1
135
+ return false if @nodes.nil?
136
+ return false if @nodes.length > 32
137
+ return false if !@edges.nil? && @edges.length > 64
138
+ true
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] schema Value to be assigned
143
+ def schema=(schema)
144
+ if schema.nil?
145
+ fail ArgumentError, 'schema cannot be nil'
146
+ end
147
+
148
+ if schema > 32767
149
+ fail ArgumentError, 'invalid value for "schema", must be smaller than or equal to 32767.'
150
+ end
151
+
152
+ if schema < 1
153
+ fail ArgumentError, 'invalid value for "schema", must be greater than or equal to 1.'
154
+ end
155
+
156
+ @schema = schema
157
+ end
158
+
159
+ # Custom attribute writer method with validation
160
+ # @param [Object] nodes Value to be assigned
161
+ def nodes=(nodes)
162
+ if nodes.nil?
163
+ fail ArgumentError, 'nodes cannot be nil'
164
+ end
165
+
166
+ if nodes.length > 32
167
+ fail ArgumentError, 'invalid value for "nodes", number of items must be less than or equal to 32.'
168
+ end
169
+
170
+ @nodes = nodes
171
+ end
172
+
173
+ # Custom attribute writer method with validation
174
+ # @param [Object] edges Value to be assigned
175
+ def edges=(edges)
176
+ if edges.nil?
177
+ fail ArgumentError, 'edges cannot be nil'
178
+ end
179
+
180
+ if edges.length > 64
181
+ fail ArgumentError, 'invalid value for "edges", number of items must be less than or equal to 64.'
182
+ end
183
+
184
+ @edges = edges
185
+ end
186
+
187
+ # Checks equality by comparing each attribute.
188
+ # @param [Object] Object to be compared
189
+ def ==(o)
190
+ return true if self.equal?(o)
191
+ self.class == o.class &&
192
+ schema == o.schema &&
193
+ nodes == o.nodes &&
194
+ edges == o.edges
195
+ end
196
+
197
+ # @see the `==` method
198
+ # @param [Object] Object to be compared
199
+ def eql?(o)
200
+ self == o
201
+ end
202
+
203
+ # Calculates hash code according to all attributes.
204
+ # @return [Integer] Hash code
205
+ def hash
206
+ [schema, nodes, edges].hash
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def self.build_from_hash(attributes)
213
+ return nil unless attributes.is_a?(Hash)
214
+ attributes = attributes.transform_keys(&:to_sym)
215
+ transformed_hash = {}
216
+ openapi_types.each_pair do |key, type|
217
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
218
+ transformed_hash["#{key}"] = nil
219
+ elsif type =~ /\AArray<(.*)>/i
220
+ # check to ensure the input is an array given that the attribute
221
+ # is documented as an array but the input is not
222
+ if attributes[attribute_map[key]].is_a?(Array)
223
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
224
+ end
225
+ elsif !attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
227
+ end
228
+ end
229
+ new(transformed_hash)
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def self._deserialize(type, value)
237
+ case type.to_sym
238
+ when :Time
239
+ Time.parse(value)
240
+ when :Date
241
+ Date.parse(value)
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :Boolean
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ # models (e.g. Pet) or oneOf
270
+ klass = Lingara.const_get(type)
271
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
272
+ end
273
+ end
274
+
275
+ # Returns the string representation of the object
276
+ # @return [String] String presentation of the object
277
+ def to_s
278
+ to_hash.to_s
279
+ end
280
+
281
+ # to_body is an alias to to_hash (backward compatibility)
282
+ # @return [Hash] Returns the object in the form of hash
283
+ def to_body
284
+ to_hash
285
+ end
286
+
287
+ # Returns the object in the form of hash
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_hash
290
+ hash = {}
291
+ self.class.attribute_map.each_pair do |attr, param|
292
+ value = self.send(attr)
293
+ if value.nil?
294
+ is_nullable = self.class.openapi_nullable.include?(attr)
295
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
296
+ end
297
+
298
+ hash[param] = _to_hash(value)
299
+ end
300
+ hash
301
+ end
302
+
303
+ # Outputs non-array value in the form of hash
304
+ # For object, use to_hash. Otherwise, just return the value
305
+ # @param [Object] value Any valid value
306
+ # @return [Hash] Returns the value in the form of hash
307
+ def _to_hash(value)
308
+ if value.is_a?(Array)
309
+ value.compact.map { |v| _to_hash(v) }
310
+ elsif value.is_a?(Hash)
311
+ {}.tap do |hash|
312
+ value.each { |k, v| hash[k] = _to_hash(v) }
313
+ end
314
+ elsif value.respond_to? :to_hash
315
+ value.to_hash
316
+ else
317
+ value
318
+ end
319
+ end
320
+
321
+ end
322
+
323
+ end
@@ -0,0 +1,317 @@
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 CanvasDraft
18
+ attr_accessor :revision
19
+
20
+ attr_accessor :draft_version
21
+
22
+ attr_accessor :definition
23
+
24
+ attr_accessor :objects
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'revision' => :'revision',
30
+ :'draft_version' => :'draft_version',
31
+ :'definition' => :'definition',
32
+ :'objects' => :'objects'
33
+ }
34
+ end
35
+
36
+ # Returns attribute mapping this model knows about
37
+ def self.acceptable_attribute_map
38
+ attribute_map
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ acceptable_attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'revision' => :'Integer',
50
+ :'draft_version' => :'Integer',
51
+ :'definition' => :'CanvasDefinition',
52
+ :'objects' => :'Hash<String, CanvasObjectRef>'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::CanvasDraft` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ acceptable_attribute_map = self.class.acceptable_attribute_map
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!acceptable_attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::CanvasDraft`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'revision')
79
+ self.revision = attributes[:'revision']
80
+ else
81
+ self.revision = nil
82
+ end
83
+
84
+ if attributes.key?(:'draft_version')
85
+ self.draft_version = attributes[:'draft_version']
86
+ else
87
+ self.draft_version = nil
88
+ end
89
+
90
+ if attributes.key?(:'definition')
91
+ self.definition = attributes[:'definition']
92
+ else
93
+ self.definition = nil
94
+ end
95
+
96
+ if attributes.key?(:'objects')
97
+ if (value = attributes[:'objects']).is_a?(Hash)
98
+ self.objects = value
99
+ end
100
+ else
101
+ self.objects = nil
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
109
+ invalid_properties = Array.new
110
+ if @revision.nil?
111
+ invalid_properties.push('invalid value for "revision", revision cannot be nil.')
112
+ end
113
+
114
+ if @draft_version.nil?
115
+ invalid_properties.push('invalid value for "draft_version", draft_version cannot be nil.')
116
+ end
117
+
118
+ if @definition.nil?
119
+ invalid_properties.push('invalid value for "definition", definition cannot be nil.')
120
+ end
121
+
122
+ if @objects.nil?
123
+ invalid_properties.push('invalid value for "objects", objects cannot be nil.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ warn '[DEPRECATED] the `valid?` method is obsolete'
133
+ return false if @revision.nil?
134
+ return false if @draft_version.nil?
135
+ return false if @definition.nil?
136
+ return false if @objects.nil?
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method with validation
141
+ # @param [Object] revision Value to be assigned
142
+ def revision=(revision)
143
+ if revision.nil?
144
+ fail ArgumentError, 'revision cannot be nil'
145
+ end
146
+
147
+ @revision = revision
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] draft_version Value to be assigned
152
+ def draft_version=(draft_version)
153
+ if draft_version.nil?
154
+ fail ArgumentError, 'draft_version cannot be nil'
155
+ end
156
+
157
+ @draft_version = draft_version
158
+ end
159
+
160
+ # Custom attribute writer method with validation
161
+ # @param [Object] definition Value to be assigned
162
+ def definition=(definition)
163
+ if definition.nil?
164
+ fail ArgumentError, 'definition cannot be nil'
165
+ end
166
+
167
+ @definition = definition
168
+ end
169
+
170
+ # Custom attribute writer method with validation
171
+ # @param [Object] objects Value to be assigned
172
+ def objects=(objects)
173
+ if objects.nil?
174
+ fail ArgumentError, 'objects cannot be nil'
175
+ end
176
+
177
+ @objects = objects
178
+ end
179
+
180
+ # Checks equality by comparing each attribute.
181
+ # @param [Object] Object to be compared
182
+ def ==(o)
183
+ return true if self.equal?(o)
184
+ self.class == o.class &&
185
+ revision == o.revision &&
186
+ draft_version == o.draft_version &&
187
+ definition == o.definition &&
188
+ objects == o.objects
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [revision, draft_version, definition, objects].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ return nil unless attributes.is_a?(Hash)
208
+ attributes = attributes.transform_keys(&:to_sym)
209
+ transformed_hash = {}
210
+ openapi_types.each_pair do |key, type|
211
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
212
+ transformed_hash["#{key}"] = nil
213
+ elsif type =~ /\AArray<(.*)>/i
214
+ # check to ensure the input is an array given that the attribute
215
+ # is documented as an array but the input is not
216
+ if attributes[attribute_map[key]].is_a?(Array)
217
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
218
+ end
219
+ elsif !attributes[attribute_map[key]].nil?
220
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
221
+ end
222
+ end
223
+ new(transformed_hash)
224
+ end
225
+
226
+ # Deserializes the data based on type
227
+ # @param string type Data type
228
+ # @param string value Value to be deserialized
229
+ # @return [Object] Deserialized data
230
+ def self._deserialize(type, value)
231
+ case type.to_sym
232
+ when :Time
233
+ Time.parse(value)
234
+ when :Date
235
+ Date.parse(value)
236
+ when :String
237
+ value.to_s
238
+ when :Integer
239
+ value.to_i
240
+ when :Float
241
+ value.to_f
242
+ when :Boolean
243
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
244
+ true
245
+ else
246
+ false
247
+ end
248
+ when :Object
249
+ # generic object (usually a Hash), return directly
250
+ value
251
+ when /\AArray<(?<inner_type>.+)>\z/
252
+ inner_type = Regexp.last_match[:inner_type]
253
+ value.map { |v| _deserialize(inner_type, v) }
254
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
255
+ k_type = Regexp.last_match[:k_type]
256
+ v_type = Regexp.last_match[:v_type]
257
+ {}.tap do |hash|
258
+ value.each do |k, v|
259
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
260
+ end
261
+ end
262
+ else # model
263
+ # models (e.g. Pet) or oneOf
264
+ klass = Lingara.const_get(type)
265
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
266
+ end
267
+ end
268
+
269
+ # Returns the string representation of the object
270
+ # @return [String] String presentation of the object
271
+ def to_s
272
+ to_hash.to_s
273
+ end
274
+
275
+ # to_body is an alias to to_hash (backward compatibility)
276
+ # @return [Hash] Returns the object in the form of hash
277
+ def to_body
278
+ to_hash
279
+ end
280
+
281
+ # Returns the object in the form of hash
282
+ # @return [Hash] Returns the object in the form of hash
283
+ def to_hash
284
+ hash = {}
285
+ self.class.attribute_map.each_pair do |attr, param|
286
+ value = self.send(attr)
287
+ if value.nil?
288
+ is_nullable = self.class.openapi_nullable.include?(attr)
289
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
290
+ end
291
+
292
+ hash[param] = _to_hash(value)
293
+ end
294
+ hash
295
+ end
296
+
297
+ # Outputs non-array value in the form of hash
298
+ # For object, use to_hash. Otherwise, just return the value
299
+ # @param [Object] value Any valid value
300
+ # @return [Hash] Returns the value in the form of hash
301
+ def _to_hash(value)
302
+ if value.is_a?(Array)
303
+ value.compact.map { |v| _to_hash(v) }
304
+ elsif value.is_a?(Hash)
305
+ {}.tap do |hash|
306
+ value.each { |k, v| hash[k] = _to_hash(v) }
307
+ end
308
+ elsif value.respond_to? :to_hash
309
+ value.to_hash
310
+ else
311
+ value
312
+ end
313
+ end
314
+
315
+ end
316
+
317
+ end