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

namespace MyTelegram.Schema.Account;

///<summary>
/// Terminate a <a href="https://corefork.telegram.org/api/takeout">takeout session, see here » for more info</a>.
/// <para>Possible errors</para>
/// Code Type Description
/// 403 TAKEOUT_REQUIRED A <a href="https://corefork.telegram.org/api/takeout">takeout</a> session needs to be initialized first, <a href="https://corefork.telegram.org/api/takeout">see here » for more info</a>.
/// See <a href="https://corefork.telegram.org/method/account.finishTakeoutSession" />
///</summary>
[TlObject(0x1d2652ee)]
public sealed class RequestFinishTakeoutSession : IRequest<IBool>
{
    public uint ConstructorId => 0x1d2652ee;
    ///<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>
    /// Data exported successfully
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Success { get; set; }

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

    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)) { Success = true; }
    }
}
