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

// AccountAcceptAuthorizationRequest represents TL type `account.acceptAuthorization#f3ed4c73`.
// Sends a Telegram Passport authorization form, effectively sharing data with the
// service
//
// See https://core.telegram.org/method/account.acceptAuthorization for reference.
type AccountAcceptAuthorizationRequest struct {
	// Bot ID
	BotID int64
	// Telegram Passport element types requested by the service
	Scope string
	// Service's public key
	PublicKey string
	// Types of values sent and their hashes
	ValueHashes []SecureValueHash
	// Encrypted values
	Credentials SecureCredentialsEncrypted
}

// AccountAcceptAuthorizationRequestTypeID is TL type id of AccountAcceptAuthorizationRequest.
const AccountAcceptAuthorizationRequestTypeID = 0xf3ed4c73

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

func ( *AccountAcceptAuthorizationRequest) () bool {
	if  == nil {
		return true
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.Scope == "") {
		return false
	}
	if !(.PublicKey == "") {
		return false
	}
	if !(.ValueHashes == nil) {
		return false
	}
	if !(.Credentials.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountAcceptAuthorizationRequest from given interface.
func ( *AccountAcceptAuthorizationRequest) ( interface {
	() ( int64)
	() ( string)
	() ( string)
	() ( []SecureValueHash)
	() ( SecureCredentialsEncrypted)
}) {
	.BotID = .()
	.Scope = .()
	.PublicKey = .()
	.ValueHashes = .()
	.Credentials = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountAcceptAuthorizationRequest) () string {
	return "account.acceptAuthorization"
}

// TypeInfo returns info about TL type.
func ( *AccountAcceptAuthorizationRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.acceptAuthorization",
		ID:   AccountAcceptAuthorizationRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "Scope",
			SchemaName: "scope",
		},
		{
			Name:       "PublicKey",
			SchemaName: "public_key",
		},
		{
			Name:       "ValueHashes",
			SchemaName: "value_hashes",
		},
		{
			Name:       "Credentials",
			SchemaName: "credentials",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountAcceptAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.acceptAuthorization#f3ed4c73 as nil")
	}
	.PutID(AccountAcceptAuthorizationRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountAcceptAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.acceptAuthorization#f3ed4c73 as nil")
	}
	.PutLong(.BotID)
	.PutString(.Scope)
	.PutString(.PublicKey)
	.PutVectorHeader(len(.ValueHashes))
	for ,  := range .ValueHashes {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.acceptAuthorization#f3ed4c73: field value_hashes element with index %d: %w", , )
		}
	}
	if  := .Credentials.Encode();  != nil {
		return fmt.Errorf("unable to encode account.acceptAuthorization#f3ed4c73: field credentials: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountAcceptAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.acceptAuthorization#f3ed4c73 to nil")
	}
	if  := .ConsumeID(AccountAcceptAuthorizationRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountAcceptAuthorizationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.acceptAuthorization#f3ed4c73 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: field scope: %w", )
		}
		.Scope = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: field public_key: %w", )
		}
		.PublicKey = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: field value_hashes: %w", )
		}

		if  > 0 {
			.ValueHashes = make([]SecureValueHash, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  SecureValueHash
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: field value_hashes: %w", )
			}
			.ValueHashes = append(.ValueHashes, )
		}
	}
	{
		if  := .Credentials.Decode();  != nil {
			return fmt.Errorf("unable to decode account.acceptAuthorization#f3ed4c73: field credentials: %w", )
		}
	}
	return nil
}

// GetBotID returns value of BotID field.
func ( *AccountAcceptAuthorizationRequest) () ( int64) {
	if  == nil {
		return
	}
	return .BotID
}

// GetScope returns value of Scope field.
func ( *AccountAcceptAuthorizationRequest) () ( string) {
	if  == nil {
		return
	}
	return .Scope
}

// GetPublicKey returns value of PublicKey field.
func ( *AccountAcceptAuthorizationRequest) () ( string) {
	if  == nil {
		return
	}
	return .PublicKey
}

// GetValueHashes returns value of ValueHashes field.
func ( *AccountAcceptAuthorizationRequest) () ( []SecureValueHash) {
	if  == nil {
		return
	}
	return .ValueHashes
}

// GetCredentials returns value of Credentials field.
func ( *AccountAcceptAuthorizationRequest) () ( SecureCredentialsEncrypted) {
	if  == nil {
		return
	}
	return .Credentials
}

// AccountAcceptAuthorization invokes method account.acceptAuthorization#f3ed4c73 returning error if any.
// Sends a Telegram Passport authorization form, effectively sharing data with the
// service
//
// See https://core.telegram.org/method/account.acceptAuthorization for reference.
func ( *Client) ( context.Context,  *AccountAcceptAuthorizationRequest) (bool, error) {
	var  BoolBox

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