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

// AuthImportAuthorizationRequest represents TL type `auth.importAuthorization#a57a7dad`.
// Logs in a user using a key transmitted from his native data-center.
//
// See https://core.telegram.org/method/auth.importAuthorization for reference.
type AuthImportAuthorizationRequest struct {
	// User ID
	ID int64
	// Authorization key
	Bytes []byte
}

// AuthImportAuthorizationRequestTypeID is TL type id of AuthImportAuthorizationRequest.
const AuthImportAuthorizationRequestTypeID = 0xa57a7dad

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

func ( *AuthImportAuthorizationRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Bytes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AuthImportAuthorizationRequest from given interface.
func ( *AuthImportAuthorizationRequest) ( interface {
	() ( int64)
	() ( []byte)
}) {
	.ID = .()
	.Bytes = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AuthImportAuthorizationRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.importAuthorization",
		ID:   AuthImportAuthorizationRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Bytes",
			SchemaName: "bytes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthImportAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.importAuthorization#a57a7dad as nil")
	}
	.PutID(AuthImportAuthorizationRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthImportAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.importAuthorization#a57a7dad as nil")
	}
	.PutLong(.ID)
	.PutBytes(.Bytes)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthImportAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.importAuthorization#a57a7dad to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode auth.importAuthorization#a57a7dad: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode auth.importAuthorization#a57a7dad: field bytes: %w", )
		}
		.Bytes = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *AuthImportAuthorizationRequest) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetBytes returns value of Bytes field.
func ( *AuthImportAuthorizationRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .Bytes
}

// AuthImportAuthorization invokes method auth.importAuthorization#a57a7dad returning error if any.
// Logs in a user using a key transmitted from his native data-center.
//
// Possible errors:
//
//	400 AUTH_BYTES_INVALID: The provided authorization is invalid.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/auth.importAuthorization for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *AuthImportAuthorizationRequest) (AuthAuthorizationClass, error) {
	var  AuthAuthorizationBox

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