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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Get a document by its SHA256 hash, mainly used for gifs
/// <para>Possible errors</para>
/// Code Type Description
/// 400 SHA256_HASH_INVALID The provided SHA256 hash is invalid.
/// See <a href="https://corefork.telegram.org/method/messages.getDocumentByHash" />
///</summary>
[TlObject(0xb1f2061f)]
public sealed class RequestGetDocumentByHash : IRequest<MyTelegram.Schema.IDocument>
{
    public uint ConstructorId => 0xb1f2061f;
    ///<summary>
    /// SHA256 of file
    ///</summary>
    public ReadOnlyMemory<byte> Sha256 { get; set; }

    ///<summary>
    /// Size of the file in bytes
    ///</summary>
    public long Size { get; set; }

    ///<summary>
    /// Mime type
    ///</summary>
    public string MimeType { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Sha256);
        writer.Write(Size);
        writer.Write(MimeType);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Sha256 = buffer.ReadBytes();
        Size = buffer.ReadInt64();
        MimeType = buffer.ReadString();
    }
}
