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

namespace MyTelegram.Schema.Payments;

///<summary>
/// Display or remove a <a href="https://corefork.telegram.org/api/gifts">received gift »</a> from our profile.
/// See <a href="https://corefork.telegram.org/method/payments.saveStarGift" />
///</summary>
[TlObject(0x2a2a697c)]
public sealed class RequestSaveStarGift : IRequest<IBool>
{
    public uint ConstructorId => 0x2a2a697c;
    ///<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, hides the gift from our profile.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Unsave { get; set; }
    public MyTelegram.Schema.IInputSavedStarGift Stargift { get; set; }

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

    }

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

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