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

// AuthResendCodeRequest represents TL type `auth.resendCode#cae47523`.
// Resend the login code via another medium, the phone code type is determined by the
// return value of the previous auth.sendCode/auth.resendCode: see login¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/auth
//
// See https://core.telegram.org/method/auth.resendCode for reference.
type AuthResendCodeRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The phone number
	PhoneNumber string
	// The phone code hash obtained from auth.sendCode¹
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.sendCode
	PhoneCodeHash string
	// Official clients only, used if the device integrity verification failed, and no secret
	// could be obtained to invoke auth.requestFirebaseSms¹: in this case, the device
	// integrity verification failure reason must be passed here.
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.requestFirebaseSms
	//
	// Use SetReason and GetReason helpers.
	Reason string
}

// AuthResendCodeRequestTypeID is TL type id of AuthResendCodeRequest.
const AuthResendCodeRequestTypeID = 0xcae47523

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

func ( *AuthResendCodeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.PhoneNumber == "") {
		return false
	}
	if !(.PhoneCodeHash == "") {
		return false
	}
	if !(.Reason == "") {
		return false
	}

	return true
}

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

// FillFrom fills AuthResendCodeRequest from given interface.
func ( *AuthResendCodeRequest) ( interface {
	() ( string)
	() ( string)
	() ( string,  bool)
}) {
	.PhoneNumber = .()
	.PhoneCodeHash = .()
	if ,  := .();  {
		.Reason = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*AuthResendCodeRequest) () string {
	return "auth.resendCode"
}

// TypeInfo returns info about TL type.
func ( *AuthResendCodeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.resendCode",
		ID:   AuthResendCodeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PhoneNumber",
			SchemaName: "phone_number",
		},
		{
			Name:       "PhoneCodeHash",
			SchemaName: "phone_code_hash",
		},
		{
			Name:       "Reason",
			SchemaName: "reason",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AuthResendCodeRequest) () {
	if !(.Reason == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AuthResendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.resendCode#cae47523 as nil")
	}
	.PutID(AuthResendCodeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthResendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.resendCode#cae47523 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.resendCode#cae47523: field flags: %w", )
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	if .Flags.Has(0) {
		.PutString(.Reason)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthResendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.resendCode#cae47523 to nil")
	}
	if  := .ConsumeID(AuthResendCodeRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.resendCode#cae47523: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthResendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.resendCode#cae47523 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.resendCode#cae47523: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.resendCode#cae47523: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.resendCode#cae47523: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.resendCode#cae47523: field reason: %w", )
		}
		.Reason = 
	}
	return nil
}

// GetPhoneNumber returns value of PhoneNumber field.
func ( *AuthResendCodeRequest) () ( string) {
	if  == nil {
		return
	}
	return .PhoneNumber
}

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

// SetReason sets value of Reason conditional field.
func ( *AuthResendCodeRequest) ( string) {
	.Flags.Set(0)
	.Reason = 
}

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

// AuthResendCode invokes method auth.resendCode#cae47523 returning error if any.
// Resend the login code via another medium, the phone code type is determined by the
// return value of the previous auth.sendCode/auth.resendCode: see login¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/auth
//
// Possible errors:
//
//	400 EMAIL_INSTALL_MISSING:
//	400 PHONE_CODE_EMPTY: phone_code is missing.
//	400 PHONE_CODE_EXPIRED: The phone code you provided has expired.
//	400 PHONE_CODE_HASH_EMPTY: phone_code_hash is missing.
//	406 PHONE_NUMBER_INVALID: The phone number is invalid.
//	406 SEND_CODE_UNAVAILABLE: Returned when all available options for this type of number were already used (e.g. flash-call, then SMS, then this error might be returned to trigger a second resend).
//
// See https://core.telegram.org/method/auth.resendCode for reference.
func ( *Client) ( context.Context,  *AuthResendCodeRequest) (AuthSentCodeClass, error) {
	var  AuthSentCodeBox

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