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

// PaymentsConnectedStarRefBots represents TL type `payments.connectedStarRefBots#98d5ea1d`.
// Active affiliations¹
//
// Links:
//  1. https://core.telegram.org/api/bots/referrals#becoming-an-affiliate
//
// See https://core.telegram.org/constructor/payments.connectedStarRefBots for reference.
type PaymentsConnectedStarRefBots struct {
	// Total number of active affiliations
	Count int
	// The affiliations
	ConnectedBots []ConnectedBotStarRef
	// Peers mentioned in connected_bots
	Users []UserClass
}

// PaymentsConnectedStarRefBotsTypeID is TL type id of PaymentsConnectedStarRefBots.
const PaymentsConnectedStarRefBotsTypeID = 0x98d5ea1d

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

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

	return true
}

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

// FillFrom fills PaymentsConnectedStarRefBots from given interface.
func ( *PaymentsConnectedStarRefBots) ( interface {
	() ( int)
	() ( []ConnectedBotStarRef)
	() ( []UserClass)
}) {
	.Count = .()
	.ConnectedBots = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsConnectedStarRefBots) () string {
	return "payments.connectedStarRefBots"
}

// TypeInfo returns info about TL type.
func ( *PaymentsConnectedStarRefBots) () tdp.Type {
	 := tdp.Type{
		Name: "payments.connectedStarRefBots",
		ID:   PaymentsConnectedStarRefBotsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "ConnectedBots",
			SchemaName: "connected_bots",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsConnectedStarRefBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.connectedStarRefBots#98d5ea1d as nil")
	}
	.PutID(PaymentsConnectedStarRefBotsTypeID)
	return .EncodeBare()
}

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

// Decode implements bin.Decoder.
func ( *PaymentsConnectedStarRefBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.connectedStarRefBots#98d5ea1d to nil")
	}
	if  := .ConsumeID(PaymentsConnectedStarRefBotsTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsConnectedStarRefBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.connectedStarRefBots#98d5ea1d to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field connected_bots: %w", )
		}

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

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

// GetCount returns value of Count field.
func ( *PaymentsConnectedStarRefBots) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

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

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

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