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

namespace MyTelegram.Schema.Phone;

///<summary>
/// Get an <a href="https://corefork.telegram.org/api/links#video-chat-livestream-links">invite link</a> for a group call or livestream
/// <para>Possible errors</para>
/// Code Type Description
/// 400 GROUPCALL_INVALID The specified group call is invalid.
/// 403 PUBLIC_CHANNEL_MISSING You can only export group call invite links for public chats or channels.
/// See <a href="https://corefork.telegram.org/method/phone.exportGroupCallInvite" />
///</summary>
[TlObject(0xe6aa647f)]
public sealed class RequestExportGroupCallInvite : IRequest<MyTelegram.Schema.Phone.IExportedGroupCallInvite>
{
    public uint ConstructorId => 0xe6aa647f;
    ///<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>
    /// For livestreams or muted group chats, if set, users that join using this link will be able to speak without explicitly requesting permission by (for example by raising their hand).
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool CanSelfUnmute { get; set; }

    ///<summary>
    /// The group call
    /// See <a href="https://corefork.telegram.org/type/InputGroupCall" />
    ///</summary>
    public MyTelegram.Schema.IInputGroupCall Call { get; set; }

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

    }

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

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