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

// ContactsAddContactRequest represents TL type `contacts.addContact#e8f463d0`.
// Add an existing telegram user as contact.
// Use contacts.importContacts¹ to add contacts by phone number, without knowing their
// Telegram ID.
//
// Links:
//  1. https://core.telegram.org/method/contacts.importContacts
//
// See https://core.telegram.org/method/contacts.addContact for reference.
type ContactsAddContactRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Allow the other user to see our phone number?
	AddPhonePrivacyException bool
	// Telegram ID of the other user
	ID InputUserClass
	// First name
	FirstName string
	// Last name
	LastName string
	// User's phone number, may be omitted to simply add the user to the contact list,
	// without a phone number.
	Phone string
}

// ContactsAddContactRequestTypeID is TL type id of ContactsAddContactRequest.
const ContactsAddContactRequestTypeID = 0xe8f463d0

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

func ( *ContactsAddContactRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.AddPhonePrivacyException == false) {
		return false
	}
	if !(.ID == nil) {
		return false
	}
	if !(.FirstName == "") {
		return false
	}
	if !(.LastName == "") {
		return false
	}
	if !(.Phone == "") {
		return false
	}

	return true
}

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

// FillFrom fills ContactsAddContactRequest from given interface.
func ( *ContactsAddContactRequest) ( interface {
	() ( bool)
	() ( InputUserClass)
	() ( string)
	() ( string)
	() ( string)
}) {
	.AddPhonePrivacyException = .()
	.ID = .()
	.FirstName = .()
	.LastName = .()
	.Phone = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ContactsAddContactRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.addContact",
		ID:   ContactsAddContactRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AddPhonePrivacyException",
			SchemaName: "add_phone_privacy_exception",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "FirstName",
			SchemaName: "first_name",
		},
		{
			Name:       "LastName",
			SchemaName: "last_name",
		},
		{
			Name:       "Phone",
			SchemaName: "phone",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ContactsAddContactRequest) () {
	if !(.AddPhonePrivacyException == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ContactsAddContactRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.addContact#e8f463d0 as nil")
	}
	.PutID(ContactsAddContactRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsAddContactRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.addContact#e8f463d0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.addContact#e8f463d0: field flags: %w", )
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode contacts.addContact#e8f463d0: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.addContact#e8f463d0: field id: %w", )
	}
	.PutString(.FirstName)
	.PutString(.LastName)
	.PutString(.Phone)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsAddContactRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.addContact#e8f463d0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode contacts.addContact#e8f463d0: field flags: %w", )
		}
	}
	.AddPhonePrivacyException = .Flags.Has(0)
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.addContact#e8f463d0: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.addContact#e8f463d0: field first_name: %w", )
		}
		.FirstName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.addContact#e8f463d0: field last_name: %w", )
		}
		.LastName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.addContact#e8f463d0: field phone: %w", )
		}
		.Phone = 
	}
	return nil
}

// SetAddPhonePrivacyException sets value of AddPhonePrivacyException conditional field.
func ( *ContactsAddContactRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.AddPhonePrivacyException = true
	} else {
		.Flags.Unset(0)
		.AddPhonePrivacyException = false
	}
}

// GetAddPhonePrivacyException returns value of AddPhonePrivacyException conditional field.
func ( *ContactsAddContactRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetID returns value of ID field.
func ( *ContactsAddContactRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .ID
}

// GetFirstName returns value of FirstName field.
func ( *ContactsAddContactRequest) () ( string) {
	if  == nil {
		return
	}
	return .FirstName
}

// GetLastName returns value of LastName field.
func ( *ContactsAddContactRequest) () ( string) {
	if  == nil {
		return
	}
	return .LastName
}

// GetPhone returns value of Phone field.
func ( *ContactsAddContactRequest) () ( string) {
	if  == nil {
		return
	}
	return .Phone
}

// ContactsAddContact invokes method contacts.addContact#e8f463d0 returning error if any.
// Add an existing telegram user as contact.
// Use contacts.importContacts¹ to add contacts by phone number, without knowing their
// Telegram ID.
//
// Links:
//  1. https://core.telegram.org/method/contacts.importContacts
//
// Possible errors:
//
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CONTACT_ID_INVALID: The provided contact ID is invalid.
//	400 CONTACT_NAME_EMPTY: Contact name empty.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//
// See https://core.telegram.org/method/contacts.addContact for reference.
func ( *Client) ( context.Context,  *ContactsAddContactRequest) (UpdatesClass, error) {
	var  UpdatesBox

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