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

// AccountGetSecureValueRequest represents TL type `account.getSecureValue#73665bc2`.
// Get saved Telegram Passport¹ document, for more info see the passport docs »²
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#encryption
//
// See https://core.telegram.org/method/account.getSecureValue for reference.
type AccountGetSecureValueRequest struct {
	// Requested value types
	Types []SecureValueTypeClass
}

// AccountGetSecureValueRequestTypeID is TL type id of AccountGetSecureValueRequest.
const AccountGetSecureValueRequestTypeID = 0x73665bc2

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

func ( *AccountGetSecureValueRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Types == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountGetSecureValueRequest from given interface.
func ( *AccountGetSecureValueRequest) ( interface {
	() ( []SecureValueTypeClass)
}) {
	.Types = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountGetSecureValueRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.getSecureValue",
		ID:   AccountGetSecureValueRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Types",
			SchemaName: "types",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountGetSecureValueRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.getSecureValue#73665bc2 as nil")
	}
	.PutID(AccountGetSecureValueRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountGetSecureValueRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.getSecureValue#73665bc2 as nil")
	}
	.PutVectorHeader(len(.Types))
	for ,  := range .Types {
		if  == nil {
			return fmt.Errorf("unable to encode account.getSecureValue#73665bc2: field types element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.getSecureValue#73665bc2: field types element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountGetSecureValueRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.getSecureValue#73665bc2 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.getSecureValue#73665bc2: field types: %w", )
		}

		if  > 0 {
			.Types = make([]SecureValueTypeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeSecureValueType()
			if  != nil {
				return fmt.Errorf("unable to decode account.getSecureValue#73665bc2: field types: %w", )
			}
			.Types = append(.Types, )
		}
	}
	return nil
}

// GetTypes returns value of Types field.
func ( *AccountGetSecureValueRequest) () ( []SecureValueTypeClass) {
	if  == nil {
		return
	}
	return .Types
}

// MapTypes returns field Types wrapped in SecureValueTypeClassArray helper.
func ( *AccountGetSecureValueRequest) () ( SecureValueTypeClassArray) {
	return SecureValueTypeClassArray(.Types)
}

// AccountGetSecureValue invokes method account.getSecureValue#73665bc2 returning error if any.
// Get saved Telegram Passport¹ document, for more info see the passport docs »²
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#encryption
//
// See https://core.telegram.org/method/account.getSecureValue for reference.
func ( *Client) ( context.Context,  []SecureValueTypeClass) ([]SecureValue, error) {
	var  SecureValueVector

	 := &AccountGetSecureValueRequest{
		Types: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return []SecureValue(.Elems), nil
}