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

// AuthCancelCodeRequest represents TL type `auth.cancelCode#1f040578`.
// Cancel the login verification code
//
// See https://core.telegram.org/method/auth.cancelCode for reference.
type AuthCancelCodeRequest struct {
	// Phone number
	PhoneNumber string
	// Phone code hash from auth.sendCode¹
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.sendCode
	PhoneCodeHash string
}

// AuthCancelCodeRequestTypeID is TL type id of AuthCancelCodeRequest.
const AuthCancelCodeRequestTypeID = 0x1f040578

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

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *AuthCancelCodeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.cancelCode",
		ID:   AuthCancelCodeRequestTypeID,
	}
	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 ( *AuthCancelCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.cancelCode#1f040578 as nil")
	}
	.PutID(AuthCancelCodeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthCancelCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.cancelCode#1f040578 as nil")
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthCancelCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.cancelCode#1f040578 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.cancelCode#1f040578: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.cancelCode#1f040578: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	return nil
}

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

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

// AuthCancelCode invokes method auth.cancelCode#1f040578 returning error if any.
// Cancel the login verification code
//
// Possible errors:
//
//	400 PHONE_CODE_EXPIRED: The phone code you provided has expired.
//	406 PHONE_NUMBER_INVALID: The phone number is invalid.
//
// See https://core.telegram.org/method/auth.cancelCode for reference.
func ( *Client) ( context.Context,  *AuthCancelCodeRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}