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