Class: AssemblyAI::Transcripts::TranscriptListItem

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/transcripts/types/transcript_list_item.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, resource_url:, status:, created:, audio_url:, completed: OMIT, error: OMIT, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptListItem

Parameters:

  • id (String)

    The unique identifier for the transcript

  • resource_url (String)

    The URL to retrieve the transcript

  • status (AssemblyAI::Transcripts::TranscriptStatus)

    The status of the transcript

  • created (DateTime)

    The date and time the transcript was created

  • completed (DateTime) (defaults to: OMIT)

    The date and time the transcript was completed

  • audio_url (String)

    The URL to the audio file

  • error (String) (defaults to: OMIT)

    Error message of why the transcript failed

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_urlString (readonly)

Returns The URL to the audio file.

Returns:

  • (String)

    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

#completedDateTime (readonly)

Returns The date and time the transcript was completed.

Returns:

  • (DateTime)

    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

#createdDateTime (readonly)

Returns The date and time the transcript was created.

Returns:

  • (DateTime)

    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

#errorString (readonly)

Returns Error message of why the transcript failed.

Returns:

  • (String)

    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

#idString (readonly)

Returns The unique identifier for the transcript.

Returns:

  • (String)

    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_urlString (readonly)

Returns The URL to retrieve the transcript.

Returns:

  • (String)

    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

#statusAssemblyAI::Transcripts::TranscriptStatus (readonly)

Returns The status of the transcript.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


94
95
96
# File 'lib/assemblyai/transcripts/types/transcript_list_item.rb', line 94

def to_json(*_args)
  @_field_set&.to_json
end