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

// PopularContact represents TL type `popularContact#5ce14175`.
// Popular contact
//
// See https://core.telegram.org/constructor/popularContact for reference.
type PopularContact struct {
	// Contact identifier
	ClientID int64
	// How many people imported this contact
	Importers int
}

// PopularContactTypeID is TL type id of PopularContact.
const PopularContactTypeID = 0x5ce14175

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

func ( *PopularContact) () bool {
	if  == nil {
		return true
	}
	if !(.ClientID == 0) {
		return false
	}
	if !(.Importers == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PopularContact from given interface.
func ( *PopularContact) ( interface {
	() ( int64)
	() ( int)
}) {
	.ClientID = .()
	.Importers = .()
}

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

// TypeName returns name of type in TL schema.
func (*PopularContact) () string {
	return "popularContact"
}

// TypeInfo returns info about TL type.
func ( *PopularContact) () tdp.Type {
	 := tdp.Type{
		Name: "popularContact",
		ID:   PopularContactTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ClientID",
			SchemaName: "client_id",
		},
		{
			Name:       "Importers",
			SchemaName: "importers",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PopularContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode popularContact#5ce14175 as nil")
	}
	.PutID(PopularContactTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PopularContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode popularContact#5ce14175 as nil")
	}
	.PutLong(.ClientID)
	.PutInt(.Importers)
	return nil
}

// Decode implements bin.Decoder.
func ( *PopularContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode popularContact#5ce14175 to nil")
	}
	if  := .ConsumeID(PopularContactTypeID);  != nil {
		return fmt.Errorf("unable to decode popularContact#5ce14175: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PopularContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode popularContact#5ce14175 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode popularContact#5ce14175: field client_id: %w", )
		}
		.ClientID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode popularContact#5ce14175: field importers: %w", )
		}
		.Importers = 
	}
	return nil
}

// GetClientID returns value of ClientID field.
func ( *PopularContact) () ( int64) {
	if  == nil {
		return
	}
	return .ClientID
}

// GetImporters returns value of Importers field.
func ( *PopularContact) () ( int) {
	if  == nil {
		return
	}
	return .Importers
}