// 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#3ef1a9bf`.
// 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 {
	// The phone number
	PhoneNumber string
	// The phone code hash obtained from auth.sendCode¹
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.sendCode
	PhoneCodeHash string
}

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

// 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 !(.PhoneNumber == "") {
		return false
	}
	if !(.PhoneCodeHash == "") {
		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)
}) {
	.PhoneNumber = .()
	.PhoneCodeHash = .()
}

// 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",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthResendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.resendCode#3ef1a9bf 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#3ef1a9bf as nil")
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthResendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.resendCode#3ef1a9bf to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.resendCode#3ef1a9bf: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.resendCode#3ef1a9bf: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	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
}

// AuthResendCode invokes method auth.resendCode#3ef1a9bf 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 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
}