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

namespace MyTelegram.Schema.Contacts;

///<summary>
/// Replace the contents of an entire <a href="https://corefork.telegram.org/api/block">blocklist, see here for more info »</a>.
/// See <a href="https://corefork.telegram.org/method/contacts.setBlocked" />
///</summary>
[TlObject(0x94c65c76)]
public sealed class RequestSetBlocked : IRequest<IBool>
{
    public uint ConstructorId => 0x94c65c76;
    ///<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>
    /// Whether to edit the story blocklist; if not set, will edit the main blocklist. See <a href="https://corefork.telegram.org/api/block">here »</a> for differences between the two.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool MyStoriesFrom { get; set; }

    ///<summary>
    /// Full content of the blocklist.
    ///</summary>
    public TVector<MyTelegram.Schema.IInputPeer> Id { get; set; }

    ///<summary>
    /// Maximum number of results to return, <a href="https://corefork.telegram.org/api/offsets">see pagination</a>
    ///</summary>
    public int Limit { get; set; }

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

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { MyStoriesFrom = true; }
        Id = buffer.Read<TVector<MyTelegram.Schema.IInputPeer>>();
        Limit = buffer.ReadInt32();
    }
}
