lingara 0.1.0.pre.alpha.13 → 0.2.0.pre.alpha.1

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -2
  3. data/lib/lingara/client.rb +59 -10
  4. data/lib/lingara/events/catalogue.rb +20 -2
  5. data/lib/lingara/minted_token.rb +73 -0
  6. data/lib/lingara/models/allowance_row.rb +1 -1
  7. data/lib/lingara/models/app_context_slice.rb +1 -1
  8. data/lib/lingara/models/app_disabled_data.rb +263 -0
  9. data/lib/lingara/models/app_enabled_data.rb +263 -0
  10. data/lib/lingara/models/app_installed_data.rb +1 -1
  11. data/lib/lingara/models/app_uninstalled_data.rb +1 -1
  12. data/lib/lingara/models/create_lesson_plan_event_error.rb +1 -1
  13. data/lib/lingara/models/create_lesson_plan_event_phase.rb +1 -1
  14. data/lib/lingara/models/create_lesson_plan_event_result.rb +1 -1
  15. data/lib/lingara/models/create_lesson_plan_event_started.rb +1 -1
  16. data/lib/lingara/models/dialogue_entry.rb +303 -0
  17. data/lib/lingara/models/dialogue_turn_request.rb +442 -0
  18. data/lib/lingara/models/embed_token.rb +379 -0
  19. data/lib/lingara/models/embed_token_request.rb +331 -0
  20. data/lib/lingara/models/error_envelope.rb +1 -1
  21. data/lib/lingara/models/event_envelope.rb +1 -1
  22. data/lib/lingara/models/event_page.rb +1 -1
  23. data/lib/lingara/models/generate_vocabulary_event_done.rb +1 -1
  24. data/lib/lingara/models/generate_vocabulary_event_error.rb +1 -1
  25. data/lib/lingara/models/generate_vocabulary_event_item.rb +1 -1
  26. data/lib/lingara/models/generate_vocabulary_event_started.rb +1 -1
  27. data/lib/lingara/models/inbound_event_accepted.rb +1 -1
  28. data/lib/lingara/models/lesson_plan.rb +1 -1
  29. data/lib/lingara/models/lesson_plan_content.rb +1 -1
  30. data/lib/lingara/models/lesson_plan_create_request.rb +1 -1
  31. data/lib/lingara/models/lesson_plan_failed_data.rb +1 -1
  32. data/lib/lingara/models/lesson_plan_ready_data.rb +1 -1
  33. data/lib/lingara/models/notice.rb +1 -1
  34. data/lib/lingara/models/npc.rb +1 -1
  35. data/lib/lingara/models/plan_fail_reason.rb +1 -1
  36. data/lib/lingara/models/plan_pending.rb +1 -1
  37. data/lib/lingara/models/plan_phase.rb +1 -1
  38. data/lib/lingara/models/plan_question.rb +1 -1
  39. data/lib/lingara/models/plan_ready_status.rb +1 -1
  40. data/lib/lingara/models/plan_result.rb +1 -1
  41. data/lib/lingara/models/plan_set.rb +1 -1
  42. data/lib/lingara/models/plan_started.rb +1 -1
  43. data/lib/lingara/models/plan_status.rb +1 -1
  44. data/lib/lingara/models/plan_word.rb +1 -1
  45. data/lib/lingara/models/practice_completed_data.rb +291 -0
  46. data/lib/lingara/models/practice_item.rb +347 -0
  47. data/lib/lingara/models/practice_outcome.rb +45 -0
  48. data/lib/lingara/models/reaction_report.rb +1 -1
  49. data/lib/lingara/models/reaction_status.rb +1 -1
  50. data/lib/lingara/models/send_dialogue_turn_event_delta.rb +287 -0
  51. data/lib/lingara/models/send_dialogue_turn_event_done.rb +287 -0
  52. data/lib/lingara/models/send_dialogue_turn_event_error.rb +287 -0
  53. data/lib/lingara/models/send_dialogue_turn_event_notice.rb +287 -0
  54. data/lib/lingara/models/send_tutor_message_event_delta.rb +1 -1
  55. data/lib/lingara/models/send_tutor_message_event_done.rb +1 -1
  56. data/lib/lingara/models/send_tutor_message_event_error.rb +1 -1
  57. data/lib/lingara/models/send_tutor_message_event_notice.rb +1 -1
  58. data/lib/lingara/models/speaker.rb +41 -0
  59. data/lib/lingara/models/stream_error.rb +1 -1
  60. data/lib/lingara/models/stream_events_event_done.rb +1 -1
  61. data/lib/lingara/models/stream_events_event_error.rb +1 -1
  62. data/lib/lingara/models/stream_events_event_event.rb +1 -1
  63. data/lib/lingara/models/stream_lesson_plan_event_error.rb +1 -1
  64. data/lib/lingara/models/stream_lesson_plan_event_pending.rb +1 -1
  65. data/lib/lingara/models/stream_lesson_plan_event_phase.rb +1 -1
  66. data/lib/lingara/models/stream_lesson_plan_event_result.rb +1 -1
  67. data/lib/lingara/models/stream_lesson_plan_event_started.rb +1 -1
  68. data/lib/lingara/models/threshold_scope.rb +1 -1
  69. data/lib/lingara/models/turn_delta.rb +1 -1
  70. data/lib/lingara/models/turn_entry.rb +1 -1
  71. data/lib/lingara/models/turn_role.rb +1 -1
  72. data/lib/lingara/models/tutor_turn_request.rb +1 -1
  73. data/lib/lingara/models/usage.rb +1 -1
  74. data/lib/lingara/models/usage_ledger.rb +1 -1
  75. data/lib/lingara/models/usage_threshold_reached_data.rb +1 -1
  76. data/lib/lingara/models/version_detail.rb +1 -1
  77. data/lib/lingara/models/version_history_entry.rb +1 -1
  78. data/lib/lingara/models/version_list.rb +1 -1
  79. data/lib/lingara/models/version_spec.rb +1 -1
  80. data/lib/lingara/models/version_state.rb +1 -1
  81. data/lib/lingara/models/version_summary.rb +1 -1
  82. data/lib/lingara/models/vocab_example.rb +1 -1
  83. data/lib/lingara/models/vocab_item.rb +1 -1
  84. data/lib/lingara/models/vocab_meta.rb +1 -1
  85. data/lib/lingara/models/vocab_request.rb +1 -1
  86. data/lib/lingara/models/vocab_started.rb +1 -1
  87. data/lib/lingara/models/world_context_changed.rb +1 -1
  88. data/lib/lingara/models/world_practice_completed.rb +294 -0
  89. data/lib/lingara/models/world_practice_requested.rb +1 -1
  90. data/lib/lingara/operations.rb +27 -0
  91. data/lib/lingara/streams.rb +25 -0
  92. data/lib/lingara/version.rb +3 -3
  93. data/lib/lingara.rb +1 -0
  94. data/sig/lingara.rbs +33 -0
  95. metadata +18 -2
