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

// MessagesSetInlineBotResultsRequest represents TL type `messages.setInlineBotResults#bb12a419`.
// Answer an inline query, for bots only
//
// See https://core.telegram.org/method/messages.setInlineBotResults for reference.
type MessagesSetInlineBotResultsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set this flag if the results are composed of media files
	Gallery bool
	// Set this flag if results may be cached on the server side only for the user that sent
	// the query. By default, results may be returned to any user who sends the same query
	Private bool
	// Unique identifier for the answered query
	QueryID int64
	// Vector of results for the inline query
	Results []InputBotInlineResultClass
	// The maximum amount of time in seconds that the result of the inline query may be
	// cached on the server. Defaults to 300.
	CacheTime int
	// Pass the offset that a client should send in the next query with the same text to
	// receive more results. Pass an empty string if there are no more results or if you
	// don't support pagination. Offset length can't exceed 64 bytes.
	//
	// Use SetNextOffset and GetNextOffset helpers.
	NextOffset string
	// If passed, clients will display a button on top of the remaining inline result list
	// with the specified text, that switches the user to a private chat with the bot and
	// sends the bot a start message with a certain parameter.
	//
	// Use SetSwitchPm and GetSwitchPm helpers.
	SwitchPm InlineBotSwitchPM
	// If passed, clients will display a button on top of the remaining inline result list
	// with the specified text, that switches the user to the specified inline mode mini
	// appĀ¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps#inline-mode-mini-apps
	//
	// Use SetSwitchWebview and GetSwitchWebview helpers.
	SwitchWebview InlineBotWebView
}

// MessagesSetInlineBotResultsRequestTypeID is TL type id of MessagesSetInlineBotResultsRequest.
const MessagesSetInlineBotResultsRequestTypeID = 0xbb12a419

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

func ( *MessagesSetInlineBotResultsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Gallery == false) {
		return false
	}
	if !(.Private == false) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.Results == nil) {
		return false
	}
	if !(.CacheTime == 0) {
		return false
	}
	if !(.NextOffset == "") {
		return false
	}
	if !(.SwitchPm.Zero()) {
		return false
	}
	if !(.SwitchWebview.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetInlineBotResultsRequest from given interface.
func ( *MessagesSetInlineBotResultsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
	() ( []InputBotInlineResultClass)
	() ( int)
	() ( string,  bool)
	() ( InlineBotSwitchPM,  bool)
	() ( InlineBotWebView,  bool)
}) {
	.Gallery = .()
	.Private = .()
	.QueryID = .()
	.Results = .()
	.CacheTime = .()
	if ,  := .();  {
		.NextOffset = 
	}

	if ,  := .();  {
		.SwitchPm = 
	}

	if ,  := .();  {
		.SwitchWebview = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSetInlineBotResultsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setInlineBotResults",
		ID:   MessagesSetInlineBotResultsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Gallery",
			SchemaName: "gallery",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Private",
			SchemaName: "private",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "Results",
			SchemaName: "results",
		},
		{
			Name:       "CacheTime",
			SchemaName: "cache_time",
		},
		{
			Name:       "NextOffset",
			SchemaName: "next_offset",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "SwitchPm",
			SchemaName: "switch_pm",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "SwitchWebview",
			SchemaName: "switch_webview",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetInlineBotResultsRequest) () {
	if !(.Gallery == false) {
		.Flags.Set(0)
	}
	if !(.Private == false) {
		.Flags.Set(1)
	}
	if !(.NextOffset == "") {
		.Flags.Set(2)
	}
	if !(.SwitchPm.Zero()) {
		.Flags.Set(3)
	}
	if !(.SwitchWebview.Zero()) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetInlineBotResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setInlineBotResults#bb12a419 as nil")
	}
	.PutID(MessagesSetInlineBotResultsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetInlineBotResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setInlineBotResults#bb12a419 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setInlineBotResults#bb12a419: field flags: %w", )
	}
	.PutLong(.QueryID)
	.PutVectorHeader(len(.Results))
	for ,  := range .Results {
		if  == nil {
			return fmt.Errorf("unable to encode messages.setInlineBotResults#bb12a419: field results element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.setInlineBotResults#bb12a419: field results element with index %d: %w", , )
		}
	}
	.PutInt(.CacheTime)
	if .Flags.Has(2) {
		.PutString(.NextOffset)
	}
	if .Flags.Has(3) {
		if  := .SwitchPm.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.setInlineBotResults#bb12a419: field switch_pm: %w", )
		}
	}
	if .Flags.Has(4) {
		if  := .SwitchWebview.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.setInlineBotResults#bb12a419: field switch_webview: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetInlineBotResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setInlineBotResults#bb12a419 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field flags: %w", )
		}
	}
	.Gallery = .Flags.Has(0)
	.Private = .Flags.Has(1)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field query_id: %w", )
		}
		.QueryID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field results: %w", )
		}

		if  > 0 {
			.Results = make([]InputBotInlineResultClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputBotInlineResult()
			if  != nil {
				return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field results: %w", )
			}
			.Results = append(.Results, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field cache_time: %w", )
		}
		.CacheTime = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field next_offset: %w", )
		}
		.NextOffset = 
	}
	if .Flags.Has(3) {
		if  := .SwitchPm.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field switch_pm: %w", )
		}
	}
	if .Flags.Has(4) {
		if  := .SwitchWebview.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setInlineBotResults#bb12a419: field switch_webview: %w", )
		}
	}
	return nil
}

// SetGallery sets value of Gallery conditional field.
func ( *MessagesSetInlineBotResultsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Gallery = true
	} else {
		.Flags.Unset(0)
		.Gallery = false
	}
}

