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

namespace MyTelegram.Schema;

///<summary>
/// Location of profile photo of channel/group/supergroup/user
/// See <a href="https://corefork.telegram.org/constructor/inputPeerPhotoFileLocation" />
///</summary>
[TlObject(0x37257e99)]
public sealed class TInputPeerPhotoFileLocation : IInputFileLocation
{
    public uint ConstructorId => 0x37257e99;
    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags { get; set; }

    ///<summary>
    /// Whether to download the high-quality version of the picture
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Big { get; set; }

    ///<summary>
    /// The peer whose profile picture should be downloaded
    /// See <a href="https://corefork.telegram.org/type/InputPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputPeer Peer { get; set; }

    ///<summary>
    /// Photo ID
    ///</summary>
    public long PhotoId { get; set; }

    public void ComputeFlag()
    {
        if (Big) { Flags = Flags.SetBit(0); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Peer);
        writer.Write(PhotoId);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Big = true; }
        Peer = buffer.Read<MyTelegram.Schema.IInputPeer>();
        PhotoId = buffer.ReadInt64();
    }
}