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

// MessagesSetBotCallbackAnswerRequest represents TL type `messages.setBotCallbackAnswer#d58f130a`.
// Set the callback answer to a user button press (bots only)
//
// See https://core.telegram.org/method/messages.setBotCallbackAnswer for reference.
type MessagesSetBotCallbackAnswerRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to show the message as a popup instead of a toast notification
	Alert bool
	// Query ID
	QueryID int64
	// Popup to show
	//
	// Use SetMessage and GetMessage helpers.
	Message string
	// URL to open
	//
	// Use SetURL and GetURL helpers.
	URL string
	// Cache validity
	CacheTime int
}

// MessagesSetBotCallbackAnswerRequestTypeID is TL type id of MessagesSetBotCallbackAnswerRequest.
const MessagesSetBotCallbackAnswerRequestTypeID = 0xd58f130a

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

func ( *MessagesSetBotCallbackAnswerRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Alert == false) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.Message == "") {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.CacheTime == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetBotCallbackAnswerRequest from given interface.
func ( *MessagesSetBotCallbackAnswerRequest) ( interface {
	() ( bool)
	() ( int64)
	() ( string,  bool)
	() ( string,  bool)
	() ( int)
}) {
	.Alert = .()
	.QueryID = .()
	if ,  := .();  {
		.Message = 
	}

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

	.CacheTime = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSetBotCallbackAnswerRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setBotCallbackAnswer",
		ID:   MessagesSetBotCallbackAnswerRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Alert",
			SchemaName: "alert",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "URL",
			SchemaName: "url",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "CacheTime",
			SchemaName: "cache_time",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetBotCallbackAnswerRequest) () {
	if !(.Alert == false) {
		.Flags.Set(1)
	}
	if !(.Message == "") {
		.Flags.Set(0)
	}
	if !(.URL == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetBotCallbackAnswerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setBotCallbackAnswer#d58f130a as nil")
	}
	.PutID(MessagesSetBotCallbackAnswerRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetBotCallbackAnswerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setBotCallbackAnswer#d58f130a as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setBotCallbackAnswer#d58f130a: field flags: %w", )
	}
	.PutLong(.QueryID)
	if .Flags.Has(0) {
		.PutString(.Message)
	}
	if .Flags.Has(2) {
		.PutString(.URL)
	}
	.PutInt(.CacheTime)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetBotCallbackAnswerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setBotCallbackAnswer#d58f130a to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setBotCallbackAnswer#d58f130a: field flags: %w", )
		}
	}
	.Alert = .Flags.Has(1)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotCallbackAnswer#d58f130a: field query_id: %w", )
		}
		.QueryID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotCallbackAnswer#d58f130a: field message: %w", )
		}
		.Message = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotCallbackAnswer#d58f130a: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setBotCallbackAnswer#d58f130a: field cache_time: %w", )
		}
		.CacheTime = 
	}
	return nil
}

// SetAlert sets value of Alert conditional field.
func ( *MessagesSetBotCallbackAnswerRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Alert = true
	} else {
		.Flags.Unset(1)
		.Alert = false
	}
}

// GetAlert returns value of Alert conditional field.
func ( *MessagesSetBotCallbackAnswerRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// SetMessage sets value of Message conditional field.
func ( *MessagesSetBotCallbackAnswerRequest) ( string) {
	.Flags.Set(0)
	.Message = 
}

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

// SetURL sets value of URL conditional field.
func ( *MessagesSetBotCallbackAnswerRequest) ( string) {
	.Flags.Set(2)
	.URL = 
}

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

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

// MessagesSetBotCallbackAnswer invokes method messages.setBotCallbackAnswer#d58f130a returning error if any.
// Set the callback answer to a user button press (bots only)
//
// Possible errors:
//
//	400 MESSAGE_TOO_LONG: The provided message is too long.
//	400 QUERY_ID_INVALID: The query ID is invalid.
//	400 URL_INVALID: Invalid URL provided.
//	400 USER_BOT_REQUIRED: This method can only be called by a bot.
//
// See https://core.telegram.org/method/messages.setBotCallbackAnswer for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetBotCallbackAnswerRequest) (bool, error) {
	var  BoolBox

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