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

namespace MyTelegram.Schema.Upload;

///<summary>
/// Download a <a href="https://corefork.telegram.org/cdn">CDN</a> file.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 FILE_TOKEN_INVALID The master DC did not accept the <code>file_token</code> (e.g., the token has expired). Continue downloading the file from the master DC using upload.getFile.
/// See <a href="https://corefork.telegram.org/method/upload.getCdnFile" />
///</summary>
[TlObject(0x395f69da)]
public sealed class RequestGetCdnFile : IRequest<MyTelegram.Schema.Upload.ICdnFile>
{
    public uint ConstructorId => 0x395f69da;
    ///<summary>
    /// File token
    ///</summary>
    public ReadOnlyMemory<byte> FileToken { get; set; }

    ///<summary>
    /// Offset of chunk to download
    ///</summary>
    public long Offset { get; set; }

    ///<summary>
    /// Length of chunk to download
    ///</summary>
    public int Limit { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(FileToken);
        writer.Write(Offset);
        writer.Write(Limit);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        FileToken = buffer.ReadBytes();
        Offset = buffer.ReadInt64();
        Limit = buffer.ReadInt32();
    }
}
