Class: AssemblyAI::Lemur::LemurQuestionAnswerResponse
- Inherits:
-
Object
- Object
- AssemblyAI::Lemur::LemurQuestionAnswerResponse
- Defined in:
- lib/assemblyai/lemur/types/lemur_question_answer_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#request_id ⇒ String
readonly
The ID of the LeMUR request.
-
#response ⇒ Array<AssemblyAI::Lemur::LemurQuestionAnswer>
readonly
The answers generated by LeMUR and their questions.
-
#usage ⇒ AssemblyAI::Lemur::LemurUsage
readonly
The usage numbers for the LeMUR request.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Lemur::LemurQuestionAnswerResponse
Deserialize a JSON object to an instance of LemurQuestionAnswerResponse.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(response:, request_id:, usage:, additional_properties: nil) ⇒ AssemblyAI::Lemur::LemurQuestionAnswerResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of LemurQuestionAnswerResponse to a JSON object.
Constructor Details
#initialize(response:, request_id:, usage:, additional_properties: nil) ⇒ AssemblyAI::Lemur::LemurQuestionAnswerResponse
30 31 32 33 34 35 36 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 30 def initialize(response:, request_id:, usage:, additional_properties: nil) @response = response @request_id = request_id @usage = usage @additional_properties = additional_properties @_field_set = { "response": response, "request_id": request_id, "usage": usage } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 18 def additional_properties @additional_properties end |
#request_id ⇒ String (readonly)
Returns The ID of the LeMUR request.
14 15 16 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 14 def request_id @request_id end |
#response ⇒ Array<AssemblyAI::Lemur::LemurQuestionAnswer> (readonly)
Returns The answers generated by LeMUR and their questions.
12 13 14 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 12 def response @response end |
#usage ⇒ AssemblyAI::Lemur::LemurUsage (readonly)
Returns The usage numbers for the LeMUR request.
16 17 18 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 16 def usage @usage end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Lemur::LemurQuestionAnswerResponse
Deserialize a JSON object to an instance of LemurQuestionAnswerResponse
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 42 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) response = parsed_json["response"]&.map do |v| v = v.to_json AssemblyAI::Lemur::LemurQuestionAnswer.from_json(json_object: v) end request_id = struct["request_id"] if parsed_json["usage"].nil? usage = nil else usage = parsed_json["usage"].to_json usage = AssemblyAI::Lemur::LemurUsage.from_json(json_object: usage) end new( response: response, request_id: request_id, usage: usage, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
77 78 79 80 81 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 77 def self.validate_raw(obj:) obj.response.is_a?(Array) != false || raise("Passed value for field obj.response is not the expected type, validation failed.") obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.") AssemblyAI::Lemur::LemurUsage.validate_raw(obj: obj.usage) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of LemurQuestionAnswerResponse to a JSON object
67 68 69 |
# File 'lib/assemblyai/lemur/types/lemur_question_answer_response.rb', line 67 def to_json(*_args) @_field_set&.to_json end |