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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Sends a service message to a secret chat.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 CHAT_ID_INVALID The provided chat id is invalid.
/// 400 DATA_INVALID Encrypted data invalid.
/// 400 ENCRYPTION_DECLINED The secret chat was declined.
/// 400 ENCRYPTION_ID_INVALID The provided secret chat ID is invalid.
/// 500 MSG_WAIT_FAILED A waiting call returned an error.
/// 403 USER_DELETED You can't send this secret message because the other participant deleted their account.
/// 403 USER_IS_BLOCKED You were blocked by this user.
/// See <a href="https://corefork.telegram.org/method/messages.sendEncryptedService" />
///</summary>
[TlObject(0x32d439a4)]
public sealed class RequestSendEncryptedService : IRequest<MyTelegram.Schema.Messages.ISentEncryptedMessage>
{
    public uint ConstructorId => 0x32d439a4;
    ///<summary>
    /// Secret chat ID
    /// See <a href="https://corefork.telegram.org/type/InputEncryptedChat" />
    ///</summary>
    public MyTelegram.Schema.IInputEncryptedChat Peer { get; set; }

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

    ///<summary>
    /// TL-serialization of  <a href="https://corefork.telegram.org/type/DecryptedMessage">DecryptedMessage</a> type, encrypted with a key generated during chat initialization
    ///</summary>
    public byte[] Data { get; set; }

    public void ComputeFlag()
    {

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Peer = buffer.Read<MyTelegram.Schema.IInputEncryptedChat>();
        RandomId = buffer.ReadInt64();
        Data = buffer.ReadBytes();
    }
}
