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

namespace MyTelegram.Schema.Account;

///<summary>
/// Returns list of chats with non-default notification settings
/// See <a href="https://corefork.telegram.org/method/account.getNotifyExceptions" />
///</summary>
[TlObject(0x53577479)]
public sealed class RequestGetNotifyExceptions : IRequest<MyTelegram.Schema.IUpdates>
{
    public uint ConstructorId => 0x53577479;
    ///<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>
    /// If set, chats with non-default sound will be returned
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool CompareSound { get; set; }

    ///<summary>
    /// If set, chats with non-default notification settings for stories will be returned
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool CompareStories { get; set; }

    ///<summary>
    /// If specified, only chats of the specified category will be returned
    /// See <a href="https://corefork.telegram.org/type/InputNotifyPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputNotifyPeer? Peer { get; set; }

    public void ComputeFlag()
    {
        if (CompareSound) { Flags = Flags.SetBit(1); }
        if (CompareStories) { Flags = Flags.SetBit(2); }
        if (Peer != null) { Flags = Flags.SetBit(0); }
    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(1)) { CompareSound = true; }
        if (Flags.IsBitSet(2)) { CompareStories = true; }
        if (Flags.IsBitSet(0)) { Peer = buffer.Read<MyTelegram.Schema.IInputNotifyPeer>(); }
    }
}
