// <auto-generated/>
// ReSharper disable All

namespace MyTelegram.Schema;

///<summary>
/// A pending <a href="https://corefork.telegram.org/api/transcribe">voice message transcription »</a> initiated with <a href="https://corefork.telegram.org/method/messages.transcribeAudio">messages.transcribeAudio</a> was updated.
/// See <a href="https://corefork.telegram.org/constructor/updateTranscribedAudio" />
///</summary>
[TlObject(0x84cd5a)]
public sealed class TUpdateTranscribedAudio : IUpdate
{
    public uint ConstructorId => 0x84cd5a;
    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags { get; set; }

    ///<summary>
    /// Whether this transcription is still pending and further <a href="https://corefork.telegram.org/constructor/updateTranscribedAudio">updateTranscribedAudio</a> about it will be sent in the future.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Pending { get; set; }

    ///<summary>
    /// Peer of the transcribed message
    /// See <a href="https://corefork.telegram.org/type/Peer" />
    ///</summary>
    public MyTelegram.Schema.IPeer Peer { get; set; }

    ///<summary>
    /// Transcribed message ID
    ///</summary>
    public int MsgId { get; set; }

    ///<summary>
    /// Transcription ID
    ///</summary>
    public long TranscriptionId { get; set; }

    ///<summary>
    /// Transcribed text
    ///</summary>
    public string Text { get; set; }

    public void ComputeFlag()
    {
        if (Pending) { Flags = Flags.SetBit(0); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Peer);
        writer.Write(MsgId);
        writer.Write(TranscriptionId);
        writer.Write(Text);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Pending = true; }
        Peer = buffer.Read<MyTelegram.Schema.IPeer>();
        MsgId = buffer.ReadInt32();
        TranscriptionId = buffer.ReadInt64();
        Text = buffer.ReadString();
    }
}