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

// ContactsUpdateContactNoteRequest represents TL type `contacts.updateContactNote#139f63fb`.
// Update the private note associated to a contact; see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/contacts#private-notes-for-contacts
//
// See https://core.telegram.org/method/contacts.updateContactNote for reference.
type ContactsUpdateContactNoteRequest struct {
	// The contact.
	ID InputUserClass
	// The note.
	Note TextWithEntities
}

// ContactsUpdateContactNoteRequestTypeID is TL type id of ContactsUpdateContactNoteRequest.
const ContactsUpdateContactNoteRequestTypeID = 0x139f63fb

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

func ( *ContactsUpdateContactNoteRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ID == nil) {
		return false
	}
	if !(.Note.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsUpdateContactNoteRequest from given interface.
func ( *ContactsUpdateContactNoteRequest) ( interface {
	() ( InputUserClass)
	() ( TextWithEntities)
}) {
	.ID = .()
	.Note = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ContactsUpdateContactNoteRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.updateContactNote",
		ID:   ContactsUpdateContactNoteRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Note",
			SchemaName: "note",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsUpdateContactNoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.updateContactNote#139f63fb as nil")
	}
	.PutID(ContactsUpdateContactNoteRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsUpdateContactNoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.updateContactNote#139f63fb as nil")
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode contacts.updateContactNote#139f63fb: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.updateContactNote#139f63fb: field id: %w", )
	}
	if  := .Note.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.updateContactNote#139f63fb: field note: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsUpdateContactNoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.updateContactNote#139f63fb to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.updateContactNote#139f63fb: field id: %w", )
		}
		.ID = 
	}
	{
		if  := .Note.Decode();  != nil {
			return fmt.Errorf("unable to decode contacts.updateContactNote#139f63fb: field note: %w", )
		}
	}
	return nil
}

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

// GetNote returns value of Note field.
func ( *ContactsUpdateContactNoteRequest) () ( TextWithEntities) {
	if  == nil {
		return
	}
	return .Note
}

// ContactsUpdateContactNote invokes method contacts.updateContactNote#139f63fb returning error if any.
// Update the private note associated to a contact; see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/contacts#private-notes-for-contacts
//
// Possible errors:
//
//	400 CONTACT_ID_INVALID: The provided contact ID is invalid.
//
// See https://core.telegram.org/method/contacts.updateContactNote for reference.
func ( *Client) ( context.Context,  *ContactsUpdateContactNoteRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}