@@ -0,0 +1,263 @@
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-golden-remora
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 AppEnabledData
18
+ attr_accessor :client_id
19
+
20
+ attr_accessor :install_id
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'client_id' => :'client_id',
26
+ :'install_id' => :'install_id'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'client_id' => :'String',
44
+ :'install_id' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::AppEnabledData` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::AppEnabledData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'client_id')
71
+ self.client_id = attributes[:'client_id']
72
+ else
73
+ self.client_id = nil
74
+ end
75
+
76
+ if attributes.key?(:'install_id')
77
+ self.install_id = attributes[:'install_id']
78
+ else
79
+ self.install_id = nil
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ invalid_properties = Array.new
88
+ if @client_id.nil?
89
+ invalid_properties.push('invalid value for "client_id", client_id cannot be nil.')
90
+ end
91
+
92
+ if @install_id.nil?
93
+ invalid_properties.push('invalid value for "install_id", install_id cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if @client_id.nil?
104
+ return false if @install_id.nil?
105
+ true
106
+ end
107
+
108
+ # Custom attribute writer method with validation
109
+ # @param [Object] client_id Value to be assigned
110
+ def client_id=(client_id)
111
+ if client_id.nil?
112
+ fail ArgumentError, 'client_id cannot be nil'
113
+ end
114
+
115
+ @client_id = client_id
116
+ end
117
+
118
+ # Custom attribute writer method with validation
119
+ # @param [Object] install_id Value to be assigned
120
+ def install_id=(install_id)
121
+ if install_id.nil?
122
+ fail ArgumentError, 'install_id cannot be nil'
123
+ end
124
+
125
+ @install_id = install_id
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ client_id == o.client_id &&
134
+ install_id == o.install_id
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [client_id, install_id].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[attribute_map[key]].is_a?(Array)
163
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ end
165
+ elsif !attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ end
168
+ end
169
+ new(transformed_hash)
170
+ end
171
+
172
+ # Deserializes the data based on type
173
+ # @param string type Data type
174
+ # @param string value Value to be deserialized
175
+ # @return [Object] Deserialized data
176
+ def self._deserialize(type, value)
177
+ case type.to_sym
178
+ when :Time
179
+ Time.parse(value)
180
+ when :Date
181
+ Date.parse(value)
182
+ when :String
183
+ value.to_s
184
+ when :Integer
185
+ value.to_i
186
+ when :Float
187
+ value.to_f
188
+ when :Boolean
189
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
+ true
191
+ else
192
+ false
193
+ end
194
+ when :Object
195
+ # generic object (usually a Hash), return directly
196
+ value
197
+ when /\AArray<(?<inner_type>.+)>\z/
198
+ inner_type = Regexp.last_match[:inner_type]
199
+ value.map { |v| _deserialize(inner_type, v) }
200
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
+ k_type = Regexp.last_match[:k_type]
202
+ v_type = Regexp.last_match[:v_type]
203
+ {}.tap do |hash|
204
+ value.each do |k, v|
205
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
+ end
207
+ end
208
+ else # model
209
+ # models (e.g. Pet) or oneOf
210
+ klass = Lingara.const_get(type)
211
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ # Returns the object in the form of hash
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_hash
230
+ hash = {}
231
+ self.class.attribute_map.each_pair do |attr, param|
232
+ value = self.send(attr)
233
+ if value.nil?
234
+ is_nullable = self.class.openapi_nullable.include?(attr)
235
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
236
+ end
237
+
238
+ hash[param] = _to_hash(value)
239
+ end
240
+ hash
241
+ end
242
+
243
+ # Outputs non-array value in the form of hash
244
+ # For object, use to_hash. Otherwise, just return the value
245
+ # @param [Object] value Any valid value
246
+ # @return [Hash] Returns the value in the form of hash
247
+ def _to_hash(value)
248
+ if value.is_a?(Array)
249
+ value.compact.map { |v| _to_hash(v) }
250
+ elsif value.is_a?(Hash)
251
+ {}.tap do |hash|
252
+ value.each { |k, v| hash[k] = _to_hash(v) }
253
+ end
254
+ elsif value.respond_to? :to_hash
255
+ value.to_hash
256
+ else
257
+ value
258
+ end
259
+ end
260
+
261
+ end
262
+
263
+ end
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 2026-10-affable-towhee
6
+ The version of the OpenAPI document: 2026-10-golden-remora
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.14.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 2026-10-affable-towhee
6
+ The version of the OpenAPI document: 2026-10-golden-remora
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.14.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 2026-10-affable-towhee
6
+ The version of the OpenAPI document: 2026-10-golden-remora
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.14.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 2026-10-affable-towhee
6
+ The version of the OpenAPI document: 2026-10-golden-remora
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.14.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 2026-10-affable-towhee
6
+ The version of the OpenAPI document: 2026-10-golden-remora
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.14.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 2026-10-affable-towhee
6
+ The version of the OpenAPI document: 2026-10-golden-remora
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.14.0
@@ -0,0 +1,303 @@
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-golden-remora
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 DialogueEntry
18
+ attr_accessor :speaker
19
+
20
+ attr_accessor :text
21
+
22
+ class EnumAttributeValidator
23
+ attr_reader :datatype
24
+ attr_reader :allowable_values
25
+
26
+ def initialize(datatype, allowable_values)
27
+ @allowable_values = allowable_values.map do |value|
28
+ case datatype.to_s
29
+ when /Integer/i
30
+ value.to_i
31
+ when /Float/i
32
+ value.to_f
33
+ else
34
+ value
35
+ end
36
+ end
37
+ end
38
+
39
+ def valid?(value)
40
+ !value || allowable_values.include?(value)
41
+ end
42
+ end
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'speaker' => :'speaker',
48
+ :'text' => :'text'
49
+ }
50
+ end
51
+
52
+ # Returns attribute mapping this model knows about
53
+ def self.acceptable_attribute_map
54
+ attribute_map
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ acceptable_attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'speaker' => :'Speaker',
66
+ :'text' => :'String'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lingara::DialogueEntry` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ acceptable_attribute_map = self.class.acceptable_attribute_map
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!acceptable_attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lingara::DialogueEntry`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'speaker')
93
+ self.speaker = attributes[:'speaker']
94
+ else
95
+ self.speaker = nil
96
+ end
97
+
98
+ if attributes.key?(:'text')
99
+ self.text = attributes[:'text']
100
+ else
101
+ self.text = 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 @speaker.nil?
111
+ invalid_properties.push('invalid value for "speaker", speaker cannot be nil.')
112
+ end
113
+
114
+ if @text.nil?
115
+ invalid_properties.push('invalid value for "text", text cannot be nil.')
116
+ end
117
+
118
+ if @text.to_s.length > 500
119
+ invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 500.')
120
+ end
121
+
122
+ if @text.to_s.length < 1
123
+ invalid_properties.push('invalid value for "text", the character length must be greater than or equal to 1.')
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 @speaker.nil?
134
+ return false if @text.nil?
135
+ return false if @text.to_s.length > 500
136
+ return false if @text.to_s.length < 1
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method with validation
141
+ # @param [Object] speaker Value to be assigned
142
+ def speaker=(speaker)
143
+ if speaker.nil?
144
+ fail ArgumentError, 'speaker cannot be nil'
145
+ end
146
+
147
+ @speaker = speaker
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] text Value to be assigned
152
+ def text=(text)
153
+ if text.nil?
154
+ fail ArgumentError, 'text cannot be nil'
155
+ end
156
+
157
+ if text.to_s.length > 500
158
+ fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 500.'
159
+ end
160
+
161
+ if text.to_s.length < 1
162
+ fail ArgumentError, 'invalid value for "text", the character length must be greater than or equal to 1.'
163
+ end
164
+
165
+ @text = text
166
+ end
167
+
168
+ # Checks equality by comparing each attribute.
169
+ # @param [Object] Object to be compared
170
+ def ==(o)
171
+ return true if self.equal?(o)
172
+ self.class == o.class &&
173
+ speaker == o.speaker &&
174
+ text == o.text
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Integer] Hash code
185
+ def hash
186
+ [speaker, text].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def self.build_from_hash(attributes)
193
+ return nil unless attributes.is_a?(Hash)
194
+ attributes = attributes.transform_keys(&:to_sym)
195
+ transformed_hash = {}
196
+ openapi_types.each_pair do |key, type|
197
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
198
+ transformed_hash["#{key}"] = nil
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[attribute_map[key]].is_a?(Array)
203
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
204
+ end
205
+ elsif !attributes[attribute_map[key]].nil?
206
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
207
+ end
208
+ end
209
+ new(transformed_hash)
210
+ end
211
+
212
+ # Deserializes the data based on type
213
+ # @param string type Data type
214
+ # @param string value Value to be deserialized
215
+ # @return [Object] Deserialized data
216
+ def self._deserialize(type, value)
217
+ case type.to_sym
218
+ when :Time
219
+ Time.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :String
223
+ value.to_s
224
+ when :Integer
225
+ value.to_i
226
+ when :Float
227
+ value.to_f
228
+ when :Boolean
229
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
+ true
231
+ else
232
+ false
233
+ end
234
+ when :Object
235
+ # generic object (usually a Hash), return directly
236
+ value
237
+ when /\AArray<(?<inner_type>.+)>\z/
238
+ inner_type = Regexp.last_match[:inner_type]
239
+ value.map { |v| _deserialize(inner_type, v) }
240
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
241
+ k_type = Regexp.last_match[:k_type]
242
+ v_type = Regexp.last_match[:v_type]
243
+ {}.tap do |hash|
244
+ value.each do |k, v|
245
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
246
+ end
247
+ end
248
+ else # model
249
+ # models (e.g. Pet) or oneOf
250
+ klass = Lingara.const_get(type)
251
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
252
+ end
253
+ end
254
+
255
+ # Returns the string representation of the object
256
+ # @return [String] String presentation of the object
257
+ def to_s
258
+ to_hash.to_s
259
+ end
260
+
261
+ # to_body is an alias to to_hash (backward compatibility)
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_body
264
+ to_hash
265
+ end
266
+
267
+ # Returns the object in the form of hash
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_hash
270
+ hash = {}
271
+ self.class.attribute_map.each_pair do |attr, param|
272
+ value = self.send(attr)
273
+ if value.nil?
274
+ is_nullable = self.class.openapi_nullable.include?(attr)
275
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
276
+ end
277
+
278
+ hash[param] = _to_hash(value)
279
+ end
280
+ hash
281
+ end
282
+
283
+ # Outputs non-array value in the form of hash
284
+ # For object, use to_hash. Otherwise, just return the value
285
+ # @param [Object] value Any valid value
286
+ # @return [Hash] Returns the value in the form of hash
287
+ def _to_hash(value)
288
+ if value.is_a?(Array)
289
+ value.compact.map { |v| _to_hash(v) }
290
+ elsif value.is_a?(Hash)
291
+ {}.tap do |hash|
292
+ value.each { |k, v| hash[k] = _to_hash(v) }
293
+ end
294
+ elsif value.respond_to? :to_hash
295
+ value.to_hash
296
+ else
297
+ value
298
+ end
299
+ end
300
+
301
+ end
302
+
303
+ end