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

// AccountDeleteAccountRequest represents TL type `account.deleteAccount#a2c0cf74`.
// Delete the user's account from the telegram servers.
// Can also be used to delete the account of a user that provided the login code, but
// forgot the 2FA password and no recovery method is configured, see here »¹ for more
// info on password recovery, and here »² for more info on account deletion.
//
// Links:
//  1. https://core.telegram.org/api/srp#password-recovery
//  2. https://core.telegram.org/api/account-deletion
//
// See https://core.telegram.org/method/account.deleteAccount for reference.
type AccountDeleteAccountRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Why is the account being deleted, can be empty
	Reason string
	// 2FA password¹: this field can be omitted even for accounts with 2FA enabled: in this
	// case account account deletion will be delayed by 7 days as specified in the docs »²
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	//  2) https://core.telegram.org/api/account-deletion
	//
	// Use SetPassword and GetPassword helpers.
	Password InputCheckPasswordSRPClass
}

// AccountDeleteAccountRequestTypeID is TL type id of AccountDeleteAccountRequest.
const AccountDeleteAccountRequestTypeID = 0xa2c0cf74

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

func ( *AccountDeleteAccountRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Reason == "") {
		return false
	}
	if !(.Password == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountDeleteAccountRequest from given interface.
func ( *AccountDeleteAccountRequest) ( interface {
	() ( string)
	() ( InputCheckPasswordSRPClass,  bool)
}) {
	.Reason = .()
	if ,  := .();  {
		.Password = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *AccountDeleteAccountRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.deleteAccount",
		ID:   AccountDeleteAccountRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Reason",
			SchemaName: "reason",
		},
		{
			Name:       "Password",
			SchemaName: "password",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountDeleteAccountRequest) () {
	if !(.Password == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountDeleteAccountRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.deleteAccount#a2c0cf74 as nil")
	}
	.PutID(AccountDeleteAccountRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountDeleteAccountRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.deleteAccount#a2c0cf74 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.deleteAccount#a2c0cf74: field flags: %w", )
	}
	.PutString(.Reason)
	if .Flags.Has(0) {
		if .Password == nil {
			return fmt.Errorf("unable to encode account.deleteAccount#a2c0cf74: field password is nil")
		}
		if  := .Password.Encode();  != nil {
			return fmt.Errorf("unable to encode account.deleteAccount#a2c0cf74: field password: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountDeleteAccountRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.deleteAccount#a2c0cf74 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.deleteAccount#a2c0cf74: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.deleteAccount#a2c0cf74: field reason: %w", )
		}
		.Reason = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputCheckPasswordSRP()
		if  != nil {
			return fmt.Errorf("unable to decode account.deleteAccount#a2c0cf74: field password: %w", )
		}
		.Password = 
	}
	return nil
}

// GetReason returns value of Reason field.
func ( *AccountDeleteAccountRequest) () ( string) {
	if  == nil {
		return
	}
	return .Reason
}

// SetPassword sets value of Password conditional field.
func ( *AccountDeleteAccountRequest) ( InputCheckPasswordSRPClass) {
	.Flags.Set(0)
	.Password = 
}

// GetPassword returns value of Password conditional field and
// boolean which is true if field was set.
func ( *AccountDeleteAccountRequest) () ( InputCheckPasswordSRPClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Password, true
}

// GetPasswordAsNotEmpty returns mapped value of Password conditional field and
// boolean which is true if field was set.
func ( *AccountDeleteAccountRequest) () (*InputCheckPasswordSRP, bool) {
	if ,  := .GetPassword();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// AccountDeleteAccount invokes method account.deleteAccount#a2c0cf74 returning error if any.
// Delete the user's account from the telegram servers.
// Can also be used to delete the account of a user that provided the login code, but
// forgot the 2FA password and no recovery method is configured, see here »¹ for more
// info on password recovery, and here »² for more info on account deletion.
//
// Links:
//  1. https://core.telegram.org/api/srp#password-recovery
//  2. https://core.telegram.org/api/account-deletion
//
// Possible errors:
//
//	420 2FA_CONFIRM_WAIT_%d: Since this account is active and protected by a 2FA password, we will delete it in 1 week for security purposes. You can cancel this process at any time, you'll be able to reset your account in %d seconds.
//
// See https://core.telegram.org/method/account.deleteAccount for reference.
func ( *Client) ( context.Context,  *AccountDeleteAccountRequest) (bool, error) {
	var  BoolBox

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