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

// AuthInitPasskeyLoginRequest represents TL type `auth.initPasskeyLogin#518ad0b7`.
// Initialize login with a passkey over an unauthenticated connection, see here »¹ for
// more info.
//
// Links:
//  1. https://core.telegram.org/api/passkeys#logging-in-with-a-passkey
//
// See https://core.telegram.org/method/auth.initPasskeyLogin for reference.
type AuthInitPasskeyLoginRequest struct {
	// Application identifier (see App configuration¹)
	//
	// Links:
	//  1) https://core.telegram.org/myapp
	APIID int
	// Application identifier hash (see App configuration¹)
	//
	// Links:
	//  1) https://core.telegram.org/myapp
	APIHash string
}

// AuthInitPasskeyLoginRequestTypeID is TL type id of AuthInitPasskeyLoginRequest.
const AuthInitPasskeyLoginRequestTypeID = 0x518ad0b7

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

func ( *AuthInitPasskeyLoginRequest) () bool {
	if  == nil {
		return true
	}
	if !(.APIID == 0) {
		return false
	}
	if !(.APIHash == "") {
		return false
	}

	return true
}

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

// FillFrom fills AuthInitPasskeyLoginRequest from given interface.
func ( *AuthInitPasskeyLoginRequest) ( interface {
	() ( int)
	() ( string)
}) {
	.APIID = .()
	.APIHash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AuthInitPasskeyLoginRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.initPasskeyLogin",
		ID:   AuthInitPasskeyLoginRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "APIID",
			SchemaName: "api_id",
		},
		{
			Name:       "APIHash",
			SchemaName: "api_hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthInitPasskeyLoginRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.initPasskeyLogin#518ad0b7 as nil")
	}
	.PutID(AuthInitPasskeyLoginRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthInitPasskeyLoginRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.initPasskeyLogin#518ad0b7 as nil")
	}
	.PutInt(.APIID)
	.PutString(.APIHash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthInitPasskeyLoginRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.initPasskeyLogin#518ad0b7 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.initPasskeyLogin#518ad0b7: field api_id: %w", )
		}
		.APIID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.initPasskeyLogin#518ad0b7: field api_hash: %w", )
		}
		.APIHash = 
	}
	return nil
}

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

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

// AuthInitPasskeyLogin invokes method auth.initPasskeyLogin#518ad0b7 returning error if any.
// Initialize login with a passkey over an unauthenticated connection, see here »¹ for
// more info.
//
// Links:
//  1. https://core.telegram.org/api/passkeys#logging-in-with-a-passkey
//
// Possible errors:
//
//	400 API_ID_INVALID: API ID invalid.
//	500 AUTH_RESTART: Restart the authorization process.
//	500 PASSKEY_AUTH_RESTART:
//
// See https://core.telegram.org/method/auth.initPasskeyLogin for reference.
func ( *Client) ( context.Context,  *AuthInitPasskeyLoginRequest) (*AuthPasskeyLoginOptions, error) {
	var  AuthPasskeyLoginOptions

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