// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PaymentsGetPaymentFormRequest represents TL type `payments.getPaymentForm#37148dbb`.
// Get a payment form
//
// See https://core.telegram.org/method/payments.getPaymentForm for reference.
type PaymentsGetPaymentFormRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Invoice
	Invoice InputInvoiceClass
	// 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:
	// bg_color - Background color text_color - Text color hint_color - Hint text color
	// link_color - Link color button_color - Button color button_text_color - Button text
	// color
	//
	// Use SetThemeParams and GetThemeParams helpers.
	ThemeParams DataJSON
}

// PaymentsGetPaymentFormRequestTypeID is TL type id of PaymentsGetPaymentFormRequest.
const PaymentsGetPaymentFormRequestTypeID = 0x37148dbb

// Ensuring interfaces in compile-time for PaymentsGetPaymentFormRequest.
var (
	_ bin.Encoder     = &PaymentsGetPaymentFormRequest{}
	_ bin.Decoder     = &PaymentsGetPaymentFormRequest{}
	_ bin.BareEncoder = &PaymentsGetPaymentFormRequest{}
	_ bin.BareDecoder = &PaymentsGetPaymentFormRequest{}
)

func ( *PaymentsGetPaymentFormRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Invoice == nil) {
		return false
	}
	if !(.ThemeParams.Zero()) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PaymentsGetPaymentFormRequest) () string {
	if  == nil {
		return "PaymentsGetPaymentFormRequest(nil)"
	}
	type  PaymentsGetPaymentFormRequest
	return fmt.Sprintf("PaymentsGetPaymentFormRequest%+v", (*))
}

// FillFrom fills PaymentsGetPaymentFormRequest from given interface.
func ( *PaymentsGetPaymentFormRequest) ( interface {
	() ( InputInvoiceClass)
	() ( DataJSON,  bool)
}) {
	.Invoice = .()
	if ,  := .();  {
		.ThemeParams = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PaymentsGetPaymentFormRequest) () uint32 {
	return PaymentsGetPaymentFormRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*PaymentsGetPaymentFormRequest) () string {
	return "payments.getPaymentForm"
}

// TypeInfo returns info about TL type.
func ( *PaymentsGetPaymentFormRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getPaymentForm",
		ID:   PaymentsGetPaymentFormRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Invoice",
			SchemaName: "invoice",
		},
		{
			Name:       "ThemeParams",
			SchemaName: "theme_params",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetPaymentFormRequest) () {
	if !(.ThemeParams.Zero()) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetPaymentFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getPaymentForm#37148dbb as nil")
	}
	.PutID(PaymentsGetPaymentFormRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetPaymentFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getPaymentForm#37148dbb as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getPaymentForm#37148dbb: field flags: %w", )
	}
	if .Invoice == nil {
		return fmt.Errorf("unable to encode payments.getPaymentForm#37148dbb: field invoice is nil")
	}
	if  := .Invoice.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getPaymentForm#37148dbb: field invoice: %w", )
	}
	if .Flags.Has(0) {
		if  := .ThemeParams.Encode();  != nil {
			return fmt.Errorf("unable to encode payments.getPaymentForm#37148dbb: field theme_params: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsGetPaymentFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getPaymentForm#37148dbb to nil")
	}
	if  := .ConsumeID(PaymentsGetPaymentFormRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.getPaymentForm#37148dbb: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetPaymentFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getPaymentForm#37148dbb to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getPaymentForm#37148dbb: field flags: %w", )
		}
	}
	{
		,  := DecodeInputInvoice()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getPaymentForm#37148dbb: field invoice: %w", )
		}
		.Invoice = 
	}
	if .Flags.Has(0) {
		if  := .ThemeParams.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getPaymentForm#37148dbb: field theme_params: %w", )
		}
	}
	return nil
}

// GetInvoice returns value of Invoice field.
func ( *PaymentsGetPaymentFormRequest) () ( InputInvoiceClass) {
	if  == nil {
		return
	}
	return .Invoice
}

// SetThemeParams sets value of ThemeParams conditional field.
func ( *PaymentsGetPaymentFormRequest) ( DataJSON) {
	.Flags.Set(0)
	.ThemeParams = 
}

// GetThemeParams returns value of ThemeParams conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetPaymentFormRequest) () ( DataJSON,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ThemeParams, true
}

// PaymentsGetPaymentForm invokes method payments.getPaymentForm#37148dbb returning error if any.
// Get a payment form
//
// Possible errors:
//
//	400 BOOST_PEER_INVALID: The specified boost_peer is invalid.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 SLUG_INVALID: The specified invoice slug is invalid.
//	400 UNTIL_DATE_INVALID: Invalid until date provided.
//
// See https://core.telegram.org/method/payments.getPaymentForm for reference.
func ( *Client) ( context.Context,  *PaymentsGetPaymentFormRequest) (*PaymentsPaymentForm, error) {
	var  PaymentsPaymentForm

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}