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

namespace MyTelegram.Schema;

///<summary>
/// A user joined the <a href="https://corefork.telegram.org/api/channel">supergroup/channel</a> using a specific invite link
/// See <a href="https://corefork.telegram.org/constructor/channelAdminLogEventActionParticipantJoinByInvite" />
///</summary>
[TlObject(0xfe9fc158)]
public sealed class TChannelAdminLogEventActionParticipantJoinByInvite : IChannelAdminLogEventAction
{
    public uint ConstructorId => 0xfe9fc158;
    ///<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>
    /// The participant joined by importing a <a href="https://corefork.telegram.org/api/links#chat-folder-links">chat folder deep link »</a>.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool ViaChatlist { get; set; }

    ///<summary>
    /// The invite link used to join the <a href="https://corefork.telegram.org/api/channel">supergroup/channel</a>
    /// See <a href="https://corefork.telegram.org/type/ExportedChatInvite" />
    ///</summary>
    public MyTelegram.Schema.IExportedChatInvite Invite { get; set; }

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

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Invite);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { ViaChatlist = true; }
        Invite = buffer.Read<MyTelegram.Schema.IExportedChatInvite>();
    }
}