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

// AccountCheckUsernameRequest represents TL type `account.checkUsername#2714d86c`.
// Validates a username and checks availability.
//
// See https://core.telegram.org/method/account.checkUsername for reference.
type AccountCheckUsernameRequest struct {
	// usernameAccepted characters: A-z (case-insensitive), 0-9 and underscores.Length: 5-32
	// characters.
	Username string
}

// AccountCheckUsernameRequestTypeID is TL type id of AccountCheckUsernameRequest.
const AccountCheckUsernameRequestTypeID = 0x2714d86c

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

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

	return true
}

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

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

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

// TypeName returns name of type in TL schema.
func (*AccountCheckUsernameRequest) () string {
	return "account.checkUsername"
}

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

// Encode implements bin.Encoder.
func ( *AccountCheckUsernameRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.checkUsername#2714d86c as nil")
	}
	.PutID(AccountCheckUsernameRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountCheckUsernameRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.checkUsername#2714d86c as nil")
	}
	.PutString(.Username)
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountCheckUsernameRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.checkUsername#2714d86c to nil")
	}
	if  := .ConsumeID(AccountCheckUsernameRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.checkUsername#2714d86c: %w", )
	}
	return .DecodeBare()
}

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

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

// AccountCheckUsername invokes method account.checkUsername#2714d86c returning error if any.
// Validates a username and checks availability.
//
// Possible errors:
//
//	400 USERNAME_INVALID: The provided username is not valid.
//	400 USERNAME_OCCUPIED: The provided username is already occupied.
//	400 USERNAME_PURCHASE_AVAILABLE: The specified username can be purchased on https://fragment.com.
//
// See https://core.telegram.org/method/account.checkUsername for reference.
func ( *Client) ( context.Context,  string) (bool, error) {
	var  BoolBox

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