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

// MessagesBotCallbackAnswer represents TL type `messages.botCallbackAnswer#36585ea4`.
// Callback answer sent by the bot in response to a button press
//
// See https://core.telegram.org/constructor/messages.botCallbackAnswer for reference.
type MessagesBotCallbackAnswer struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether an alert should be shown to the user instead of a toast notification
	Alert bool
	// Whether an URL is present
	HasURL bool
	// Whether to show games in WebView or in native UI.
	NativeUI bool
	// Alert to show
	//
	// Use SetMessage and GetMessage helpers.
	Message string
	// URL to open
	//
	// Use SetURL and GetURL helpers.
	URL string
	// For how long should this answer be cached
	CacheTime int
}

// MessagesBotCallbackAnswerTypeID is TL type id of MessagesBotCallbackAnswer.
const MessagesBotCallbackAnswerTypeID = 0x36585ea4

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

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

	return true
}

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

// FillFrom fills MessagesBotCallbackAnswer from given interface.
func ( *MessagesBotCallbackAnswer) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( int)
}) {
	.Alert = .()
	.HasURL = .()
	.NativeUI = .()
	if ,  := .();  {
		.Message = 
	}

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

	.CacheTime = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesBotCallbackAnswer) () tdp.Type {
	 := tdp.Type{
		Name: "messages.botCallbackAnswer",
		ID:   MessagesBotCallbackAnswerTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Alert",
			SchemaName: "alert",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "HasURL",
			SchemaName: "has_url",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "NativeUI",
			SchemaName: "native_ui",
			Null:       !.Flags.Has(4),
		},
		{
			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 ( *MessagesBotCallbackAnswer) () {
	if !(.Alert == false) {
		.Flags.Set(1)
	}
	if !(.HasURL == false) {
		.Flags.Set(3)
	}
	if !(.NativeUI == false) {
		.Flags.Set(4)
	}
	if !(.Message == "") {
		.Flags.Set(0)
	}
	if !(.URL == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesBotCallbackAnswer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.botCallbackAnswer#36585ea4 as nil")
	}
	.PutID(MessagesBotCallbackAnswerTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesBotCallbackAnswer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.botCallbackAnswer#36585ea4 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.botCallbackAnswer#36585ea4: field flags: %w", )
		}
	}
	.Alert = .Flags.Has(1)
	.HasURL = .Flags.Has(3)
	.NativeUI = .Flags.Has(4)
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.botCallbackAnswer#36585ea4: field message: %w", )
		}
		.Message = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.botCallbackAnswer#36585ea4: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.botCallbackAnswer#36585ea4: field cache_time: %w", )
		}
		.CacheTime = 
	}
	return nil
}

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

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

// SetHasURL sets value of HasURL conditional field.
func ( *MessagesBotCallbackAnswer) ( bool) {
	if  {
		.Flags.Set(3)
		.HasURL = true
	} else {
		.Flags.Unset(3)
		.HasURL = false
	}
}

// GetHasURL returns value of HasURL conditional field.
func ( *MessagesBotCallbackAnswer) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetNativeUI sets value of NativeUI conditional field.
func ( *MessagesBotCallbackAnswer) ( bool) {
	if  {
		.Flags.Set(4)
		.NativeUI = true
	} else {
		.Flags.Unset(4)
		.NativeUI = false
	}
}

// GetNativeUI returns value of NativeUI conditional field.
func ( *MessagesBotCallbackAnswer) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

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

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

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

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

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