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

namespace MyTelegram.Schema.Payments;

/// <summary>
/// Get the gifts pinned on a specific user's profile.
/// May also be used to fetch all gifts received by the current user.
/// See <a href="https://core.telegram.org/method/payments.getUserStarGifts"/>
/// </summary>
[TlObject(0xecf24f1d)]
public sealed class RequestGetUserStarGifts : IRequest<MyTelegram.Schema.Payments.IUserStarGifts>
{
    public uint ConstructorId => 0xecf24f1d;
    
    public int Flags { get; set; }
    
    /// <summary>
    /// The user whose profile gifts to fetch.
    /// If not set, fetches all gifts received by the current user
    /// </summary>
    public MyTelegram.Schema.IInputUser? UserId { get; set; }
    
    /// <summary>
    /// Offset for pagination
    /// </summary>
    public string Offset { get; set; }
    
    /// <summary>
    /// Maximum number of results to return
    /// </summary>
    public int Limit { get; set; }

    public void ComputeFlag()
    {
        if (UserId != null) { Flags = Flags.SetBit(0); }
    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { UserId = buffer.Read<MyTelegram.Schema.IInputUser>(); }
        Offset = buffer.ReadString();
        Limit = buffer.ReadInt32();
    }
}
