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

// MessagesSetBotPrecheckoutResultsRequest represents TL type `messages.setBotPrecheckoutResults#9c2dd95`.
// Once the user has confirmed their payment and shipping details, the bot receives an
// updateBotPrecheckoutQuery¹ update.
// Use this method to respond to such pre-checkout queries.
// Note: Telegram must receive an answer within 10 seconds after the pre-checkout query
// was sent.
//
// Links:
//  1. https://core.telegram.org/constructor/updateBotPrecheckoutQuery
//
// See https://core.telegram.org/method/messages.setBotPrecheckoutResults for reference.
type MessagesSetBotPrecheckoutResultsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set this flag if everything is alright (goods are available, etc.) and the bot is
	// ready to proceed with the order, otherwise do not set it, and set the error field,
	// instead
	Success bool
	// Unique identifier for the query to be answered
	QueryID int64
	// Required if the success isn't set. Error message in human readable form that explains
	// the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought
	// the last of our amazing black T-shirts while you were busy filling out your payment
	// details. Please choose a different color or garment!"). Telegram will display this
	// message to the user.
	//
	// Use SetError and GetError helpers.
	Error string
}

// MessagesSetBotPrecheckoutResultsRequestTypeID is TL type id of MessagesSetBotPrecheckoutResultsRequest.
const MessagesSetBotPrecheckoutResultsRequestTypeID = 0x9c2dd95

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

func ( *MessagesSetBotPrecheckoutResultsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Success == false) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.Error == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetBotPrecheckoutResultsRequest from given interface.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( interface {
	() ( bool)
	() ( int64)
	() ( string,  bool)
}) {
	.Success = .()
	.QueryID = .()
	if ,  := .();  {
		.Error = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*MessagesSetBotPrecheckoutResultsRequest) () string {
	return "messages.setBotPrecheckoutResults"
}

// TypeInfo returns info about TL type.
func ( *MessagesSetBotPrecheckoutResultsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setBotPrecheckoutResults",
		ID:   MessagesSetBotPrecheckoutResultsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Success",
			SchemaName: "success",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "Error",
			SchemaName: "error",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetBotPrecheckoutResultsRequest) () {
	if !(.Success == false) {
		.Flags.Set(1)
	}
	if !(.Error == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setBotPrecheckoutResults#9c2dd95 as nil")
	}
	.PutID(MessagesSetBotPrecheckoutResultsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setBotPrecheckoutResults#9c2dd95 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setBotPrecheckoutResults#9c2dd95: field flags: %w", )
	}
	.PutLong(.QueryID)
	if .Flags.Has(0) {
		.PutString(.Error)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setBotPrecheckoutResults#9c2dd95 to nil")
	}
	if  := .ConsumeID(MessagesSetBotPrecheckoutResultsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.setBotPrecheckoutResults#9c2dd95: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setBotPrecheckoutResults#9c2dd95 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setBotPrecheckoutResults#9c2dd95: field flags: %w", )
		}
	}
	.Success = .Flags.Has(1)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotPrecheckoutResults#9c2dd95: field query_id: %w", )
		}
		.QueryID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotPrecheckoutResults#9c2dd95: field error: %w", )
		}
		.Error = 
	}
	return nil
}

// SetSuccess sets value of Success conditional field.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Success = true
	} else {
		.Flags.Unset(1)
		.Success = false
	}
}

// GetSuccess returns value of Success conditional field.
func ( *MessagesSetBotPrecheckoutResultsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetQueryID returns value of QueryID field.
func ( *MessagesSetBotPrecheckoutResultsRequest) () ( int64) {
	if  == nil {
		return
	}
	return .QueryID
}

// SetError sets value of Error conditional field.
func ( *MessagesSetBotPrecheckoutResultsRequest) ( string) {
	.Flags.Set(0)
	.Error = 
}

// GetError returns value of Error conditional field and
// boolean which is true if field was set.
func ( *MessagesSetBotPrecheckoutResultsRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Error, true
}

// MessagesSetBotPrecheckoutResults invokes method messages.setBotPrecheckoutResults#9c2dd95 returning error if any.
// Once the user has confirmed their payment and shipping details, the bot receives an
// updateBotPrecheckoutQuery¹ update.
// Use this method to respond to such pre-checkout queries.
// Note: Telegram must receive an answer within 10 seconds after the pre-checkout query
// was sent.
//
// Links:
//  1. https://core.telegram.org/constructor/updateBotPrecheckoutQuery
//
// Possible errors:
//
//	400 ERROR_TEXT_EMPTY: The provided error message is empty.
//
// See https://core.telegram.org/method/messages.setBotPrecheckoutResults for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetBotPrecheckoutResultsRequest) (bool, error) {
	var  BoolBox

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