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

// AuthSendCodeRequest represents TL type `auth.sendCode#a677244f`.
// Send the verification code for login
//
// See https://core.telegram.org/method/auth.sendCode for reference.
type AuthSendCodeRequest struct {
	// Phone number in international format
	PhoneNumber string
	// Application identifier (see App configurationĀ¹)
	//
	// Links:
	//  1) https://core.telegram.org/myapp
	APIID int
	// Application secret hash (see App configurationĀ¹)
	//
	// Links:
	//  1) https://core.telegram.org/myapp
	APIHash string
	// Settings for the code type to send
	Settings CodeSettings
}

// AuthSendCodeRequestTypeID is TL type id of AuthSendCodeRequest.
const AuthSendCodeRequestTypeID = 0xa677244f

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

func ( *AuthSendCodeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.PhoneNumber == "") {
		return false
	}
	if !(.APIID == 0) {
		return false
	}
	if !(.APIHash == "") {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSendCodeRequest from given interface.
func ( *AuthSendCodeRequest) ( interface {
	() ( string)
	() ( int)
	() ( string)
	() ( CodeSettings)
}) {
	.PhoneNumber = .()
	.APIID = .()
	.APIHash = .()
	.Settings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AuthSendCodeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sendCode",
		ID:   AuthSendCodeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PhoneNumber",
			SchemaName: "phone_number",
		},
		{
			Name:       "APIID",
			SchemaName: "api_id",
		},
		{
			Name:       "APIHash",
			SchemaName: "api_hash",
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sendCode#a677244f as nil")
	}
	.PutID(AuthSendCodeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sendCode#a677244f as nil")
	}
	.PutString(.PhoneNumber)
	.PutInt(.APIID)
	.PutString(.APIHash)
	if  := .Settings.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.sendCode#a677244f: field settings: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSendCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sendCode#a677244f to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sendCode#a677244f: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sendCode#a677244f: field api_id: %w", )
		}
		.APIID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sendCode#a677244f: field api_hash: %w", )
		}
		.APIHash = 
	}
	{
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.sendCode#a677244f: field settings: %w", )
		}
	}
	return nil
}

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

// GetAPIID returns value of APIID field.
func ( *AuthSendCodeRequest) () ( int) {
	if  == nil {
		return
	}
	return .APIID
}

// GetAPIHash returns value of APIHash field.
func ( *AuthSendCodeRequest) () ( string) {
	if  == nil {
		return
	}
	return .APIHash
}

// GetSettings returns value of Settings field.
func ( *AuthSendCodeRequest) () ( CodeSettings) {
	if  == nil {
		return
	}
	return .Settings
}

// AuthSendCode invokes method auth.sendCode#a677244f returning error if any.
// Send the verification code for login
//
// Possible errors:
//
//	400 API_ID_INVALID: API ID invalid.
//	400 API_ID_PUBLISHED_FLOOD: This API id was published somewhere, you can't use it now.
//	500 AUTH_RESTART: Restart the authorization process.
//	400 PHONE_NUMBER_APP_SIGNUP_FORBIDDEN: You can't sign up using this app.
//	400 PHONE_NUMBER_BANNED: The provided phone number is banned from telegram.
//	400 PHONE_NUMBER_FLOOD: You asked for the code too many times.
//	406 PHONE_NUMBER_INVALID: The phone number is invalid.
//	406 PHONE_PASSWORD_FLOOD: You have tried logging in too many times.
//	400 PHONE_PASSWORD_PROTECTED: This phone is password protected.
//	400 SMS_CODE_CREATE_FAILED: An error occurred while creating the SMS code.
//
// See https://core.telegram.org/method/auth.sendCode for reference.
func ( *Client) ( context.Context,  *AuthSendCodeRequest) (AuthSentCodeClass, error) {
	var  AuthSentCodeBox

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