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

// PhoneGroupCall represents TL type `phone.groupCall#9e727aad`.
// Contains info about a group call, and partial info about its participants.
//
// See https://core.telegram.org/constructor/phone.groupCall for reference.
type PhoneGroupCall struct {
	// Info about the group call
	Call GroupCallClass
	// A partial list of participants.
	Participants []GroupCallParticipant
	// Next offset to use when fetching the remaining participants using phone
	// getGroupParticipantsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/method/phone.getGroupParticipants
	ParticipantsNextOffset string
	// Chats mentioned in the participants vector
	Chats []ChatClass
	// Users mentioned in the participants vector
	Users []UserClass
}

// PhoneGroupCallTypeID is TL type id of PhoneGroupCall.
const PhoneGroupCallTypeID = 0x9e727aad

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

func ( *PhoneGroupCall) () bool {
	if  == nil {
		return true
	}
	if !(.Call == nil) {
		return false
	}
	if !(.Participants == nil) {
		return false
	}
	if !(.ParticipantsNextOffset == "") {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PhoneGroupCall from given interface.
func ( *PhoneGroupCall) ( interface {
	() ( GroupCallClass)
	() ( []GroupCallParticipant)
	() ( string)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Call = .()
	.Participants = .()
	.ParticipantsNextOffset = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*PhoneGroupCall) () string {
	return "phone.groupCall"
}

// TypeInfo returns info about TL type.
func ( *PhoneGroupCall) () tdp.Type {
	 := tdp.Type{
		Name: "phone.groupCall",
		ID:   PhoneGroupCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "Participants",
			SchemaName: "participants",
		},
		{
			Name:       "ParticipantsNextOffset",
			SchemaName: "participants_next_offset",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneGroupCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.groupCall#9e727aad as nil")
	}
	.PutID(PhoneGroupCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneGroupCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.groupCall#9e727aad as nil")
	}
	if .Call == nil {
		return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field call is nil")
	}
	if  := .Call.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field call: %w", )
	}
	.PutVectorHeader(len(.Participants))
	for ,  := range .Participants {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field participants element with index %d: %w", , )
		}
	}
	.PutString(.ParticipantsNextOffset)
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phone.groupCall#9e727aad: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneGroupCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.groupCall#9e727aad to nil")
	}
	if  := .ConsumeID(PhoneGroupCallTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.groupCall#9e727aad: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneGroupCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.groupCall#9e727aad to nil")
	}
	{
		,  := DecodeGroupCall()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupCall#9e727aad: field call: %w", )
		}
		.Call = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupCall#9e727aad: field participants: %w", )
		}

		if  > 0 {
			.Participants = make([]GroupCallParticipant, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  GroupCallParticipant
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode phone.groupCall#9e727aad: field participants: %w", )
			}
			.Participants = append(.Participants, )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupCall#9e727aad: field participants_next_offset: %w", )
		}
		.ParticipantsNextOffset = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupCall#9e727aad: field chats: %w", )
		}

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

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

// GetCall returns value of Call field.
func ( *PhoneGroupCall) () ( GroupCallClass) {
	if  == nil {
		return
	}
	return .Call
}

// GetParticipants returns value of Participants field.
func ( *PhoneGroupCall) () ( []GroupCallParticipant) {
	if  == nil {
		return
	}
	return .Participants
}

// GetParticipantsNextOffset returns value of ParticipantsNextOffset field.
func ( *PhoneGroupCall) () ( string) {
	if  == nil {
		return
	}
	return .ParticipantsNextOffset
}

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

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

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

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