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

// AccountChangePhoneRequest represents TL type `account.changePhone#70c32edb`.
// Change the phone number of the current account
//
// See https://core.telegram.org/method/account.changePhone for reference.
type AccountChangePhoneRequest struct {
	// New phone number
	PhoneNumber string
	// Phone code hash received when calling account.sendChangePhoneCode¹
	//
	// Links:
	//  1) https://core.telegram.org/method/account.sendChangePhoneCode
	PhoneCodeHash string
	// Phone code received when calling account.sendChangePhoneCode¹
	//
	// Links:
	//  1) https://core.telegram.org/method/account.sendChangePhoneCode
	PhoneCode string
}

// AccountChangePhoneRequestTypeID is TL type id of AccountChangePhoneRequest.
const AccountChangePhoneRequestTypeID = 0x70c32edb

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *AccountChangePhoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.changePhone#70c32edb as nil")
	}
	.PutID(AccountChangePhoneRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountChangePhoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.changePhone#70c32edb as nil")
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	.PutString(.PhoneCode)
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountChangePhoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.changePhone#70c32edb to nil")
	}
	if  := .ConsumeID(AccountChangePhoneRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.changePhone#70c32edb: %w", )
	}
	return .DecodeBare()
}

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

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

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

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

// AccountChangePhone invokes method account.changePhone#70c32edb returning error if any.
// Change the phone number of the current account
//
// Possible errors:
//
//	400 PHONE_CODE_EMPTY: phone_code is missing.
//	400 PHONE_CODE_EXPIRED: The phone code you provided has expired.
//	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.changePhone for reference.
func ( *Client) ( context.Context,  *AccountChangePhoneRequest) (UserClass, error) {
	var  UserBox

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