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

// MessagesBotApp represents TL type `messages.botApp#eb50adf5`.
// Contains information about a named Mini App¹
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#named-mini-apps
//
// See https://core.telegram.org/constructor/messages.botApp for reference.
type MessagesBotApp struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the web app was never used by the user, and confirmation must be asked from
	// the user before opening it.
	Inactive bool
	// The bot is asking permission to send messages to the user: if the user agrees, set the
	// write_allowed flag when invoking messages.requestAppWebView¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.requestAppWebView
	RequestWriteAccess bool
	// Deprecated flag, can be ignored.
	HasSettings bool
	// Bot app information
	App BotAppClass
}

// MessagesBotAppTypeID is TL type id of MessagesBotApp.
const MessagesBotAppTypeID = 0xeb50adf5

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

func ( *MessagesBotApp) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Inactive == false) {
		return false
	}
	if !(.RequestWriteAccess == false) {
		return false
	}
	if !(.HasSettings == false) {
		return false
	}
	if !(.App == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesBotApp from given interface.
func ( *MessagesBotApp) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( BotAppClass)
}) {
	.Inactive = .()
	.RequestWriteAccess = .()
	.HasSettings = .()
	.App = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesBotApp) () tdp.Type {
	 := tdp.Type{
		Name: "messages.botApp",
		ID:   MessagesBotAppTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Inactive",
			SchemaName: "inactive",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "RequestWriteAccess",
			SchemaName: "request_write_access",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "HasSettings",
			SchemaName: "has_settings",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "App",
			SchemaName: "app",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesBotApp) () {
	if !(.Inactive == false) {
		.Flags.Set(0)
	}
	if !(.RequestWriteAccess == false) {
		.Flags.Set(1)
	}
	if !(.HasSettings == false) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesBotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.botApp#eb50adf5 as nil")
	}
	.PutID(MessagesBotAppTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesBotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.botApp#eb50adf5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.botApp#eb50adf5: field flags: %w", )
	}
	if .App == nil {
		return fmt.Errorf("unable to encode messages.botApp#eb50adf5: field app is nil")
	}
	if  := .App.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.botApp#eb50adf5: field app: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesBotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.botApp#eb50adf5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.botApp#eb50adf5: field flags: %w", )
		}
	}
	.Inactive = .Flags.Has(0)
	.RequestWriteAccess = .Flags.Has(1)
	.HasSettings = .Flags.Has(2)
	{
		,  := DecodeBotApp()
		if  != nil {
			return fmt.Errorf("unable to decode messages.botApp#eb50adf5: field app: %w", )
		}
		.App = 
	}
	return nil
}

// SetInactive sets value of Inactive conditional field.
func ( *MessagesBotApp) ( bool) {
	if  {
		.Flags.Set(0)
		.Inactive = true
	} else {
		.Flags.Unset(0)
		.Inactive = false
	}
}

// GetInactive returns value of Inactive conditional field.
func ( *MessagesBotApp) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetRequestWriteAccess sets value of RequestWriteAccess conditional field.
func ( *MessagesBotApp) ( bool) {
	if  {
		.Flags.Set(1)
		.RequestWriteAccess = true
	} else {
		.Flags.Unset(1)
		.RequestWriteAccess = false
	}
}

// GetRequestWriteAccess returns value of RequestWriteAccess conditional field.
func ( *MessagesBotApp) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetHasSettings sets value of HasSettings conditional field.
func ( *MessagesBotApp) ( bool) {
	if  {
		.Flags.Set(2)
		.HasSettings = true
	} else {
		.Flags.Unset(2)
		.HasSettings = false
	}
}

// GetHasSettings returns value of HasSettings conditional field.
func ( *MessagesBotApp) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetApp returns value of App field.
func ( *MessagesBotApp) () ( BotAppClass) {
	if  == nil {
		return
	}
	return .App
}

// GetAppAsModified returns mapped value of App field.
func ( *MessagesBotApp) () (*BotApp, bool) {
	return .App.AsModified()
}