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

// AccountBusinessChatLinks represents TL type `account.businessChatLinks#ec43a2d1`.
// Contains info about business chat deep links »¹ created by the current account.
//
// Links:
//  1. https://core.telegram.org/api/business#business-chat-links
//
// See https://core.telegram.org/constructor/account.businessChatLinks for reference.
type AccountBusinessChatLinks struct {
	// Links
	Links []BusinessChatLink
	// Mentioned chats
	Chats []ChatClass
	// Mentioned users
	Users []UserClass
}

// AccountBusinessChatLinksTypeID is TL type id of AccountBusinessChatLinks.
const AccountBusinessChatLinksTypeID = 0xec43a2d1

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

func ( *AccountBusinessChatLinks) () bool {
	if  == nil {
		return true
	}
	if !(.Links == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountBusinessChatLinks from given interface.
func ( *AccountBusinessChatLinks) ( interface {
	() ( []BusinessChatLink)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Links = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountBusinessChatLinks) () tdp.Type {
	 := tdp.Type{
		Name: "account.businessChatLinks",
		ID:   AccountBusinessChatLinksTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Links",
			SchemaName: "links",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountBusinessChatLinks) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.businessChatLinks#ec43a2d1 as nil")
	}
	.PutID(AccountBusinessChatLinksTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountBusinessChatLinks) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.businessChatLinks#ec43a2d1 as nil")
	}
	.PutVectorHeader(len(.Links))
	for ,  := range .Links {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.businessChatLinks#ec43a2d1: field links element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode account.businessChatLinks#ec43a2d1: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.businessChatLinks#ec43a2d1: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode account.businessChatLinks#ec43a2d1: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.businessChatLinks#ec43a2d1: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

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

		if  > 0 {
			.Links = make([]BusinessChatLink, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  BusinessChatLink
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.businessChatLinks#ec43a2d1: field links: %w", )
			}
			.Links = append(.Links, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.businessChatLinks#ec43a2d1: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode account.businessChatLinks#ec43a2d1: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.businessChatLinks#ec43a2d1: field users: %w", )
		}

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

// GetLinks returns value of Links field.
func ( *AccountBusinessChatLinks) () ( []BusinessChatLink) {
	if  == nil {
		return
	}
	return .Links
}

// GetChats returns value of Chats field.
func ( *AccountBusinessChatLinks) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

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

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *AccountBusinessChatLinks) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

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