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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Sends one or more <a href="https://corefork.telegram.org/api/reactions#paid-reactions">paid Telegram Star reactions »</a>, transferring <a href="https://corefork.telegram.org/api/stars">Telegram Stars »</a> to a channel's balance.
/// See <a href="https://corefork.telegram.org/method/messages.sendPaidReaction" />
///</summary>
[TlObject(0x58bbcb50)]
public sealed class RequestSendPaidReaction : IRequest<MyTelegram.Schema.IUpdates>
{
    public uint ConstructorId => 0x58bbcb50;
    ///<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>
    /// The channel
    /// See <a href="https://corefork.telegram.org/type/InputPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputPeer Peer { get; set; }

    ///<summary>
    /// The message to react to
    ///</summary>
    public int MsgId { get; set; }

    ///<summary>
    /// The number of <a href="https://corefork.telegram.org/api/stars">stars</a> to send (each will increment the reaction counter by one).
    ///</summary>
    public int Count { get; set; }

    ///<summary>
    /// Unique client message ID required to prevent message resending
    ///</summary>
    public long RandomId { get; set; }

    ///<summary>
    /// Each post with star reactions has a leaderboard with the top senders, but users can opt out of appearing there if they prefer more privacy.  <br>If the user explicitly chose to make their paid reaction(s) private, pass <a href="https://corefork.telegram.org/constructor/boolTrue">boolTrue</a> to <a href="https://corefork.telegram.org/method/messages.sendPaidReaction">messages.sendPaidReaction</a>.<code>private</code>.  <br>If the user explicitly chose to make their paid reaction(s) private, pass <a href="https://corefork.telegram.org/constructor/boolTrue">boolFalse</a> to <a href="https://corefork.telegram.org/method/messages.sendPaidReaction">messages.sendPaidReaction</a>.<code>private</code>.  <br>If the user did not make any explicit choice about the privacy of their paid reaction(s) (i.e. when reacting by clicking on an existing star reaction on a message), do not populate the <a href="https://corefork.telegram.org/method/messages.sendPaidReaction">messages.sendPaidReaction</a>.<code>private</code> flag.
    /// See <a href="https://corefork.telegram.org/type/PaidReactionPrivacy" />
    ///</summary>
    public MyTelegram.Schema.IPaidReactionPrivacy? Private { get; set; }

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

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Peer);
        writer.Write(MsgId);
        writer.Write(Count);
        writer.Write(RandomId);
        if (Flags.IsBitSet(0)) { writer.Write(Private); }
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        Peer = buffer.Read<MyTelegram.Schema.IInputPeer>();
        MsgId = buffer.ReadInt32();
        Count = buffer.ReadInt32();
        RandomId = buffer.ReadInt64();
        if (Flags.IsBitSet(0)) { Private = buffer.Read<MyTelegram.Schema.IPaidReactionPrivacy>(); }
    }
}
