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

// AuthImportBotAuthorizationRequest represents TL type `auth.importBotAuthorization#67a3ff2c`.
// Login as a bot
//
// See https://core.telegram.org/method/auth.importBotAuthorization for reference.
type AuthImportBotAuthorizationRequest struct {
	// Reserved for future use
	Flags int
	// 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
	// Bot token (see botsĀ¹)
	//
	// Links:
	//  1) https://core.telegram.org/bots
	BotAuthToken string
}

// AuthImportBotAuthorizationRequestTypeID is TL type id of AuthImportBotAuthorizationRequest.
const AuthImportBotAuthorizationRequestTypeID = 0x67a3ff2c

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

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *AuthImportBotAuthorizationRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.importBotAuthorization",
		ID:   AuthImportBotAuthorizationRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Flags",
			SchemaName: "flags",
		},
		{
			Name:       "APIID",
			SchemaName: "api_id",
		},
		{
			Name:       "APIHash",
			SchemaName: "api_hash",
		},
		{
			Name:       "BotAuthToken",
			SchemaName: "bot_auth_token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthImportBotAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.importBotAuthorization#67a3ff2c as nil")
	}
	.PutID(AuthImportBotAuthorizationRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthImportBotAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.importBotAuthorization#67a3ff2c as nil")
	}
	.PutInt(.Flags)
	.PutInt(.APIID)
	.PutString(.APIHash)
	.PutString(.BotAuthToken)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthImportBotAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.importBotAuthorization#67a3ff2c to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.importBotAuthorization#67a3ff2c: field flags: %w", )
		}
		.Flags = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.importBotAuthorization#67a3ff2c: field api_id: %w", )
		}
		.APIID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.importBotAuthorization#67a3ff2c: field api_hash: %w", )
		}
		.APIHash = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.importBotAuthorization#67a3ff2c: field bot_auth_token: %w", )
		}
		.BotAuthToken = 
	}
	return nil
}

// GetFlags returns value of Flags field.
func ( *AuthImportBotAuthorizationRequest) () ( int) {
	if  == nil {
		return
	}
	return .Flags
}

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

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

// GetBotAuthToken returns value of BotAuthToken field.
func ( *AuthImportBotAuthorizationRequest) () ( string) {
	if  == nil {
		return
	}
	return .BotAuthToken
}

// AuthImportBotAuthorization invokes method auth.importBotAuthorization#67a3ff2c returning error if any.
// Login as a bot
//
// Possible errors:
//
//	400 ACCESS_TOKEN_EXPIRED: Access token expired.
//	400 ACCESS_TOKEN_INVALID: Access token invalid.
//	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.importBotAuthorization for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *AuthImportBotAuthorizationRequest) (AuthAuthorizationClass, error) {
	var  AuthAuthorizationBox

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