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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Get a list of <a href="https://corefork.telegram.org/api/sponsored-messages">sponsored messages for a peer, see here »</a> for more info.
/// See <a href="https://corefork.telegram.org/method/messages.getSponsoredMessages" />
///</summary>
[TlObject(0x3d6ce850)]
public sealed class RequestGetSponsoredMessages : IRequest<MyTelegram.Schema.Messages.ISponsoredMessages>
{
    public uint ConstructorId => 0x3d6ce850;
    public int Flags { get; set; }

    ///<summary>
    /// The currently open channel/bot.
    /// See <a href="https://corefork.telegram.org/type/InputPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputPeer Peer { get; set; }
    public int? MsgId { get; set; }

    public void ComputeFlag()
    {
        if (/*MsgId != 0 && */MsgId.HasValue) { Flags = Flags.SetBit(0); }
    }

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

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