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

namespace MyTelegram.Schema.Upload;

///<summary>
/// The file must be downloaded from a <a href="https://corefork.telegram.org/cdn">CDN DC</a>.
/// See <a href="https://corefork.telegram.org/constructor/upload.fileCdnRedirect" />
///</summary>
[TlObject(0xf18cda44)]
public sealed class TFileCdnRedirect : IFile
{
    public uint ConstructorId => 0xf18cda44;
    ///<summary>
    /// <a href="https://corefork.telegram.org/cdn">CDN DC</a> ID
    ///</summary>
    public int DcId { get; set; }

    ///<summary>
    /// File token (see <a href="https://corefork.telegram.org/cdn">CDN files</a>)
    ///</summary>
    public ReadOnlyMemory<byte> FileToken { get; set; }

    ///<summary>
    /// Encryption key (see <a href="https://corefork.telegram.org/cdn">CDN files</a>)
    ///</summary>
    public ReadOnlyMemory<byte> EncryptionKey { get; set; }

    ///<summary>
    /// Encryption IV (see <a href="https://corefork.telegram.org/cdn">CDN files</a>)
    ///</summary>
    public ReadOnlyMemory<byte> EncryptionIv { get; set; }

    ///<summary>
    /// File hashes (see <a href="https://corefork.telegram.org/cdn">CDN files</a>)
    ///</summary>
    public TVector<MyTelegram.Schema.IFileHash> FileHashes { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(DcId);
        writer.Write(FileToken);
        writer.Write(EncryptionKey);
        writer.Write(EncryptionIv);
        writer.Write(FileHashes);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        DcId = buffer.ReadInt32();
        FileToken = buffer.ReadBytes();
        EncryptionKey = buffer.ReadBytes();
        EncryptionIv = buffer.ReadBytes();
        FileHashes = buffer.Read<TVector<MyTelegram.Schema.IFileHash>>();
    }
}