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

// AccountConnectedBots represents TL type `account.connectedBots#17d7f87b`.
// Info about currently connected business bots¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/connected-business-bots
//
// See https://core.telegram.org/constructor/account.connectedBots for reference.
type AccountConnectedBots struct {
	// Info about the connected bots
	ConnectedBots []ConnectedBot
	// Bot information
	Users []UserClass
}

// AccountConnectedBotsTypeID is TL type id of AccountConnectedBots.
const AccountConnectedBotsTypeID = 0x17d7f87b

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

func ( *AccountConnectedBots) () bool {
	if  == nil {
		return true
	}
	if !(.ConnectedBots == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountConnectedBots from given interface.
func ( *AccountConnectedBots) ( interface {
	() ( []ConnectedBot)
	() ( []UserClass)
}) {
	.ConnectedBots = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountConnectedBots) () tdp.Type {
	 := tdp.Type{
		Name: "account.connectedBots",
		ID:   AccountConnectedBotsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ConnectedBots",
			SchemaName: "connected_bots",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountConnectedBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.connectedBots#17d7f87b as nil")
	}
	.PutID(AccountConnectedBotsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountConnectedBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.connectedBots#17d7f87b as nil")
	}
	.PutVectorHeader(len(.ConnectedBots))
	for ,  := range .ConnectedBots {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.connectedBots#17d7f87b: field connected_bots element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode account.connectedBots#17d7f87b: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.connectedBots#17d7f87b: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountConnectedBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.connectedBots#17d7f87b to nil")
	}
	if  := .ConsumeID(AccountConnectedBotsTypeID);  != nil {
		return fmt.Errorf("unable to decode account.connectedBots#17d7f87b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountConnectedBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.connectedBots#17d7f87b to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.connectedBots#17d7f87b: field connected_bots: %w", )
		}

		if  > 0 {
			.ConnectedBots = make([]ConnectedBot, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ConnectedBot
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.connectedBots#17d7f87b: field connected_bots: %w", )
			}
			.ConnectedBots = append(.ConnectedBots, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.connectedBots#17d7f87b: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode account.connectedBots#17d7f87b: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetConnectedBots returns value of ConnectedBots field.
func ( *AccountConnectedBots) () ( []ConnectedBot) {
	if  == nil {
		return
	}
	return .ConnectedBots
}

// GetUsers returns value of Users field.
func ( *AccountConnectedBots) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *AccountConnectedBots) () ( UserClassArray) {
	return UserClassArray(.Users)
}