|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative "transcript_ready_status" |
| 4 | +require "json" |
| 5 | + |
| 6 | +module AssemblyAI |
| 7 | + class Transcripts |
| 8 | + # The notification when the transcript status is completed or error. |
| 9 | + class TranscriptReadyNotification |
| 10 | + attr_reader :transcript_id, :status, :additional_properties |
| 11 | + |
| 12 | + # @param transcript_id [String] The ID of the transcript |
| 13 | + # @param status [Transcripts::TranscriptReadyStatus] The status of the transcript. Either completed or error. |
| 14 | + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition |
| 15 | + # @return [Transcripts::TranscriptReadyNotification] |
| 16 | + def initialize(transcript_id:, status:, additional_properties: nil) |
| 17 | + # @type [String] The ID of the transcript |
| 18 | + @transcript_id = transcript_id |
| 19 | + # @type [Transcripts::TranscriptReadyStatus] The status of the transcript. Either completed or error. |
| 20 | + @status = status |
| 21 | + # @type [OpenStruct] Additional properties unmapped to the current class definition |
| 22 | + @additional_properties = additional_properties |
| 23 | + end |
| 24 | + |
| 25 | + # Deserialize a JSON object to an instance of TranscriptReadyNotification |
| 26 | + # |
| 27 | + # @param json_object [JSON] |
| 28 | + # @return [Transcripts::TranscriptReadyNotification] |
| 29 | + def self.from_json(json_object:) |
| 30 | + struct = JSON.parse(json_object, object_class: OpenStruct) |
| 31 | + JSON.parse(json_object) |
| 32 | + transcript_id = struct.transcript_id |
| 33 | + status = struct.status |
| 34 | + new(transcript_id: transcript_id, status: status, additional_properties: struct) |
| 35 | + end |
| 36 | + |
| 37 | + # Serialize an instance of TranscriptReadyNotification to a JSON object |
| 38 | + # |
| 39 | + # @return [JSON] |
| 40 | + def to_json(*_args) |
| 41 | + { "transcript_id": @transcript_id, "status": @status }.to_json |
| 42 | + end |
| 43 | + |
| 44 | + # 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. |
| 45 | + # |
| 46 | + # @param obj [Object] |
| 47 | + # @return [Void] |
| 48 | + def self.validate_raw(obj:) |
| 49 | + obj.transcript_id.is_a?(String) != false || raise("Passed value for field obj.transcript_id is not the expected type, validation failed.") |
| 50 | + obj.status.is_a?(Transcripts::TranscriptReadyStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") |
| 51 | + end |
| 52 | + end |
| 53 | + end |
| 54 | +end |
0 commit comments