// 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
	// Theme parameters »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps#theme-parameters
	//
	// 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:
//
//	406 API_GIFT_RESTRICTED_UPDATE_APP: Please update the app to access the gift API.
//	400 BOOST_PEER_INVALID: The specified boost_peer is invalid.
//	403 BOT_ACCESS_FORBIDDEN: The specified method can be used over a business connection for some operations, but the specified query attempted an operation that is not allowed over a business connection.
//	400 BOT_INVOICE_INVALID: The specified invoice is invalid.
//	400 BUSINESS_CONNECTION_INVALID: The connection_id passed to the wrapping invokeWithBusinessConnection call is invalid.
//	400 GIFT_MONTHS_INVALID: The value passed in invoice.inputInvoicePremiumGiftStars.months is invalid.
//	400 GIFT_STARS_INVALID: The specified amount of stars is invalid.
//	400 INVOICE_INVALID: The specified invoice is invalid.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 MESSAGE_TOO_LONG: The provided message is too long.
//	400 MONTH_INVALID: The number of months specified in inputInvoicePremiumGiftStars.months is invalid.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 NO_PAYMENT_NEEDED: The upgrade/transfer of the specified gift was already paid for or is free.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 PREMIUM_PURPOSE_INVALID:
//	400 SLUG_INVALID: The specified invoice slug is invalid.
//	400 STARGIFT_ALREADY_CONVERTED: The specified star gift was already converted to Stars.
//	400 STARGIFT_ALREADY_REFUNDED: The specified star gift was already refunded.
//	400 STARGIFT_ALREADY_UPGRADED: The specified gift was already upgraded to a collectible gift.
//	406 STARGIFT_EXPORT_IN_PROGRESS: A gift export is in progress, a detailed and localized description for the error will be emitted via an updateServiceNotification as specified here ».
//	400 STARGIFT_INVALID: The passed gift is invalid.
//	400 STARGIFT_MESSAGE_INVALID:
//	400 STARGIFT_NOT_FOUND: The specified gift was not found.
//	400 STARGIFT_NOT_OWNER:
//	400 STARGIFT_OWNER_INVALID: You cannot transfer or sell a gift owned by another user.
//	400 STARGIFT_PEER_INVALID: The specified inputSavedStarGiftChat.peer is invalid.
//	400 STARGIFT_RESELL_CURRENCY_NOT_ALLOWED: You can't buy the gift using the specified currency (i.e. trying to pay in Stars for TON gifts).
//	400 STARGIFT_RESELL_TOO_EARLY_%d:
//	400 STARGIFT_SLUG_INVALID: The specified gift slug is invalid.
//	400 STARGIFT_TRANSFER_TOO_EARLY_%d: You cannot transfer this gift yet, wait %d seconds.
//	400 STARGIFT_UPGRADE_UNAVAILABLE: A received gift can only be upgraded to a collectible gift if the messageActionStarGift/savedStarGift.can_upgrade flag is set.
//	406 STARS_FORM_AMOUNT_MISMATCH: The form amount has changed, please fetch the new form using payments.getPaymentForm and restart the process.
//	400 TO_ID_INVALID: The specified to_id of the passed inputInvoiceStarGiftResale or inputInvoiceStarGiftTransfer 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) (PaymentsPaymentFormClass, error) {
	var  PaymentsPaymentFormBox

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