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

namespace MyTelegram.Schema.Contacts;

///<summary>
/// Returns the list of blocked users.
/// See <a href="https://corefork.telegram.org/method/contacts.getBlocked" />
///</summary>
[TlObject(0x9a868f80)]
public sealed class RequestGetBlocked : IRequest<MyTelegram.Schema.Contacts.IBlocked>
{
    public uint ConstructorId => 0x9a868f80;
    ///<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 fetch the story blocklist; if not set, will fetch 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>
    /// The number of list elements to be skipped
    ///</summary>
    public int Offset { get; set; }

    ///<summary>
    /// The number of list elements to be returned
    ///</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(Offset);
        writer.Write(Limit);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { MyStoriesFrom = true; }
        Offset = buffer.ReadInt32();
        Limit = buffer.ReadInt32();
    }
}
