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

namespace MyTelegram.Schema.Upload;

///<summary>
/// Saves a part of a large file (over 10 MB in size) to be later passed to one of the methods.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 FILE_PARTS_INVALID The number of file parts is invalid.
/// 400 FILE_PART_EMPTY The provided file part is empty.
/// 400 FILE_PART_INVALID The file part number is invalid.
/// 400 FILE_PART_SIZE_CHANGED Provided file part size has changed.
/// 400 FILE_PART_SIZE_INVALID The provided file part size is invalid.
/// 400 FILE_PART_TOO_BIG The uploaded file part is too big.
/// See <a href="https://corefork.telegram.org/method/upload.saveBigFilePart" />
///</summary>
[TlObject(0xde7b673d)]
public sealed class RequestSaveBigFilePart : IRequest<IBool>
{
    public uint ConstructorId => 0xde7b673d;
    ///<summary>
    /// Random file id, created by the client
    ///</summary>
    public long FileId { get; set; }

    ///<summary>
    /// Part sequence number
    ///</summary>
    public int FilePart { get; set; }

    ///<summary>
    /// Total number of parts
    ///</summary>
    public int FileTotalParts { get; set; }

    ///<summary>
    /// Binary data, part contents
    ///</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(FileTotalParts);
        writer.Write(Bytes);
    }

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