lingara 0.1.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 (69) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +142 -0
  4. data/lib/lingara/access_token.rb +47 -0
  5. data/lib/lingara/client.rb +182 -0
  6. data/lib/lingara/client_credentials.rb +176 -0
  7. data/lib/lingara/deprecation.rb +128 -0
  8. data/lib/lingara/errors.rb +162 -0
  9. data/lib/lingara/event_stream.rb +135 -0
  10. data/lib/lingara/models/allowance_row.rb +378 -0
  11. data/lib/lingara/models/create_lesson_plan_event_error.rb +287 -0
  12. data/lib/lingara/models/create_lesson_plan_event_phase.rb +287 -0
  13. data/lib/lingara/models/create_lesson_plan_event_result.rb +287 -0
  14. data/lib/lingara/models/create_lesson_plan_event_started.rb +287 -0
  15. data/lib/lingara/models/error_envelope.rb +264 -0
  16. data/lib/lingara/models/generate_vocabulary_event_done.rb +287 -0
  17. data/lib/lingara/models/generate_vocabulary_event_error.rb +287 -0
  18. data/lib/lingara/models/generate_vocabulary_event_item.rb +287 -0
  19. data/lib/lingara/models/generate_vocabulary_event_started.rb +287 -0
  20. data/lib/lingara/models/lesson_plan.rb +463 -0
  21. data/lib/lingara/models/lesson_plan_content.rb +305 -0
  22. data/lib/lingara/models/lesson_plan_create_request.rb +333 -0
  23. data/lib/lingara/models/notice.rb +263 -0
  24. data/lib/lingara/models/plan_pending.rb +285 -0
  25. data/lib/lingara/models/plan_phase.rb +281 -0
  26. data/lib/lingara/models/plan_question.rb +337 -0
  27. data/lib/lingara/models/plan_result.rb +237 -0
  28. data/lib/lingara/models/plan_set.rb +293 -0
  29. data/lib/lingara/models/plan_started.rb +237 -0
  30. data/lib/lingara/models/plan_status.rb +42 -0
  31. data/lib/lingara/models/plan_word.rb +273 -0
  32. data/lib/lingara/models/send_tutor_message_event_delta.rb +287 -0
  33. data/lib/lingara/models/send_tutor_message_event_done.rb +287 -0
  34. data/lib/lingara/models/send_tutor_message_event_error.rb +287 -0
  35. data/lib/lingara/models/send_tutor_message_event_notice.rb +287 -0
  36. data/lib/lingara/models/stream_error.rb +273 -0
  37. data/lib/lingara/models/stream_lesson_plan_event_error.rb +287 -0
  38. data/lib/lingara/models/stream_lesson_plan_event_pending.rb +287 -0
  39. data/lib/lingara/models/stream_lesson_plan_event_phase.rb +287 -0
  40. data/lib/lingara/models/stream_lesson_plan_event_result.rb +287 -0
  41. data/lib/lingara/models/stream_lesson_plan_event_started.rb +287 -0
  42. data/lib/lingara/models/turn_delta.rb +237 -0
  43. data/lib/lingara/models/turn_entry.rb +285 -0
  44. data/lib/lingara/models/turn_role.rb +41 -0
  45. data/lib/lingara/models/tutor_turn_request.rb +354 -0
  46. data/lib/lingara/models/usage.rb +250 -0
  47. data/lib/lingara/models/usage_ledger.rb +307 -0
  48. data/lib/lingara/models/version_detail.rb +415 -0
  49. data/lib/lingara/models/version_history_entry.rb +285 -0
  50. data/lib/lingara/models/version_list.rb +263 -0
  51. data/lib/lingara/models/version_spec.rb +249 -0
  52. data/lib/lingara/models/version_state.rb +44 -0
  53. data/lib/lingara/models/version_summary.rb +349 -0
  54. data/lib/lingara/models/vocab_example.rb +263 -0
  55. data/lib/lingara/models/vocab_item.rb +303 -0
  56. data/lib/lingara/models/vocab_meta.rb +394 -0
  57. data/lib/lingara/models/vocab_request.rb +341 -0
  58. data/lib/lingara/models/vocab_started.rb +237 -0
  59. data/lib/lingara/operations.rb +91 -0
  60. data/lib/lingara/response.rb +46 -0
  61. data/lib/lingara/retry.rb +88 -0
  62. data/lib/lingara/sse_decoder.rb +80 -0
  63. data/lib/lingara/streams.rb +104 -0
  64. data/lib/lingara/transport.rb +131 -0
  65. data/lib/lingara/user_agent.rb +24 -0
  66. data/lib/lingara/version.rb +13 -0
  67. data/lib/lingara.rb +23 -0
  68. data/sig/lingara.rbs +151 -0
  69. metadata +114 -0
