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

// AccountSendChangePhoneCodeRequest represents TL type `account.sendChangePhoneCode#82574ae5`.
// Verify a new phone number to associate to the current account
//
// See https://core.telegram.org/method/account.sendChangePhoneCode for reference.
type AccountSendChangePhoneCodeRequest struct {
	// New phone number
	PhoneNumber string
	// Phone code settings
	Settings CodeSettings
}

// AccountSendChangePhoneCodeRequestTypeID is TL type id of AccountSendChangePhoneCodeRequest.
const AccountSendChangePhoneCodeRequestTypeID = 0x82574ae5

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

func ( *AccountSendChangePhoneCodeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.PhoneNumber == "") {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSendChangePhoneCodeRequest from given interface.
func ( *AccountSendChangePhoneCodeRequest) ( interface {
	() ( string)
	() ( CodeSettings)
}) {
	.PhoneNumber = .()
	.Settings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSendChangePhoneCodeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.sendChangePhoneCode",
		ID:   AccountSendChangePhoneCodeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PhoneNumber",
			SchemaName: "phone_number",
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSendChangePhoneCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.sendChangePhoneCode#82574ae5 as nil")
	}
	.PutID(AccountSendChangePhoneCodeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSendChangePhoneCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.sendChangePhoneCode#82574ae5 as nil")
	}
	.PutString(.PhoneNumber)
	if  := .Settings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.sendChangePhoneCode#82574ae5: field settings: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSendChangePhoneCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.sendChangePhoneCode#82574ae5 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.sendChangePhoneCode#82574ae5: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.sendChangePhoneCode#82574ae5: field settings: %w", )
		}
	}
	return nil
}

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

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

// AccountSendChangePhoneCode invokes method account.sendChangePhoneCode#82574ae5 returning error if any.
// Verify a new phone number to associate to the current account
//
// Possible errors:
//
//	406 FRESH_CHANGE_PHONE_FORBIDDEN: You can't change phone number right after logging in, please wait at least 24 hours.
//	400 PHONE_NUMBER_BANNED: The provided phone number is banned from telegram.
//	406 PHONE_NUMBER_INVALID: The phone number is invalid.
//	400 PHONE_NUMBER_OCCUPIED: The phone number is already in use.
//
// See https://core.telegram.org/method/account.sendChangePhoneCode for reference.
func ( *Client) ( context.Context,  *AccountSendChangePhoneCodeRequest) (AuthSentCodeClass, error) {
	var  AuthSentCodeBox

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