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

// ContactsResolveUsernameRequest represents TL type `contacts.resolveUsername#f93ccba3`.
// Resolve a @username to get peer info
//
// See https://core.telegram.org/method/contacts.resolveUsername for reference.
type ContactsResolveUsernameRequest struct {
	// @username to resolve
	Username string
}

// ContactsResolveUsernameRequestTypeID is TL type id of ContactsResolveUsernameRequest.
const ContactsResolveUsernameRequestTypeID = 0xf93ccba3

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

func ( *ContactsResolveUsernameRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Username == "") {
		return false
	}

	return true
}

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

// FillFrom fills ContactsResolveUsernameRequest from given interface.
func ( *ContactsResolveUsernameRequest) ( interface {
	() ( string)
}) {
	.Username = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ContactsResolveUsernameRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.resolveUsername",
		ID:   ContactsResolveUsernameRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Username",
			SchemaName: "username",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsResolveUsernameRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.resolveUsername#f93ccba3 as nil")
	}
	.PutID(ContactsResolveUsernameRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsResolveUsernameRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.resolveUsername#f93ccba3 as nil")
	}
	.PutString(.Username)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsResolveUsernameRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.resolveUsername#f93ccba3 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.resolveUsername#f93ccba3: field username: %w", )
		}
		.Username = 
	}
	return nil
}

// GetUsername returns value of Username field.
func ( *ContactsResolveUsernameRequest) () ( string) {
	if  == nil {
		return
	}
	return .Username
}

// ContactsResolveUsername invokes method contacts.resolveUsername#f93ccba3 returning error if any.
// Resolve a @username to get peer info
//
// Possible errors:
//
//	400 CONNECTION_LAYER_INVALID: Layer invalid.
//	400 USERNAME_INVALID: The provided username is not valid.
//	400 USERNAME_NOT_OCCUPIED: The provided username is not occupied.
//
// See https://core.telegram.org/method/contacts.resolveUsername for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  string) (*ContactsResolvedPeer, error) {
	var  ContactsResolvedPeer

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