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

namespace MyTelegram.Schema;

///<summary>
/// See <a href="https://corefork.telegram.org/constructor/businessBotRights" />
///</summary>
[TlObject(0xa0624cf7)]
public sealed class TBusinessBotRights : IBusinessBotRights
{
    public uint ConstructorId => 0xa0624cf7;
    public int Flags { get; set; }
    public bool Reply { get; set; }
    public bool ReadMessages { get; set; }
    public bool DeleteSentMessages { get; set; }
    public bool DeleteReceivedMessages { get; set; }
    public bool EditName { get; set; }
    public bool EditBio { get; set; }
    public bool EditProfilePhoto { get; set; }
    public bool EditUsername { get; set; }
    public bool ViewGifts { get; set; }
    public bool SellGifts { get; set; }
    public bool ChangeGiftSettings { get; set; }
    public bool TransferAndUpgradeGifts { get; set; }
    public bool TransferStars { get; set; }
    public bool ManageStories { get; set; }

    public void ComputeFlag()
    {
        if (Reply) { Flags = Flags.SetBit(0); }
        if (ReadMessages) { Flags = Flags.SetBit(1); }
        if (DeleteSentMessages) { Flags = Flags.SetBit(2); }
        if (DeleteReceivedMessages) { Flags = Flags.SetBit(3); }
        if (EditName) { Flags = Flags.SetBit(4); }
        if (EditBio) { Flags = Flags.SetBit(5); }
        if (EditProfilePhoto) { Flags = Flags.SetBit(6); }
        if (EditUsername) { Flags = Flags.SetBit(7); }
        if (ViewGifts) { Flags = Flags.SetBit(8); }
        if (SellGifts) { Flags = Flags.SetBit(9); }
        if (ChangeGiftSettings) { Flags = Flags.SetBit(10); }
        if (TransferAndUpgradeGifts) { Flags = Flags.SetBit(11); }
        if (TransferStars) { Flags = Flags.SetBit(12); }
        if (ManageStories) { Flags = Flags.SetBit(13); }
    }

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

    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Reply = true; }
        if (Flags.IsBitSet(1)) { ReadMessages = true; }
        if (Flags.IsBitSet(2)) { DeleteSentMessages = true; }
        if (Flags.IsBitSet(3)) { DeleteReceivedMessages = true; }
        if (Flags.IsBitSet(4)) { EditName = true; }
        if (Flags.IsBitSet(5)) { EditBio = true; }
        if (Flags.IsBitSet(6)) { EditProfilePhoto = true; }
        if (Flags.IsBitSet(7)) { EditUsername = true; }
        if (Flags.IsBitSet(8)) { ViewGifts = true; }
        if (Flags.IsBitSet(9)) { SellGifts = true; }
        if (Flags.IsBitSet(10)) { ChangeGiftSettings = true; }
        if (Flags.IsBitSet(11)) { TransferAndUpgradeGifts = true; }
        if (Flags.IsBitSet(12)) { TransferStars = true; }
        if (Flags.IsBitSet(13)) { ManageStories = true; }
    }
}