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

// ContactsImportContactsRequest represents TL type `contacts.importContacts#2c800be5`.
// Imports contacts: saves a full list on the server, adds already registered contacts to
// the contact list, returns added contacts and their info.
// Use contacts.addContact¹ to add Telegram contacts without actually using their phone
// number.
//
// Links:
//  1. https://core.telegram.org/method/contacts.addContact
//
// See https://core.telegram.org/method/contacts.importContacts for reference.
type ContactsImportContactsRequest struct {
	// List of contacts to import
	Contacts []InputPhoneContact
}

// ContactsImportContactsRequestTypeID is TL type id of ContactsImportContactsRequest.
const ContactsImportContactsRequestTypeID = 0x2c800be5

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

func ( *ContactsImportContactsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Contacts == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsImportContactsRequest from given interface.
func ( *ContactsImportContactsRequest) ( interface {
	() ( []InputPhoneContact)
}) {
	.Contacts = .()
}

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

// TypeName returns name of type in TL schema.
func (*ContactsImportContactsRequest) () string {
	return "contacts.importContacts"
}

// TypeInfo returns info about TL type.
func ( *ContactsImportContactsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.importContacts",
		ID:   ContactsImportContactsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Contacts",
			SchemaName: "contacts",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsImportContactsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.importContacts#2c800be5 as nil")
	}
	.PutID(ContactsImportContactsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsImportContactsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.importContacts#2c800be5 as nil")
	}
	.PutVectorHeader(len(.Contacts))
	for ,  := range .Contacts {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.importContacts#2c800be5: field contacts element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ContactsImportContactsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.importContacts#2c800be5 to nil")
	}
	if  := .ConsumeID(ContactsImportContactsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode contacts.importContacts#2c800be5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ContactsImportContactsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.importContacts#2c800be5 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.importContacts#2c800be5: field contacts: %w", )
		}

		if  > 0 {
			.Contacts = make([]InputPhoneContact, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  InputPhoneContact
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode contacts.importContacts#2c800be5: field contacts: %w", )
			}
			.Contacts = append(.Contacts, )
		}
	}
	return nil
}

// GetContacts returns value of Contacts field.
func ( *ContactsImportContactsRequest) () ( []InputPhoneContact) {
	if  == nil {
		return
	}
	return .Contacts
}

// ContactsImportContacts invokes method contacts.importContacts#2c800be5 returning error if any.
// Imports contacts: saves a full list on the server, adds already registered contacts to
// the contact list, returns added contacts and their info.
// Use contacts.addContact¹ to add Telegram contacts without actually using their phone
// number.
//
// Links:
//  1. https://core.telegram.org/method/contacts.addContact
//
// See https://core.telegram.org/method/contacts.importContacts for reference.
func ( *Client) ( context.Context,  []InputPhoneContact) (*ContactsImportedContacts, error) {
	var  ContactsImportedContacts

	 := &ContactsImportContactsRequest{
		Contacts: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}