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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Add/remove sticker from recent stickers list
/// <para>Possible errors</para>
/// Code Type Description
/// 400 STICKER_ID_INVALID The provided sticker ID is invalid.
/// See <a href="https://corefork.telegram.org/method/messages.saveRecentSticker" />
///</summary>
[TlObject(0x392718f8)]
public sealed class RequestSaveRecentSticker : IRequest<IBool>
{
    public uint ConstructorId => 0x392718f8;
    ///<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 add/remove stickers recently attached to photo or video files
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Attached { get; set; }

    ///<summary>
    /// Sticker
    /// See <a href="https://corefork.telegram.org/type/InputDocument" />
    ///</summary>
    public MyTelegram.Schema.IInputDocument Id { get; set; }

    ///<summary>
    /// Whether to save or unsave the sticker
    /// See <a href="https://corefork.telegram.org/type/Bool" />
    ///</summary>
    public bool Unsave { get; set; }

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

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Attached = true; }
        Id = buffer.Read<MyTelegram.Schema.IInputDocument>();
        Unsave = buffer.Read();
    }
}
