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

// AccountConfirmPhoneRequest represents TL type `account.confirmPhone#5f2178c3`.
// Confirm a phone number to cancel account deletion, for more info click here »¹
//
// Links:
//  1. https://core.telegram.org/api/account-deletion
//
// See https://core.telegram.org/method/account.confirmPhone for reference.
type AccountConfirmPhoneRequest struct {
	// Phone code hash, for more info click here »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/account-deletion
	PhoneCodeHash string
	// SMS code, for more info click here »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/account-deletion
	PhoneCode string
}

// AccountConfirmPhoneRequestTypeID is TL type id of AccountConfirmPhoneRequest.
const AccountConfirmPhoneRequestTypeID = 0x5f2178c3

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

func ( *AccountConfirmPhoneRequest) () bool {
	if  == nil {
		return true
	}
	if !(.PhoneCodeHash == "") {
		return false
	}
	if !(.PhoneCode == "") {
		return false
	}

	return true
}

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

// FillFrom fills AccountConfirmPhoneRequest from given interface.
func ( *AccountConfirmPhoneRequest) ( interface {
	() ( string)
	() ( string)
}) {
	.PhoneCodeHash = .()
	.PhoneCode = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountConfirmPhoneRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.confirmPhone",
		ID:   AccountConfirmPhoneRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PhoneCodeHash",
			SchemaName: "phone_code_hash",
		},
		{
			Name:       "PhoneCode",
			SchemaName: "phone_code",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountConfirmPhoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.confirmPhone#5f2178c3 as nil")
	}
	.PutID(AccountConfirmPhoneRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountConfirmPhoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.confirmPhone#5f2178c3 as nil")
	}
	.PutString(.PhoneCodeHash)
	.PutString(.PhoneCode)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountConfirmPhoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.confirmPhone#5f2178c3 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.confirmPhone#5f2178c3: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.confirmPhone#5f2178c3: field phone_code: %w", )
		}
		.PhoneCode = 
	}
	return nil
}

// GetPhoneCodeHash returns value of PhoneCodeHash field.
func ( *AccountConfirmPhoneRequest) () ( string) {
	if  == nil {
		return
	}
	return .PhoneCodeHash
}

// GetPhoneCode returns value of PhoneCode field.
func ( *AccountConfirmPhoneRequest) () ( string) {
	if  == nil {
		return
	}
	return .PhoneCode
}

// AccountConfirmPhone invokes method account.confirmPhone#5f2178c3 returning error if any.
// Confirm a phone number to cancel account deletion, for more info click here »¹
//
// Links:
//  1. https://core.telegram.org/api/account-deletion
//
// Possible errors:
//
//	400 CODE_HASH_INVALID: Code hash invalid.
//	400 PHONE_CODE_EMPTY: phone_code is missing.
//
// See https://core.telegram.org/method/account.confirmPhone for reference.
func ( *Client) ( context.Context,  *AccountConfirmPhoneRequest) (bool, error) {
	var  BoolBox

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