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

// SavedPhoneContact represents TL type `savedPhoneContact#1142bd56`.
// Saved contact
//
// See https://core.telegram.org/constructor/savedPhoneContact for reference.
type SavedPhoneContact struct {
	// Phone number
	Phone string
	// First name
	FirstName string
	// Last name
	LastName string
	// Date added
	Date int
}

// SavedPhoneContactTypeID is TL type id of SavedPhoneContact.
const SavedPhoneContactTypeID = 0x1142bd56

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

func ( *SavedPhoneContact) () bool {
	if  == nil {
		return true
	}
	if !(.Phone == "") {
		return false
	}
	if !(.FirstName == "") {
		return false
	}
	if !(.LastName == "") {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills SavedPhoneContact from given interface.
func ( *SavedPhoneContact) ( interface {
	() ( string)
	() ( string)
	() ( string)
	() ( int)
}) {
	.Phone = .()
	.FirstName = .()
	.LastName = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SavedPhoneContact) () tdp.Type {
	 := tdp.Type{
		Name: "savedPhoneContact",
		ID:   SavedPhoneContactTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Phone",
			SchemaName: "phone",
		},
		{
			Name:       "FirstName",
			SchemaName: "first_name",
		},
		{
			Name:       "LastName",
			SchemaName: "last_name",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SavedPhoneContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode savedPhoneContact#1142bd56 as nil")
	}
	.PutID(SavedPhoneContactTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SavedPhoneContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode savedPhoneContact#1142bd56 as nil")
	}
	.PutString(.Phone)
	.PutString(.FirstName)
	.PutString(.LastName)
	.PutInt(.Date)
	return nil
}

// Decode implements bin.Decoder.
func ( *SavedPhoneContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode savedPhoneContact#1142bd56 to nil")
	}
	if  := .ConsumeID(SavedPhoneContactTypeID);  != nil {
		return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *SavedPhoneContact) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode savedPhoneContact#1142bd56 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field phone: %w", )
		}
		.Phone = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field first_name: %w", )
		}
		.FirstName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field last_name: %w", )
		}
		.LastName = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field date: %w", )
		}
		.Date = 
	}
	return nil
}

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

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

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

// GetDate returns value of Date field.
func ( *SavedPhoneContact) () ( int) {
	if  == nil {
		return
	}
	return .Date
}