Class: AssemblyAI::Transcripts::TranscriptListItem
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::TranscriptListItem
- Defined in:
- lib/assemblyai/transcripts/types/transcript_list_item.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#audio_url ⇒ String
readonly
The URL to the audio file.
-
#completed ⇒ DateTime
readonly
The date and time the transcript was completed.
-
#created ⇒ DateTime
readonly
The date and time the transcript was created.
-
#error ⇒ String
readonly
Error message of why the transcript failed.
-
#id ⇒ String
readonly
The unique identifier for the transcript.
-
#resource_url ⇒ String
readonly
The URL to retrieve the transcript.
-
#status ⇒ AssemblyAI::Transcripts::TranscriptStatus
readonly
The status of the transcript.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TranscriptListItem
Deserialize a JSON object to an instance of TranscriptListItem.
-
.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(id:, resource_url:, status:, created:, audio_url:, completed: OMIT, error: OMIT, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptListItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TranscriptListItem to a JSON object.
Constructor Details
#initialize(id:, resource_url:, status:, created:, audio_url:, completed: OMIT, error: OMIT, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptListItem
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 42 def initialize(id:, resource_url:, status:, created:, audio_url:, completed: OMIT, error: OMIT, additional_properties: nil) @id = id @resource_url = resource_url @status = status @created = created @completed = completed if completed != OMIT @audio_url = audio_url @error = error if error != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "resource_url": resource_url, "status": status, "created": created, "completed": completed, "audio_url": audio_url, "error": error }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
26 27 28 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 26 def additional_properties @additional_properties end |
#audio_url ⇒ String (readonly)
Returns The URL to the audio file.
22 23 24 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 22 def audio_url @audio_url end |
#completed ⇒ DateTime (readonly)
Returns The date and time the transcript was completed.
20 21 22 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 20 def completed @completed end |
#created ⇒ DateTime (readonly)
Returns The date and time the transcript was created.
18 19 20 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 18 def created @created end |
#error ⇒ String (readonly)
Returns Error message of why the transcript failed.
24 25 26 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 24 def error @error end |
#id ⇒ String (readonly)
Returns The unique identifier for the transcript.
12 13 14 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 12 def id @id end |
#resource_url ⇒ String (readonly)
Returns The URL to retrieve the transcript.
14 15 16 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 14 def resource_url @resource_url end |
#status ⇒ AssemblyAI::Transcripts::TranscriptStatus (readonly)
Returns The status of the transcript.
16 17 18 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 16 def status @status end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TranscriptListItem
Deserialize a JSON object to an instance of TranscriptListItem
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 69 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct["id"] resource_url = struct["resource_url"] status = struct["status"] created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?) completed = (DateTime.parse(parsed_json["completed"]) unless parsed_json["completed"].nil?) audio_url = struct["audio_url"] error = struct["error"] new( id: id, resource_url: resource_url, status: status, created: created, completed: completed, audio_url: audio_url, error: error, 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.
104 105 106 107 108 109 110 111 112 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 104 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.resource_url.is_a?(String) != false || raise("Passed value for field obj.resource_url is not the expected type, validation failed.") obj.status.is_a?(AssemblyAI::Transcripts::TranscriptStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.") obj.completed&.is_a?(DateTime) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.") obj.audio_url.is_a?(String) != false || raise("Passed value for field obj.audio_url is not the expected type, validation failed.") obj.error&.is_a?(String) != false || raise("Passed value for field obj.error is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TranscriptListItem to a JSON object
94 95 96 |
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 94 def to_json(*_args) @_field_set&.to_json end |