// GetGallery returns value of Gallery conditional field.
func ( *MessagesSetInlineBotResultsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetPrivate sets value of Private conditional field.
func ( *MessagesSetInlineBotResultsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Private = true
	} else {
		.Flags.Unset(1)
		.Private = false
	}
}

// GetPrivate returns value of Private conditional field.
func ( *MessagesSetInlineBotResultsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// GetResults returns value of Results field.
func ( *MessagesSetInlineBotResultsRequest) () ( []InputBotInlineResultClass) {
	if  == nil {
		return
	}
	return .Results
}

// GetCacheTime returns value of CacheTime field.
func ( *MessagesSetInlineBotResultsRequest) () ( int) {
	if  == nil {
		return
	}
	return .CacheTime
}

// SetNextOffset sets value of NextOffset conditional field.
func ( *MessagesSetInlineBotResultsRequest) ( string) {
	.Flags.Set(2)
	.NextOffset = 
}

// GetNextOffset returns value of NextOffset conditional field and
// boolean which is true if field was set.
func ( *MessagesSetInlineBotResultsRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .NextOffset, true
}

// SetSwitchPm sets value of SwitchPm conditional field.
func ( *MessagesSetInlineBotResultsRequest) ( InlineBotSwitchPM) {
	.Flags.Set(3)
	.SwitchPm = 
}

// GetSwitchPm returns value of SwitchPm conditional field and
// boolean which is true if field was set.
func ( *MessagesSetInlineBotResultsRequest) () ( InlineBotSwitchPM,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .SwitchPm, true
}

// SetSwitchWebview sets value of SwitchWebview conditional field.
func ( *MessagesSetInlineBotResultsRequest) ( InlineBotWebView) {
	.Flags.Set(4)
	.SwitchWebview = 
}

// GetSwitchWebview returns value of SwitchWebview conditional field and
// boolean which is true if field was set.
func ( *MessagesSetInlineBotResultsRequest) () ( InlineBotWebView,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .SwitchWebview, true
}

// MapResults returns field Results wrapped in InputBotInlineResultClassArray helper.
func ( *MessagesSetInlineBotResultsRequest) () ( InputBotInlineResultClassArray) {
	return InputBotInlineResultClassArray(.Results)
}

// MessagesSetInlineBotResults invokes method messages.setInlineBotResults#bb12a419 returning error if any.
// Answer an inline query, for bots only
//
// Possible errors:
//
//	400 ARTICLE_TITLE_EMPTY: The title of the article is empty.
//	400 AUDIO_CONTENT_URL_EMPTY: The remote URL specified in the content field is empty.
//	400 AUDIO_TITLE_EMPTY: An empty audio title was provided.
//	400 BUTTON_DATA_INVALID: The data of one or more of the buttons you provided is invalid.
//	400 BUTTON_TYPE_INVALID: The type of one or more of the buttons you provided is invalid.
//	400 BUTTON_URL_INVALID: Button URL invalid.
//	400 DOCUMENT_INVALID: The specified document is invalid.
//	400 FILE_CONTENT_TYPE_INVALID: File content-type is invalid.
//	400 FILE_TITLE_EMPTY: An empty file title was specified.
//	400 GIF_CONTENT_TYPE_INVALID: GIF content-type invalid.
//	400 MESSAGE_EMPTY: The provided message is empty.
//	400 MESSAGE_TOO_LONG: The provided message is too long.
//	400 NEXT_OFFSET_INVALID: The specified offset is longer than 64 bytes.
//	400 PHOTO_CONTENT_TYPE_INVALID: Photo mime-type invalid.
//	400 PHOTO_CONTENT_URL_EMPTY: Photo URL invalid.
//	400 PHOTO_INVALID: Photo invalid.
//	400 PHOTO_THUMB_URL_EMPTY: Photo thumbnail URL is empty.
//	400 QUERY_ID_INVALID: The query ID is invalid.
//	400 REPLY_MARKUP_INVALID: The provided reply markup is invalid.
//	400 RESULTS_TOO_MUCH: Too many results were provided.
//	400 RESULT_ID_DUPLICATE: You provided a duplicate result ID.
//	400 RESULT_ID_INVALID: One of the specified result IDs is invalid.
//	400 RESULT_TYPE_INVALID: Result type invalid.
//	400 SEND_MESSAGE_MEDIA_INVALID: Invalid media provided.
//	400 SEND_MESSAGE_TYPE_INVALID: The message type is invalid.
//	400 START_PARAM_EMPTY: The start parameter is empty.
//	400 START_PARAM_INVALID: Start parameter invalid.
//	400 STICKER_DOCUMENT_INVALID: The specified sticker document is invalid.
//	400 SWITCH_PM_TEXT_EMPTY: The switch_pm.text field was empty.
//	400 URL_INVALID: Invalid URL provided.
//	403 USER_BOT_INVALID: User accounts must provide the bot method parameter when calling this method. If there is no such method parameter, this method can only be invoked by bot accounts.
//	400 VIDEO_TITLE_EMPTY: The specified video title is empty.
//	400 WEBDOCUMENT_INVALID: Invalid webdocument URL provided.
//	400 WEBDOCUMENT_MIME_INVALID: Invalid webdocument mime type provided.
//	400 WEBDOCUMENT_SIZE_TOO_BIG: Webdocument is too big!
//	400 WEBDOCUMENT_URL_INVALID: The specified webdocument URL is invalid.
//
// See https://core.telegram.org/method/messages.setInlineBotResults for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetInlineBotResultsRequest) (bool, error) {
	var  BoolBox

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