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

namespace MyTelegram.Schema;

///<summary>
/// A new groupcall was started
/// See <a href="https://corefork.telegram.org/constructor/updateGroupCall" />
///</summary>
[TlObject(0x97d64341)]
public sealed class TUpdateGroupCall : IUpdate
{
    public uint ConstructorId => 0x97d64341;
    public int Flags { get; set; }

    ///<summary>
    /// The <a href="https://corefork.telegram.org/api/channel">channel/supergroup</a> where this group call or livestream takes place
    ///</summary>
    public long? ChatId { get; set; }

    ///<summary>
    /// Info about the group call or livestream
    /// See <a href="https://corefork.telegram.org/type/GroupCall" />
    ///</summary>
    public MyTelegram.Schema.IGroupCall Call { get; set; }

    public void ComputeFlag()
    {
        if (/*ChatId != 0 &&*/ ChatId.HasValue) { Flags = Flags.SetBit(0); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        if (Flags.IsBitSet(0)) { writer.Write(ChatId.Value); }
        writer.Write(Call);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { ChatId = buffer.ReadInt64(); }
        Call = buffer.Read<MyTelegram.Schema.IGroupCall>();
    }
}