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

// AuthExportLoginTokenRequest represents TL type `auth.exportLoginToken#b7e085fe`.
// Generate a login token, for login via QR code¹.
// The generated login token should be encoded using base64url, then shown as a
// tg://login?token=base64encodedtoken deep link »² in the QR code.
// For more info, see login via QR code¹.
//
// Links:
//  1. https://core.telegram.org/api/qr-login
//  2. https://core.telegram.org/api/links#qr-code-login-links
//  3. https://core.telegram.org/api/qr-login
//
// See https://core.telegram.org/method/auth.exportLoginToken for reference.
type AuthExportLoginTokenRequest 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
	// List of already logged-in user IDs, to prevent logging in twice with the same user
	ExceptIDs []int64
}

// AuthExportLoginTokenRequestTypeID is TL type id of AuthExportLoginTokenRequest.
const AuthExportLoginTokenRequestTypeID = 0xb7e085fe

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

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

	return true
}

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

// FillFrom fills AuthExportLoginTokenRequest from given interface.
func ( *AuthExportLoginTokenRequest) ( interface {
	() ( int)
	() ( string)
	() ( []int64)
}) {
	.APIID = .()
	.APIHash = .()
	.ExceptIDs = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *AuthExportLoginTokenRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.exportLoginToken#b7e085fe as nil")
	}
	.PutID(AuthExportLoginTokenRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthExportLoginTokenRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.exportLoginToken#b7e085fe as nil")
	}
	.PutInt(.APIID)
	.PutString(.APIHash)
	.PutVectorHeader(len(.ExceptIDs))
	for ,  := range .ExceptIDs {
		.PutLong()
	}
	return nil
}

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

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

		if  > 0 {
			.ExceptIDs = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode auth.exportLoginToken#b7e085fe: field except_ids: %w", )
			}
			.ExceptIDs = append(.ExceptIDs, )
		}
	}
	return nil
}

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

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

// GetExceptIDs returns value of ExceptIDs field.
func ( *AuthExportLoginTokenRequest) () ( []int64) {
	if  == nil {
		return
	}
	return .ExceptIDs
}

// AuthExportLoginToken invokes method auth.exportLoginToken#b7e085fe returning error if any.
// Generate a login token, for login via QR code¹.
// The generated login token should be encoded using base64url, then shown as a
// tg://login?token=base64encodedtoken deep link »² in the QR code.
// For more info, see login via QR code¹.
//
// Links:
//  1. https://core.telegram.org/api/qr-login
//  2. https://core.telegram.org/api/links#qr-code-login-links
//  3. https://core.telegram.org/api/qr-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.
//
// See https://core.telegram.org/method/auth.exportLoginToken for reference.
func ( *Client) ( context.Context,  *AuthExportLoginTokenRequest) (AuthLoginTokenClass, error) {
	var  AuthLoginTokenBox

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