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,43 @@
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 CanvasNodeKind
18
+ CLIENT = "client".freeze
19
+ SECRET = "secret".freeze
20
+ WEBHOOK = "webhook".freeze
21
+ APP = "app".freeze
22
+ UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
23
+
24
+ def self.all_vars
25
+ @all_vars ||= [CLIENT, SECRET, WEBHOOK, APP, UNKNOWN_DEFAULT_OPEN_API].freeze
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def self.build_from_hash(value)
32
+ new.build_from_hash(value)
33
+ end
34
+
35
+ # Builds the enum from string
36
+ # @param [String] The enum value in the form of the string
37
+ # @return [String] The enum value
38
+ def build_from_hash(value)
39
+ return value if CanvasNodeKind.all_vars.include?(value)
40
+ raise "Invalid ENUM value #{value} for class #CanvasNodeKind"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,237 @@
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 CanvasObjectRef
18
+ attr_accessor :id
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'id' => :'id'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'id' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::CanvasObjectRef` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::CanvasObjectRef`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'id')
67
+ self.id = attributes[:'id']
68
+ else
69
+ self.id = nil
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
77
+ invalid_properties = Array.new
78
+ if @id.nil?
79
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
80
+ end
81
+
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ warn '[DEPRECATED] the `valid?` method is obsolete'
89
+ return false if @id.nil?
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method with validation
94
+ # @param [Object] id Value to be assigned
95
+ def id=(id)
96
+ if id.nil?
97
+ fail ArgumentError, 'id cannot be nil'
98
+ end
99
+
100
+ @id = id
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ id == o.id
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [id].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ openapi_types.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
138
+ end
139
+ elsif !attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
141
+ end
142
+ end
143
+ new(transformed_hash)
144
+ end
145
+
146
+ # Deserializes the data based on type
147
+ # @param string type Data type
148
+ # @param string value Value to be deserialized
149
+ # @return [Object] Deserialized data
150
+ def self._deserialize(type, value)
151
+ case type.to_sym
152
+ when :Time
153
+ Time.parse(value)
154
+ when :Date
155
+ Date.parse(value)
156
+ when :String
157
+ value.to_s
158
+ when :Integer
159
+ value.to_i
160
+ when :Float
161
+ value.to_f
162
+ when :Boolean
163
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
164
+ true
165
+ else
166
+ false
167
+ end
168
+ when :Object
169
+ # generic object (usually a Hash), return directly
170
+ value
171
+ when /\AArray<(?<inner_type>.+)>\z/
172
+ inner_type = Regexp.last_match[:inner_type]
173
+ value.map { |v| _deserialize(inner_type, v) }
174
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
+ k_type = Regexp.last_match[:k_type]
176
+ v_type = Regexp.last_match[:v_type]
177
+ {}.tap do |hash|
178
+ value.each do |k, v|
179
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
+ end
181
+ end
182
+ else # model
183
+ # models (e.g. Pet) or oneOf
184
+ klass = Lingara.const_get(type)
185
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+
235
+ end
236
+
237
+ end
@@ -0,0 +1,289 @@
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 CanvasPage
18
+ attr_accessor :items
19
+
20
+ attr_accessor :total
21
+
22
+ attr_accessor :next_cursor
23
+
24
+ attr_accessor :has_more
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'items' => :'items',
30
+ :'total' => :'total',
31
+ :'next_cursor' => :'next_cursor',
32
+ :'has_more' => :'has_more'
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
+ :'items' => :'Array<CanvasSummary>',
50
+ :'total' => :'Integer',
51
+ :'next_cursor' => :'String',
52
+ :'has_more' => :'Boolean'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ :'total',
60
+ :'next_cursor',
61
+ ])
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ if (!attributes.is_a?(Hash))
68
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::CanvasPage` initialize method"
69
+ end
70
+
71
+ # check to see if the attribute exists and convert string to symbol for hash key
72
+ acceptable_attribute_map = self.class.acceptable_attribute_map
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!acceptable_attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::CanvasPage`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'items')
81
+ if (value = attributes[:'items']).is_a?(Array)
82
+ self.items = value
83
+ end
84
+ else
85
+ self.items = nil
86
+ end
87
+
88
+ if attributes.key?(:'total')
89
+ self.total = attributes[:'total']
90
+ else
91
+ self.total = nil
92
+ end
93
+
94
+ if attributes.key?(:'next_cursor')
95
+ self.next_cursor = attributes[:'next_cursor']
96
+ else
97
+ self.next_cursor = nil
98
+ end
99
+
100
+ if attributes.key?(:'has_more')
101
+ self.has_more = attributes[:'has_more']
102
+ else
103
+ self.has_more = nil
104
+ end
105
+ end
106
+
107
+ # Show invalid properties with the reasons. Usually used together with valid?
108
+ # @return Array for valid properties with the reasons
109
+ def list_invalid_properties
110
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
111
+ invalid_properties = Array.new
112
+ if @items.nil?
113
+ invalid_properties.push('invalid value for "items", items cannot be nil.')
114
+ end
115
+
116
+ if @has_more.nil?
117
+ invalid_properties.push('invalid value for "has_more", has_more cannot be nil.')
118
+ end
119
+
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ warn '[DEPRECATED] the `valid?` method is obsolete'
127
+ return false if @items.nil?
128
+ return false if @has_more.nil?
129
+ true
130
+ end
131
+
132
+ # Custom attribute writer method with validation
133
+ # @param [Object] items Value to be assigned
134
+ def items=(items)
135
+ if items.nil?
136
+ fail ArgumentError, 'items cannot be nil'
137
+ end
138
+
139
+ @items = items
140
+ end
141
+
142
+ # Custom attribute writer method with validation
143
+ # @param [Object] has_more Value to be assigned
144
+ def has_more=(has_more)
145
+ if has_more.nil?
146
+ fail ArgumentError, 'has_more cannot be nil'
147
+ end
148
+
149
+ @has_more = has_more
150
+ end
151
+
152
+ # Checks equality by comparing each attribute.
153
+ # @param [Object] Object to be compared
154
+ def ==(o)
155
+ return true if self.equal?(o)
156
+ self.class == o.class &&
157
+ items == o.items &&
158
+ total == o.total &&
159
+ next_cursor == o.next_cursor &&
160
+ has_more == o.has_more
161
+ end
162
+
163
+ # @see the `==` method
164
+ # @param [Object] Object to be compared
165
+ def eql?(o)
166
+ self == o
167
+ end
168
+
169
+ # Calculates hash code according to all attributes.
170
+ # @return [Integer] Hash code
171
+ def hash
172
+ [items, total, next_cursor, has_more].hash
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def self.build_from_hash(attributes)
179
+ return nil unless attributes.is_a?(Hash)
180
+ attributes = attributes.transform_keys(&:to_sym)
181
+ transformed_hash = {}
182
+ openapi_types.each_pair do |key, type|
183
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
184
+ transformed_hash["#{key}"] = nil
185
+ elsif type =~ /\AArray<(.*)>/i
186
+ # check to ensure the input is an array given that the attribute
187
+ # is documented as an array but the input is not
188
+ if attributes[attribute_map[key]].is_a?(Array)
189
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
190
+ end
191
+ elsif !attributes[attribute_map[key]].nil?
192
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
193
+ end
194
+ end
195
+ new(transformed_hash)
196
+ end
197
+
198
+ # Deserializes the data based on type
199
+ # @param string type Data type
200
+ # @param string value Value to be deserialized
201
+ # @return [Object] Deserialized data
202
+ def self._deserialize(type, value)
203
+ case type.to_sym
204
+ when :Time
205
+ Time.parse(value)
206
+ when :Date
207
+ Date.parse(value)
208
+ when :String
209
+ value.to_s
210
+ when :Integer
211
+ value.to_i
212
+ when :Float
213
+ value.to_f
214
+ when :Boolean
215
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
216
+ true
217
+ else
218
+ false
219
+ end
220
+ when :Object
221
+ # generic object (usually a Hash), return directly
222
+ value
223
+ when /\AArray<(?<inner_type>.+)>\z/
224
+ inner_type = Regexp.last_match[:inner_type]
225
+ value.map { |v| _deserialize(inner_type, v) }
226
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
+ k_type = Regexp.last_match[:k_type]
228
+ v_type = Regexp.last_match[:v_type]
229
+ {}.tap do |hash|
230
+ value.each do |k, v|
231
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
232
+ end
233
+ end
234
+ else # model
235
+ # models (e.g. Pet) or oneOf
236
+ klass = Lingara.const_get(type)
237
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
238
+ end
239
+ end
240
+
241
+ # Returns the string representation of the object
242
+ # @return [String] String presentation of the object
243
+ def to_s
244
+ to_hash.to_s
245
+ end
246
+
247
+ # to_body is an alias to to_hash (backward compatibility)
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_body
250
+ to_hash
251
+ end
252
+
253
+ # Returns the object in the form of hash
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_hash
256
+ hash = {}
257
+ self.class.attribute_map.each_pair do |attr, param|
258
+ value = self.send(attr)
259
+ if value.nil?
260
+ is_nullable = self.class.openapi_nullable.include?(attr)
261
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
262
+ end
263
+
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map { |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end
286
+
287
+ end
288
+
289
+ end
@@ -0,0 +1,105 @@
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
+ module CanvasParam
18
+ class << self
19
+ # List of class defined in anyOf (OpenAPI v3)
20
+ def openapi_any_of
21
+ [
22
+ :'Boolean',
23
+ :'Float',
24
+ :'String'
25
+ ]
26
+ end
27
+
28
+ # Builds the object
29
+ # @param [Mixed] Data to be matched against the list of anyOf items
30
+ # @return [Object] Returns the model or the data itself
31
+ def build(data)
32
+ # Go through the list of anyOf items and attempt to identify the appropriate one.
33
+ # Note:
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_any_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_any_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.iso8601(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = Lingara.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_any_of) # nested anyOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end