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

namespace MyTelegram.Schema.Payments;

///<summary>
/// Clear saved payment information
/// See <a href="https://corefork.telegram.org/method/payments.clearSavedInfo" />
///</summary>
[TlObject(0xd83d70c1)]
public sealed class RequestClearSavedInfo : IRequest<IBool>
{
    public uint ConstructorId => 0xd83d70c1;
    ///<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>
    /// Remove saved payment credentials
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Credentials { get; set; }

    ///<summary>
    /// Clear the last order settings saved by the user
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Info { get; set; }

    public void ComputeFlag()
    {
        if (Credentials) { Flags = Flags.SetBit(0); }
        if (Info) { Flags = Flags.SetBit(1); }
    }

    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)) { Credentials = true; }
        if (Flags.IsBitSet(1)) { Info = true; }
    }
}
