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

// AccountUpdateConnectedBotRequest represents TL type `account.updateConnectedBot#66a08c7e`.
// Connect a business bot »¹ to the current account, or to change the current
// connection settings.
//
// Links:
//  1. https://core.telegram.org/api/bots/connected-business-bots
//
// See https://core.telegram.org/method/account.updateConnectedBot for reference.
type AccountUpdateConnectedBotRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to fully disconnect the bot from the current account.
	Deleted bool
	// Business bot rights.
	//
	// Use SetRights and GetRights helpers.
	Rights BusinessBotRights
	// The bot to connect or disconnect
	Bot InputUserClass
	// Configuration for the business connection
	Recipients InputBusinessBotRecipients
}

// AccountUpdateConnectedBotRequestTypeID is TL type id of AccountUpdateConnectedBotRequest.
const AccountUpdateConnectedBotRequestTypeID = 0x66a08c7e

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

func ( *AccountUpdateConnectedBotRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Deleted == false) {
		return false
	}
	if !(.Rights.Zero()) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.Recipients.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountUpdateConnectedBotRequest from given interface.
func ( *AccountUpdateConnectedBotRequest) ( interface {
	() ( bool)
	() ( BusinessBotRights,  bool)
	() ( InputUserClass)
	() ( InputBusinessBotRecipients)
}) {
	.Deleted = .()
	if ,  := .();  {
		.Rights = 
	}

	.Bot = .()
	.Recipients = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountUpdateConnectedBotRequest) () string {
	return "account.updateConnectedBot"
}

// TypeInfo returns info about TL type.
func ( *AccountUpdateConnectedBotRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.updateConnectedBot",
		ID:   AccountUpdateConnectedBotRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Deleted",
			SchemaName: "deleted",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Rights",
			SchemaName: "rights",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "Recipients",
			SchemaName: "recipients",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountUpdateConnectedBotRequest) () {
	if !(.Deleted == false) {
		.Flags.Set(1)
	}
	if !(.Rights.Zero()) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountUpdateConnectedBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateConnectedBot#66a08c7e as nil")
	}
	.PutID(AccountUpdateConnectedBotRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUpdateConnectedBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateConnectedBot#66a08c7e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updateConnectedBot#66a08c7e: field flags: %w", )
	}
	if .Flags.Has(0) {
		if  := .Rights.Encode();  != nil {
			return fmt.Errorf("unable to encode account.updateConnectedBot#66a08c7e: field rights: %w", )
		}
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode account.updateConnectedBot#66a08c7e: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updateConnectedBot#66a08c7e: field bot: %w", )
	}
	if  := .Recipients.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updateConnectedBot#66a08c7e: field recipients: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountUpdateConnectedBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updateConnectedBot#66a08c7e to nil")
	}
	if  := .ConsumeID(AccountUpdateConnectedBotRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.updateConnectedBot#66a08c7e: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountUpdateConnectedBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updateConnectedBot#66a08c7e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updateConnectedBot#66a08c7e: field flags: %w", )
		}
	}
	.Deleted = .Flags.Has(1)
	if .Flags.Has(0) {
		if  := .Rights.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updateConnectedBot#66a08c7e: field rights: %w", )
		}
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateConnectedBot#66a08c7e: field bot: %w", )
		}
		.Bot = 
	}
	{
		if  := .Recipients.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updateConnectedBot#66a08c7e: field recipients: %w", )
		}
	}
	return nil
}

// SetDeleted sets value of Deleted conditional field.
func ( *AccountUpdateConnectedBotRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Deleted = true
	} else {
		.Flags.Unset(1)
		.Deleted = false
	}
}

// GetDeleted returns value of Deleted conditional field.
func ( *AccountUpdateConnectedBotRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetRights sets value of Rights conditional field.
func ( *AccountUpdateConnectedBotRequest) ( BusinessBotRights) {
	.Flags.Set(0)
	.Rights = 
}

// GetRights returns value of Rights conditional field and
// boolean which is true if field was set.
func ( *AccountUpdateConnectedBotRequest) () ( BusinessBotRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Rights, true
}

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

// GetRecipients returns value of Recipients field.
func ( *AccountUpdateConnectedBotRequest) () ( InputBusinessBotRecipients) {
	if  == nil {
		return
	}
	return .Recipients
}

// AccountUpdateConnectedBot invokes method account.updateConnectedBot#66a08c7e returning error if any.
// Connect a business bot »¹ to the current account, or to change the current
// connection settings.
//
// Links:
//  1. https://core.telegram.org/api/bots/connected-business-bots
//
// Possible errors:
//
//	400 BOT_BUSINESS_MISSING: The specified bot is not a business bot (the user.bot_business flag is not set).
//	400 BUSINESS_RECIPIENTS_EMPTY: You didn't set any flag in inputBusinessBotRecipients, thus the bot cannot work with any peer.
//	403 PREMIUM_ACCOUNT_REQUIRED: A premium account is required to execute this action.
//
// See https://core.telegram.org/method/account.updateConnectedBot for reference.
func ( *Client) ( context.Context,  *AccountUpdateConnectedBotRequest) (UpdatesClass, error) {
	var  UpdatesBox

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