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

// MessagesGetInlineBotResultsRequest represents TL type `messages.getInlineBotResults#514e999d`.
// Query an inline bot
//
// See https://core.telegram.org/method/messages.getInlineBotResults for reference.
type MessagesGetInlineBotResultsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The bot to query
	Bot InputUserClass
	// The currently opened chat
	Peer InputPeerClass
	// The geolocation, if requested
	//
	// Use SetGeoPoint and GetGeoPoint helpers.
	GeoPoint InputGeoPointClass
	// The query
	Query string
	// The offset within the results, will be passed directly as-is to the bot.
	Offset string
}

// MessagesGetInlineBotResultsRequestTypeID is TL type id of MessagesGetInlineBotResultsRequest.
const MessagesGetInlineBotResultsRequestTypeID = 0x514e999d

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

func ( *MessagesGetInlineBotResultsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.GeoPoint == nil) {
		return false
	}
	if !(.Query == "") {
		return false
	}
	if !(.Offset == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetInlineBotResultsRequest from given interface.
func ( *MessagesGetInlineBotResultsRequest) ( interface {
	() ( InputUserClass)
	() ( InputPeerClass)
	() ( InputGeoPointClass,  bool)
	() ( string)
	() ( string)
}) {
	.Bot = .()
	.Peer = .()
	if ,  := .();  {
		.GeoPoint = 
	}

	.Query = .()
	.Offset = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetInlineBotResultsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getInlineBotResults",
		ID:   MessagesGetInlineBotResultsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "GeoPoint",
			SchemaName: "geo_point",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Query",
			SchemaName: "query",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesGetInlineBotResultsRequest) () {
	if !(.GeoPoint == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesGetInlineBotResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getInlineBotResults#514e999d as nil")
	}
	.PutID(MessagesGetInlineBotResultsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetInlineBotResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getInlineBotResults#514e999d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field flags: %w", )
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field bot: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field peer: %w", )
	}
	if .Flags.Has(0) {
		if .GeoPoint == nil {
			return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field geo_point is nil")
		}
		if  := .GeoPoint.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.getInlineBotResults#514e999d: field geo_point: %w", )
		}
	}
	.PutString(.Query)
	.PutString(.Offset)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetInlineBotResultsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getInlineBotResults#514e999d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.getInlineBotResults#514e999d: field flags: %w", )
		}
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getInlineBotResults#514e999d: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getInlineBotResults#514e999d: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputGeoPoint()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getInlineBotResults#514e999d: field geo_point: %w", )
		}
		.GeoPoint = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getInlineBotResults#514e999d: field query: %w", )
		}
		.Query = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getInlineBotResults#514e999d: field offset: %w", )
		}
		.Offset = 
	}
	return nil
}

// GetBot returns value of Bot field.
func ( *MessagesGetInlineBotResultsRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .Bot
}

// GetPeer returns value of Peer field.
func ( *MessagesGetInlineBotResultsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// SetGeoPoint sets value of GeoPoint conditional field.
func ( *MessagesGetInlineBotResultsRequest) ( InputGeoPointClass) {
	.Flags.Set(0)
	.GeoPoint = 
}

// GetGeoPoint returns value of GeoPoint conditional field and
// boolean which is true if field was set.
func ( *MessagesGetInlineBotResultsRequest) () ( InputGeoPointClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .GeoPoint, true
}

// GetQuery returns value of Query field.
func ( *MessagesGetInlineBotResultsRequest) () ( string) {
	if  == nil {
		return
	}
	return .Query
}

// GetOffset returns value of Offset field.
func ( *MessagesGetInlineBotResultsRequest) () ( string) {
	if  == nil {
		return
	}
	return .Offset
}

// GetGeoPointAsNotEmpty returns mapped value of GeoPoint conditional field and
// boolean which is true if field was set.
func ( *MessagesGetInlineBotResultsRequest) () (*InputGeoPoint, bool) {
	if ,  := .GetGeoPoint();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// MessagesGetInlineBotResults invokes method messages.getInlineBotResults#514e999d returning error if any.
// Query an inline bot
//
// Possible errors:
//
//	400 BOT_INLINE_DISABLED: This bot can't be used in inline mode.
//	400 BOT_INVALID: This is not a valid bot.
//	400 BOT_RESPONSE_TIMEOUT: A timeout occurred while fetching data from the bot.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	-503 Timeout: Timeout while fetching data.
//
// See https://core.telegram.org/method/messages.getInlineBotResults for reference.
func ( *Client) ( context.Context,  *MessagesGetInlineBotResultsRequest) (*MessagesBotResults, error) {
	var  MessagesBotResults

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