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

namespace MyTelegram.Schema.Payments;

///<summary>
/// Get a payment form
/// <para>Possible errors</para>
/// Code Type Description
/// 400 BOOST_PEER_INVALID The specified <code>boost_peer</code> is invalid.
/// 400 MESSAGE_ID_INVALID The provided message id is invalid.
/// 400 PEER_ID_INVALID The provided peer id is invalid.
/// 400 SLUG_INVALID The specified invoice slug is invalid.
/// 400 UNTIL_DATE_INVALID Invalid until date provided.
/// See <a href="https://corefork.telegram.org/method/payments.getPaymentForm" />
///</summary>
[TlObject(0x37148dbb)]
public sealed class RequestGetPaymentForm : IRequest<MyTelegram.Schema.Payments.IPaymentForm>
{
    public uint ConstructorId => 0x37148dbb;
    ///<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>
    /// Invoice
    /// See <a href="https://corefork.telegram.org/type/InputInvoice" />
    ///</summary>
    public MyTelegram.Schema.IInputInvoice Invoice { get; set; }

    ///<summary>
    /// A JSON object with the following keys, containing color theme information (integers, RGB24) to pass to the payment provider, to apply in eventual verification pages: <br><code>bg_color</code> - Background color <br><code>text_color</code> - Text color <br><code>hint_color</code> - Hint text color <br><code>link_color</code> - Link color <br><code>button_color</code> - Button color <br><code>button_text_color</code> - Button text color
    /// See <a href="https://corefork.telegram.org/type/DataJSON" />
    ///</summary>
    public MyTelegram.Schema.IDataJSON? ThemeParams { get; set; }

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

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

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