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

namespace MyTelegram.Schema;

///<summary>
/// Info on members is unavailable
/// See <a href="https://corefork.telegram.org/constructor/chatParticipantsForbidden" />
///</summary>
[TlObject(0x8763d3e1)]
public sealed class TChatParticipantsForbidden : IChatParticipants
{
    public uint ConstructorId => 0x8763d3e1;
    ///<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>
    /// Group ID
    ///</summary>
    public long ChatId { get; set; }

    ///<summary>
    /// Info about the group membership of the current user
    /// See <a href="https://corefork.telegram.org/type/ChatParticipant" />
    ///</summary>
    public MyTelegram.Schema.IChatParticipant? SelfParticipant { get; set; }

    public void ComputeFlag()
    {
        if (SelfParticipant != null) { Flags = Flags.SetBit(0); }
    }

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

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