// 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{}
)

// PaymentsValidateRequestedInfoRequest represents TL type `payments.validateRequestedInfo#b6c8f12b`.
// Submit requested order information for validation
//
// See https://core.telegram.org/method/payments.validateRequestedInfo for reference.
type PaymentsValidateRequestedInfoRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Save order information to re-use it for future orders
	Save bool
	// Invoice
	Invoice InputInvoiceClass
	// Requested order information
	Info PaymentRequestedInfo
}

// PaymentsValidateRequestedInfoRequestTypeID is TL type id of PaymentsValidateRequestedInfoRequest.
const PaymentsValidateRequestedInfoRequestTypeID = 0xb6c8f12b

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

func ( *PaymentsValidateRequestedInfoRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Save == false) {
		return false
	}
	if !(.Invoice == nil) {
		return false
	}
	if !(.Info.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsValidateRequestedInfoRequest from given interface.
func ( *PaymentsValidateRequestedInfoRequest) ( interface {
	() ( bool)
	() ( InputInvoiceClass)
	() ( PaymentRequestedInfo)
}) {
	.Save = .()
	.Invoice = .()
	.Info = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsValidateRequestedInfoRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.validateRequestedInfo",
		ID:   PaymentsValidateRequestedInfoRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Save",
			SchemaName: "save",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Invoice",
			SchemaName: "invoice",
		},
		{
			Name:       "Info",
			SchemaName: "info",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsValidateRequestedInfoRequest) () {
	if !(.Save == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsValidateRequestedInfoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.validateRequestedInfo#b6c8f12b as nil")
	}
	.PutID(PaymentsValidateRequestedInfoRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsValidateRequestedInfoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.validateRequestedInfo#b6c8f12b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.validateRequestedInfo#b6c8f12b: field flags: %w", )
	}
	if .Invoice == nil {
		return fmt.Errorf("unable to encode payments.validateRequestedInfo#b6c8f12b: field invoice is nil")
	}
	if  := .Invoice.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.validateRequestedInfo#b6c8f12b: field invoice: %w", )
	}
	if  := .Info.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.validateRequestedInfo#b6c8f12b: field info: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsValidateRequestedInfoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.validateRequestedInfo#b6c8f12b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.validateRequestedInfo#b6c8f12b: field flags: %w", )
		}
	}
	.Save = .Flags.Has(0)
	{
		,  := DecodeInputInvoice()
		if  != nil {
			return fmt.Errorf("unable to decode payments.validateRequestedInfo#b6c8f12b: field invoice: %w", )
		}
		.Invoice = 
	}
	{
		if  := .Info.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.validateRequestedInfo#b6c8f12b: field info: %w", )
		}
	}
	return nil
}

// SetSave sets value of Save conditional field.
func ( *PaymentsValidateRequestedInfoRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Save = true
	} else {
		.Flags.Unset(0)
		.Save = false
	}
}

// GetSave returns value of Save conditional field.
func ( *PaymentsValidateRequestedInfoRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetInfo returns value of Info field.
func ( *PaymentsValidateRequestedInfoRequest) () ( PaymentRequestedInfo) {
	if  == nil {
		return
	}
	return .Info
}

// PaymentsValidateRequestedInfo invokes method payments.validateRequestedInfo#b6c8f12b returning error if any.
// Submit requested order information for validation
//
// Possible errors:
//
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//
// See https://core.telegram.org/method/payments.validateRequestedInfo for reference.
func ( *Client) ( context.Context,  *PaymentsValidateRequestedInfoRequest) (*PaymentsValidatedRequestedInfo, error) {
	var  PaymentsValidatedRequestedInfo

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