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

// MessagesGetBotCallbackAnswerRequest represents TL type `messages.getBotCallbackAnswer#9342ca07`.
// Press an inline callback button and get a callback answer from the bot
//
// See https://core.telegram.org/method/messages.getBotCallbackAnswer for reference.
type MessagesGetBotCallbackAnswerRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a "play game" button
	Game bool
	// Where was the inline keyboard sent
	Peer InputPeerClass
	// ID of the Message with the inline keyboard
	MsgID int
	// Callback data
	//
	// Use SetData and GetData helpers.
	Data []byte
	// For buttons requiring you to verify your identity with your 2FA password¹, the SRP
	// payload generated using SRP².
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonCallback
	//  2) https://core.telegram.org/api/srp
	//
	// Use SetPassword and GetPassword helpers.
	Password InputCheckPasswordSRPClass
}

// MessagesGetBotCallbackAnswerRequestTypeID is TL type id of MessagesGetBotCallbackAnswerRequest.
const MessagesGetBotCallbackAnswerRequestTypeID = 0x9342ca07

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

func ( *MessagesGetBotCallbackAnswerRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Game == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.Data == nil) {
		return false
	}
	if !(.Password == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetBotCallbackAnswerRequest from given interface.
func ( *MessagesGetBotCallbackAnswerRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( int)
	() ( []byte,  bool)
	() ( InputCheckPasswordSRPClass,  bool)
}) {
	.Game = .()
	.Peer = .()
	.MsgID = .()
	if ,  := .();  {
		.Data = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetBotCallbackAnswerRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getBotCallbackAnswer",
		ID:   MessagesGetBotCallbackAnswerRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Game",
			SchemaName: "game",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "Data",
			SchemaName: "data",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Password",
			SchemaName: "password",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesGetBotCallbackAnswerRequest) () {
	if !(.Game == false) {
		.Flags.Set(1)
	}
	if !(.Data == nil) {
		.Flags.Set(0)
	}
	if !(.Password == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesGetBotCallbackAnswerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getBotCallbackAnswer#9342ca07 as nil")
	}
	.PutID(MessagesGetBotCallbackAnswerRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetBotCallbackAnswerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getBotCallbackAnswer#9342ca07 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getBotCallbackAnswer#9342ca07: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.getBotCallbackAnswer#9342ca07: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getBotCallbackAnswer#9342ca07: field peer: %w", )
	}
	.PutInt(.MsgID)
	if .Flags.Has(0) {
		.PutBytes(.Data)
	}
	if .Flags.Has(2) {
		if .Password == nil {
			return fmt.Errorf("unable to encode messages.getBotCallbackAnswer#9342ca07: field password is nil")
		}
		if  := .Password.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.getBotCallbackAnswer#9342ca07: field password: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetBotCallbackAnswerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getBotCallbackAnswer#9342ca07 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.getBotCallbackAnswer#9342ca07: field flags: %w", )
		}
	}
	.Game = .Flags.Has(1)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getBotCallbackAnswer#9342ca07: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getBotCallbackAnswer#9342ca07: field msg_id: %w", )
		}
		.MsgID = 
	}
	if .Flags.Has(0) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getBotCallbackAnswer#9342ca07: field data: %w", )
		}
		.Data = 
	}
	if .Flags.Has(2) {
		,  := DecodeInputCheckPasswordSRP()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getBotCallbackAnswer#9342ca07: field password: %w", )
		}
		.Password = 
	}
	return nil
}

// SetGame sets value of Game conditional field.
func ( *MessagesGetBotCallbackAnswerRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Game = true
	} else {
		.Flags.Unset(1)
		.Game = false
	}
}

// GetGame returns value of Game conditional field.
func ( *MessagesGetBotCallbackAnswerRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// GetMsgID returns value of MsgID field.
func ( *MessagesGetBotCallbackAnswerRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// SetData sets value of Data conditional field.
func ( *MessagesGetBotCallbackAnswerRequest) ( []byte) {
	.Flags.Set(0)
	.Data = 
}

// GetData returns value of Data conditional field and
// boolean which is true if field was set.
func ( *MessagesGetBotCallbackAnswerRequest) () ( []byte,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Data, true
}

// SetPassword sets value of Password conditional field.
func ( *MessagesGetBotCallbackAnswerRequest) ( InputCheckPasswordSRPClass) {
	.Flags.Set(2)
	.Password = 
}

// GetPassword returns value of Password conditional field and
// boolean which is true if field was set.
func ( *MessagesGetBotCallbackAnswerRequest) () ( InputCheckPasswordSRPClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Password, true
}

// GetPasswordAsNotEmpty returns mapped value of Password conditional field and
// boolean which is true if field was set.
func ( *MessagesGetBotCallbackAnswerRequest) () (*InputCheckPasswordSRP, bool) {
	if ,  := .GetPassword();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// MessagesGetBotCallbackAnswer invokes method messages.getBotCallbackAnswer#9342ca07 returning error if any.
// Press an inline callback button and get a callback answer from the bot
//
// Possible errors:
//
//	400 BOT_RESPONSE_TIMEOUT: A timeout occurred while fetching data from the bot.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 DATA_INVALID: Encrypted data invalid.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	-503 Timeout: Timeout while fetching data.
//
// See https://core.telegram.org/method/messages.getBotCallbackAnswer for reference.
func ( *Client) ( context.Context,  *MessagesGetBotCallbackAnswerRequest) (*MessagesBotCallbackAnswer, error) {
	var  MessagesBotCallbackAnswer

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