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

namespace MyTelegram.Schema.Account;

///<summary>
/// Set a list of <a href="https://corefork.telegram.org/api/business#away-messages">Telegram Business away messages</a>.
/// See <a href="https://corefork.telegram.org/method/account.updateBusinessAwayMessage" />
///</summary>
[TlObject(0xa26a7fa5)]
public sealed class RequestUpdateBusinessAwayMessage : IRequest<IBool>
{
    public uint ConstructorId => 0xa26a7fa5;
    ///<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>
    /// Away message configuration and contents.
    /// See <a href="https://corefork.telegram.org/type/InputBusinessAwayMessage" />
    ///</summary>
    public MyTelegram.Schema.IInputBusinessAwayMessage? Message { get; set; }

    public void ComputeFlag()
    {
        if (Message != null) { Flags = Flags.SetBit(0); }
    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        if (Flags.IsBitSet(0)) { writer.Write(Message); }
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Message = buffer.Read<MyTelegram.Schema.IInputBusinessAwayMessage>(); }
    }
}
