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

using System.Buffers.Binary;

namespace MyTelegram.Schema.Upload;

///<summary>
/// Saves a part of file for further sending to one of the methods.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 FILE_PART_EMPTY The provided file part is empty.
/// 400 FILE_PART_INVALID The file part number is invalid.
/// 400 MSG_ID_INVALID Invalid message ID provided.
/// See <a href="https://corefork.telegram.org/method/upload.saveFilePart" />
///</summary>
[TlObject(0xb304a621)]
public sealed class RequestSaveFilePart : IRequest<IBool>
{
    public uint ConstructorId => 0xb304a621;
    ///<summary>
    /// Random file identifier created by the client
    ///</summary>
    public long FileId { get; set; }

    ///<summary>
    /// Numerical order of a part
    ///</summary>
    public int FilePart { get; set; }

    ///<summary>
    /// Binary data, content of a part
    ///</summary>
    public ReadOnlyMemory<byte> Bytes { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(FileId);
        writer.Write(FilePart);
        writer.Write(Bytes);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        FileId = buffer.ReadInt64();
        FilePart = buffer.ReadInt32();
        Bytes = buffer.ReadMemory();
    }
}
