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

// AuthAcceptLoginTokenRequest represents TL type `auth.acceptLoginToken#e894ad4d`.
// Accept QR code login token, logging in the app that generated it.
// Returns info about the new session.
// For more info, see login via QR code¹.
//
// Links:
//  1. https://core.telegram.org/api/qr-login
//
// See https://core.telegram.org/method/auth.acceptLoginToken for reference.
type AuthAcceptLoginTokenRequest struct {
	// Login token embedded in QR code, for more info, see login via QR code¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/qr-login
	Token []byte
}

// AuthAcceptLoginTokenRequestTypeID is TL type id of AuthAcceptLoginTokenRequest.
const AuthAcceptLoginTokenRequestTypeID = 0xe894ad4d

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

func ( *AuthAcceptLoginTokenRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Token == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AuthAcceptLoginTokenRequest from given interface.
func ( *AuthAcceptLoginTokenRequest) ( interface {
	() ( []byte)
}) {
	.Token = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AuthAcceptLoginTokenRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.acceptLoginToken",
		ID:   AuthAcceptLoginTokenRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Token",
			SchemaName: "token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthAcceptLoginTokenRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.acceptLoginToken#e894ad4d as nil")
	}
	.PutID(AuthAcceptLoginTokenRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthAcceptLoginTokenRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.acceptLoginToken#e894ad4d as nil")
	}
	.PutBytes(.Token)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthAcceptLoginTokenRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.acceptLoginToken#e894ad4d to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode auth.acceptLoginToken#e894ad4d: field token: %w", )
		}
		.Token = 
	}
	return nil
}

// GetToken returns value of Token field.
func ( *AuthAcceptLoginTokenRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .Token
}

// AuthAcceptLoginToken invokes method auth.acceptLoginToken#e894ad4d returning error if any.
// Accept QR code login token, logging in the app that generated it.
// Returns info about the new session.
// For more info, see login via QR code¹.
//
// Links:
//  1. https://core.telegram.org/api/qr-login
//
// Possible errors:
//
//	400 AUTH_TOKEN_ALREADY_ACCEPTED: The specified auth token was already accepted.
//	400 AUTH_TOKEN_EXCEPTION: An error occurred while importing the auth token.
//	400 AUTH_TOKEN_EXPIRED: The authorization token has expired.
//	400 AUTH_TOKEN_INVALIDX: The specified auth token is invalid.
//
// See https://core.telegram.org/method/auth.acceptLoginToken for reference.
func ( *Client) ( context.Context,  []byte) (*Authorization, error) {
	var  Authorization

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