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

// AccountUpdateProfileRequest represents TL type `account.updateProfile#78515775`.
// Updates user profile.
//
// See https://core.telegram.org/method/account.updateProfile for reference.
type AccountUpdateProfileRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// New user first name
	//
	// Use SetFirstName and GetFirstName helpers.
	FirstName string
	// New user last name
	//
	// Use SetLastName and GetLastName helpers.
	LastName string
	// New bio
	//
	// Use SetAbout and GetAbout helpers.
	About string
}

// AccountUpdateProfileRequestTypeID is TL type id of AccountUpdateProfileRequest.
const AccountUpdateProfileRequestTypeID = 0x78515775

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

func ( *AccountUpdateProfileRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.FirstName == "") {
		return false
	}
	if !(.LastName == "") {
		return false
	}
	if !(.About == "") {
		return false
	}

	return true
}

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

// FillFrom fills AccountUpdateProfileRequest from given interface.
func ( *AccountUpdateProfileRequest) ( interface {
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
}) {
	if ,  := .();  {
		.FirstName = 
	}

	if ,  := .();  {
		.LastName = 
	}

	if ,  := .();  {
		.About = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *AccountUpdateProfileRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.updateProfile",
		ID:   AccountUpdateProfileRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FirstName",
			SchemaName: "first_name",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "LastName",
			SchemaName: "last_name",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "About",
			SchemaName: "about",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountUpdateProfileRequest) () {
	if !(.FirstName == "") {
		.Flags.Set(0)
	}
	if !(.LastName == "") {
		.Flags.Set(1)
	}
	if !(.About == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *AccountUpdateProfileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateProfile#78515775 as nil")
	}
	.PutID(AccountUpdateProfileRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUpdateProfileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateProfile#78515775 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updateProfile#78515775: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.FirstName)
	}
	if .Flags.Has(1) {
		.PutString(.LastName)
	}
	if .Flags.Has(2) {
		.PutString(.About)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountUpdateProfileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updateProfile#78515775 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updateProfile#78515775: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateProfile#78515775: field first_name: %w", )
		}
		.FirstName = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateProfile#78515775: field last_name: %w", )
		}
		.LastName = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateProfile#78515775: field about: %w", )
		}
		.About = 
	}
	return nil
}

// SetFirstName sets value of FirstName conditional field.
func ( *AccountUpdateProfileRequest) ( string) {
	.Flags.Set(0)
	.FirstName = 
}

// GetFirstName returns value of FirstName conditional field and
// boolean which is true if field was set.
func ( *AccountUpdateProfileRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .FirstName, true
}

// SetLastName sets value of LastName conditional field.
func ( *AccountUpdateProfileRequest) ( string) {
	.Flags.Set(1)
	.LastName = 
}

// GetLastName returns value of LastName conditional field and
// boolean which is true if field was set.
func ( *AccountUpdateProfileRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .LastName, true
}

// SetAbout sets value of About conditional field.
func ( *AccountUpdateProfileRequest) ( string) {
	.Flags.Set(2)
	.About = 
}

// GetAbout returns value of About conditional field and
// boolean which is true if field was set.
func ( *AccountUpdateProfileRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .About, true
}

// AccountUpdateProfile invokes method account.updateProfile#78515775 returning error if any.
// Updates user profile.
//
// Possible errors:
//
//	400 ABOUT_TOO_LONG: About string too long.
//	400 FIRSTNAME_INVALID: The first name is invalid.
//
// See https://core.telegram.org/method/account.updateProfile for reference.
func ( *Client) ( context.Context,  *AccountUpdateProfileRequest) (UserClass, error) {
	var  UserBox

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