@@ -0,0 +1,463 @@
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-09-glowing-hoatzin
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 LessonPlan
18
+ attr_accessor :id
19
+
20
+ attr_accessor :status
21
+
22
+ attr_accessor :title
23
+
24
+ attr_accessor :source_lang
25
+
26
+ attr_accessor :target_lang
27
+
28
+ attr_accessor :level
29
+
30
+ attr_accessor :created_at
31
+
32
+ attr_accessor :completed_at
33
+
34
+ attr_accessor :ai_generated
35
+
36
+ attr_accessor :content
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'id' => :'id',
64
+ :'status' => :'status',
65
+ :'title' => :'title',
66
+ :'source_lang' => :'source_lang',
67
+ :'target_lang' => :'target_lang',
68
+ :'level' => :'level',
69
+ :'created_at' => :'created_at',
70
+ :'completed_at' => :'completed_at',
71
+ :'ai_generated' => :'ai_generated',
72
+ :'content' => :'content'
73
+ }
74
+ end
75
+
76
+ # Returns attribute mapping this model knows about
77
+ def self.acceptable_attribute_map
78
+ attribute_map
79
+ end
80
+
81
+ # Returns all the JSON keys this model knows about
82
+ def self.acceptable_attributes
83
+ acceptable_attribute_map.values
84
+ end
85
+
86
+ # Attribute type mapping.
87
+ def self.openapi_types
88
+ {
89
+ :'id' => :'String',
90
+ :'status' => :'PlanStatus',
91
+ :'title' => :'String',
92
+ :'source_lang' => :'String',
93
+ :'target_lang' => :'String',
94
+ :'level' => :'Integer',
95
+ :'created_at' => :'Time',
96
+ :'completed_at' => :'Time',
97
+ :'ai_generated' => :'Boolean',
98
+ :'content' => :'LessonPlanContent'
99
+ }
100
+ end
101
+
102
+ # List of attributes with nullable: true
103
+ def self.openapi_nullable
104
+ Set.new([
105
+ :'title',
106
+ :'completed_at',
107
+ :'content'
108
+ ])
109
+ end
110
+
111
+ # Initializes the object
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ def initialize(attributes = {})
114
+ if (!attributes.is_a?(Hash))
115
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::LessonPlan` initialize method"
116
+ end
117
+
118
+ # check to see if the attribute exists and convert string to symbol for hash key
119
+ acceptable_attribute_map = self.class.acceptable_attribute_map
120
+ attributes = attributes.each_with_object({}) { |(k, v), h|
121
+ if (!acceptable_attribute_map.key?(k.to_sym))
122
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::LessonPlan`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
123
+ end
124
+ h[k.to_sym] = v
125
+ }
126
+
127
+ if attributes.key?(:'id')
128
+ self.id = attributes[:'id']
129
+ else
130
+ self.id = nil
131
+ end
132
+
133
+ if attributes.key?(:'status')
134
+ self.status = attributes[:'status']
135
+ else
136
+ self.status = nil
137
+ end
138
+
139
+ if attributes.key?(:'title')
140
+ self.title = attributes[:'title']
141
+ end
142
+
143
+ if attributes.key?(:'source_lang')
144
+ self.source_lang = attributes[:'source_lang']
145
+ else
146
+ self.source_lang = nil
147
+ end
148
+
149
+ if attributes.key?(:'target_lang')
150
+ self.target_lang = attributes[:'target_lang']
151
+ else
152
+ self.target_lang = nil
153
+ end
154
+
155
+ if attributes.key?(:'level')
156
+ self.level = attributes[:'level']
157
+ else
158
+ self.level = nil
159
+ end
160
+
161
+ if attributes.key?(:'created_at')
162
+ self.created_at = attributes[:'created_at']
163
+ else
164
+ self.created_at = nil
165
+ end
166
+
167
+ if attributes.key?(:'completed_at')
168
+ self.completed_at = attributes[:'completed_at']
169
+ end
170
+
171
+ if attributes.key?(:'ai_generated')
172
+ self.ai_generated = attributes[:'ai_generated']
173
+ else
174
+ self.ai_generated = nil
175
+ end
176
+
177
+ if attributes.key?(:'content')
178
+ self.content = attributes[:'content']
179
+ end
180
+ end
181
+
182
+ # Show invalid properties with the reasons. Usually used together with valid?
183
+ # @return Array for valid properties with the reasons
184
+ def list_invalid_properties
185
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
186
+ invalid_properties = Array.new
187
+ if @id.nil?
188
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
189
+ end
190
+
191
+ if @status.nil?
192
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
193
+ end
194
+
195
+ if @source_lang.nil?
196
+ invalid_properties.push('invalid value for "source_lang", source_lang cannot be nil.')
197
+ end
198
+
199
+ if @target_lang.nil?
200
+ invalid_properties.push('invalid value for "target_lang", target_lang cannot be nil.')
201
+ end
202
+
203
+ if @level.nil?
204
+ invalid_properties.push('invalid value for "level", level cannot be nil.')
205
+ end
206
+
207
+ if @level > 255
208
+ invalid_properties.push('invalid value for "level", must be smaller than or equal to 255.')
209
+ end
210
+
211
+ if @level < 0
212
+ invalid_properties.push('invalid value for "level", must be greater than or equal to 0.')
213
+ end
214
+
215
+ if @created_at.nil?
216
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
217
+ end
218
+
219
+ if @ai_generated.nil?
220
+ invalid_properties.push('invalid value for "ai_generated", ai_generated cannot be nil.')
221
+ end
222
+
223
+ invalid_properties
224
+ end
225
+
226
+ # Check to see if the all the properties in the model are valid
227
+ # @return true if the model is valid
228
+ def valid?
229
+ warn '[DEPRECATED] the `valid?` method is obsolete'
230
+ return false if @id.nil?
231
+ return false if @status.nil?
232
+ return false if @source_lang.nil?
233
+ return false if @target_lang.nil?
234
+ return false if @level.nil?
235
+ return false if @level > 255
236
+ return false if @level < 0
237
+ return false if @created_at.nil?
238
+ return false if @ai_generated.nil?
239
+ true
240
+ end
241
+
242
+ # Custom attribute writer method with validation
243
+ # @param [Object] id Value to be assigned
244
+ def id=(id)
245
+ if id.nil?
246
+ fail ArgumentError, 'id cannot be nil'
247
+ end
248
+
249
+ @id = id
250
+ end
251
+
252
+ # Custom attribute writer method with validation
253
+ # @param [Object] status Value to be assigned
254
+ def status=(status)
255
+ if status.nil?
256
+ fail ArgumentError, 'status cannot be nil'
257
+ end
258
+
259
+ @status = status
260
+ end
261
+
262
+ # Custom attribute writer method with validation
263
+ # @param [Object] source_lang Value to be assigned
264
+ def source_lang=(source_lang)
265
+ if source_lang.nil?
266
+ fail ArgumentError, 'source_lang cannot be nil'
267
+ end
268
+
269
+ @source_lang = source_lang
270
+ end
271
+
272
+ # Custom attribute writer method with validation
273
+ # @param [Object] target_lang Value to be assigned
274
+ def target_lang=(target_lang)
275
+ if target_lang.nil?
276
+ fail ArgumentError, 'target_lang cannot be nil'
277
+ end
278
+
279
+ @target_lang = target_lang
280
+ end
281
+
282
+ # Custom attribute writer method with validation
283
+ # @param [Object] level Value to be assigned
284
+ def level=(level)
285
+ if level.nil?
286
+ fail ArgumentError, 'level cannot be nil'
287
+ end
288
+
289
+ if level > 255
290
+ fail ArgumentError, 'invalid value for "level", must be smaller than or equal to 255.'
291
+ end
292
+
293
+ if level < 0
294
+ fail ArgumentError, 'invalid value for "level", must be greater than or equal to 0.'
295
+ end
296
+
297
+ @level = level
298
+ end
299
+
300
+ # Custom attribute writer method with validation
301
+ # @param [Object] created_at Value to be assigned
302
+ def created_at=(created_at)
303
+ if created_at.nil?
304
+ fail ArgumentError, 'created_at cannot be nil'
305
+ end
306
+
307
+ @created_at = created_at
308
+ end
309
+
310
+ # Custom attribute writer method with validation
311
+ # @param [Object] ai_generated Value to be assigned
312
+ def ai_generated=(ai_generated)
313
+ if ai_generated.nil?
314
+ fail ArgumentError, 'ai_generated cannot be nil'
315
+ end
316
+
317
+ @ai_generated = ai_generated
318
+ end
319
+
320
+ # Checks equality by comparing each attribute.
321
+ # @param [Object] Object to be compared
322
+ def ==(o)
323
+ return true if self.equal?(o)
324
+ self.class == o.class &&
325
+ id == o.id &&
326
+ status == o.status &&
327
+ title == o.title &&
328
+ source_lang == o.source_lang &&
329
+ target_lang == o.target_lang &&
330
+ level == o.level &&
331
+ created_at == o.created_at &&
332
+ completed_at == o.completed_at &&
333
+ ai_generated == o.ai_generated &&
334
+ content == o.content
335
+ end
336
+
337
+ # @see the `==` method
338
+ # @param [Object] Object to be compared
339
+ def eql?(o)
340
+ self == o
341
+ end
342
+
343
+ # Calculates hash code according to all attributes.
344
+ # @return [Integer] Hash code
345
+ def hash
346
+ [id, status, title, source_lang, target_lang, level, created_at, completed_at, ai_generated, content].hash
347
+ end
348
+
349
+ # Builds the object from hash
350
+ # @param [Hash] attributes Model attributes in the form of hash
351
+ # @return [Object] Returns the model itself
352
+ def self.build_from_hash(attributes)
353
+ return nil unless attributes.is_a?(Hash)
354
+ attributes = attributes.transform_keys(&:to_sym)
355
+ transformed_hash = {}
356
+ openapi_types.each_pair do |key, type|
357
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
358
+ transformed_hash["#{key}"] = nil
359
+ elsif type =~ /\AArray<(.*)>/i
360
+ # check to ensure the input is an array given that the attribute
361
+ # is documented as an array but the input is not
362
+ if attributes[attribute_map[key]].is_a?(Array)
363
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
364
+ end
365
+ elsif !attributes[attribute_map[key]].nil?
366
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
367
+ end
368
+ end
369
+ new(transformed_hash)
370
+ end
371
+
372
+ # Deserializes the data based on type
373
+ # @param string type Data type
374
+ # @param string value Value to be deserialized
375
+ # @return [Object] Deserialized data
376
+ def self._deserialize(type, value)
377
+ case type.to_sym
378
+ when :Time
379
+ Time.parse(value)
380
+ when :Date
381
+ Date.parse(value)
382
+ when :String
383
+ value.to_s
384
+ when :Integer
385
+ value.to_i
386
+ when :Float
387
+ value.to_f
388
+ when :Boolean
389
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
390
+ true
391
+ else
392
+ false
393
+ end
394
+ when :Object
395
+ # generic object (usually a Hash), return directly
396
+ value
397
+ when /\AArray<(?<inner_type>.+)>\z/
398
+ inner_type = Regexp.last_match[:inner_type]
399
+ value.map { |v| _deserialize(inner_type, v) }
400
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
401
+ k_type = Regexp.last_match[:k_type]
402
+ v_type = Regexp.last_match[:v_type]
403
+ {}.tap do |hash|
404
+ value.each do |k, v|
405
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
406
+ end
407
+ end
408
+ else # model
409
+ # models (e.g. Pet) or oneOf
410
+ klass = Lingara.const_get(type)
411
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
412
+ end
413
+ end
414
+
415
+ # Returns the string representation of the object
416
+ # @return [String] String presentation of the object
417
+ def to_s
418
+ to_hash.to_s
419
+ end
420
+
421
+ # to_body is an alias to to_hash (backward compatibility)
422
+ # @return [Hash] Returns the object in the form of hash
423
+ def to_body
424
+ to_hash
425
+ end
426
+
427
+ # Returns the object in the form of hash
428
+ # @return [Hash] Returns the object in the form of hash
429
+ def to_hash
430
+ hash = {}
431
+ self.class.attribute_map.each_pair do |attr, param|
432
+ value = self.send(attr)
433
+ if value.nil?
434
+ is_nullable = self.class.openapi_nullable.include?(attr)
435
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
436
+ end
437
+
438
+ hash[param] = _to_hash(value)
439
+ end
440
+ hash
441
+ end
442
+
443
+ # Outputs non-array value in the form of hash
444
+ # For object, use to_hash. Otherwise, just return the value
445
+ # @param [Object] value Any valid value
446
+ # @return [Hash] Returns the value in the form of hash
447
+ def _to_hash(value)
448
+ if value.is_a?(Array)
449
+ value.compact.map { |v| _to_hash(v) }
450
+ elsif value.is_a?(Hash)
451
+ {}.tap do |hash|
452
+ value.each { |k, v| hash[k] = _to_hash(v) }
453
+ end
454
+ elsif value.respond_to? :to_hash
455
+ value.to_hash
456
+ else
457
+ value
458
+ end
459
+ end
460
+
461
+ end
462
+
463
+ end