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

namespace MyTelegram.Schema.Channels;

///<summary>
/// Obtains a list of peers that can be used to send messages in a specific group
/// <para>Possible errors</para>
/// Code Type Description
/// 400 CHANNEL_INVALID The provided channel is invalid.
/// 400 CHANNEL_PRIVATE You haven't joined this channel/supergroup.
/// 400 CHAT_ID_INVALID The provided chat id is invalid.
/// 400 PEER_ID_INVALID The provided peer id is invalid.
/// See <a href="https://corefork.telegram.org/method/channels.getSendAs" />
///</summary>
[TlObject(0xe785a43f)]
public sealed class RequestGetSendAs : IRequest<MyTelegram.Schema.Channels.ISendAsPeers>
{
    public uint ConstructorId => 0xe785a43f;
    public int Flags { get; set; }
    public bool ForPaidReactions { get; set; }

    ///<summary>
    /// The group where we intend to send messages
    /// See <a href="https://corefork.telegram.org/type/InputPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputPeer Peer { get; set; }

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

    }

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

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