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

// AccountInitTakeoutSessionRequest represents TL type `account.initTakeoutSession#8ef3eab0`.
// Initialize a takeout session, see here » for more info¹.
//
// Links:
//  1. https://core.telegram.org/api/takeout
//
// See https://core.telegram.org/method/account.initTakeoutSession for reference.
type AccountInitTakeoutSessionRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to export contacts
	Contacts bool
	// Whether to export messages in private chats
	MessageUsers bool
	// Whether to export messages in basic groups¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel#basic-groups
	MessageChats bool
	// Whether to export messages in supergroups¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel#supergroups
	MessageMegagroups bool
	// Whether to export messages in channels¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel#channels
	MessageChannels bool
	// Whether to export files
	Files bool
	// Maximum size of files to export
	//
	// Use SetFileMaxSize and GetFileMaxSize helpers.
	FileMaxSize int64
}

// AccountInitTakeoutSessionRequestTypeID is TL type id of AccountInitTakeoutSessionRequest.
const AccountInitTakeoutSessionRequestTypeID = 0x8ef3eab0

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

func ( *AccountInitTakeoutSessionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Contacts == false) {
		return false
	}
	if !(.MessageUsers == false) {
		return false
	}
	if !(.MessageChats == false) {
		return false
	}
	if !(.MessageMegagroups == false) {
		return false
	}
	if !(.MessageChannels == false) {
		return false
	}
	if !(.Files == false) {
		return false
	}
	if !(.FileMaxSize == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountInitTakeoutSessionRequest from given interface.
func ( *AccountInitTakeoutSessionRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64,  bool)
}) {
	.Contacts = .()
	.MessageUsers = .()
	.MessageChats = .()
	.MessageMegagroups = .()
	.MessageChannels = .()
	.Files = .()
	if ,  := .();  {
		.FileMaxSize = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *AccountInitTakeoutSessionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.initTakeoutSession",
		ID:   AccountInitTakeoutSessionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Contacts",
			SchemaName: "contacts",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "MessageUsers",
			SchemaName: "message_users",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "MessageChats",
			SchemaName: "message_chats",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "MessageMegagroups",
			SchemaName: "message_megagroups",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "MessageChannels",
			SchemaName: "message_channels",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Files",
			SchemaName: "files",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "FileMaxSize",
			SchemaName: "file_max_size",
			Null:       !.Flags.Has(5),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountInitTakeoutSessionRequest) () {
	if !(.Contacts == false) {
		.Flags.Set(0)
	}
	if !(.MessageUsers == false) {
		.Flags.Set(1)
	}
	if !(.MessageChats == false) {
		.Flags.Set(2)
	}
	if !(.MessageMegagroups == false) {
		.Flags.Set(3)
	}
	if !(.MessageChannels == false) {
		.Flags.Set(4)
	}
	if !(.Files == false) {
		.Flags.Set(5)
	}
	if !(.FileMaxSize == 0) {
		.Flags.Set(5)
	}
}

// Encode implements bin.Encoder.
func ( *AccountInitTakeoutSessionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.initTakeoutSession#8ef3eab0 as nil")
	}
	.PutID(AccountInitTakeoutSessionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountInitTakeoutSessionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.initTakeoutSession#8ef3eab0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.initTakeoutSession#8ef3eab0: field flags: %w", )
	}
	if .Flags.Has(5) {
		.PutLong(.FileMaxSize)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountInitTakeoutSessionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.initTakeoutSession#8ef3eab0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.initTakeoutSession#8ef3eab0: field flags: %w", )
		}
	}
	.Contacts = .Flags.Has(0)
	.MessageUsers = .Flags.Has(1)
	.MessageChats = .Flags.Has(2)
	.MessageMegagroups = .Flags.Has(3)
	.MessageChannels = .Flags.Has(4)
	.Files = .Flags.Has(5)
	if .Flags.Has(5) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.initTakeoutSession#8ef3eab0: field file_max_size: %w", )
		}
		.FileMaxSize = 
	}
	return nil
}

// SetContacts sets value of Contacts conditional field.
func ( *AccountInitTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Contacts = true
	} else {
		.Flags.Unset(0)
		.Contacts = false
	}
}

// GetContacts returns value of Contacts conditional field.
func ( *AccountInitTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetMessageUsers sets value of MessageUsers conditional field.
func ( *AccountInitTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.MessageUsers = true
	} else {
		.Flags.Unset(1)
		.MessageUsers = false
	}
}

// GetMessageUsers returns value of MessageUsers conditional field.
func ( *AccountInitTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetMessageChats sets value of MessageChats conditional field.
func ( *AccountInitTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.MessageChats = true
	} else {
		.Flags.Unset(2)
		.MessageChats = false
	}
}

// GetMessageChats returns value of MessageChats conditional field.
func ( *AccountInitTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetMessageMegagroups sets value of MessageMegagroups conditional field.
func ( *AccountInitTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(3)
		.MessageMegagroups = true
	} else {
		.Flags.Unset(3)
		.MessageMegagroups = false
	}
}

// GetMessageMegagroups returns value of MessageMegagroups conditional field.
func ( *AccountInitTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetMessageChannels sets value of MessageChannels conditional field.
func ( *AccountInitTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.MessageChannels = true
	} else {
		.Flags.Unset(4)
		.MessageChannels = false
	}
}

// GetMessageChannels returns value of MessageChannels conditional field.
func ( *AccountInitTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetFiles sets value of Files conditional field.
func ( *AccountInitTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(5)
		.Files = true
	} else {
		.Flags.Unset(5)
		.Files = false
	}
}

// GetFiles returns value of Files conditional field.
func ( *AccountInitTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetFileMaxSize sets value of FileMaxSize conditional field.
func ( *AccountInitTakeoutSessionRequest) ( int64) {
	.Flags.Set(5)
	.FileMaxSize = 
}

// GetFileMaxSize returns value of FileMaxSize conditional field and
// boolean which is true if field was set.
func ( *AccountInitTakeoutSessionRequest) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .FileMaxSize, true
}

// AccountInitTakeoutSession invokes method account.initTakeoutSession#8ef3eab0 returning error if any.
// Initialize a takeout session, see here » for more info¹.
//
// Links:
//  1. https://core.telegram.org/api/takeout
//
// Possible errors:
//
//	420 TAKEOUT_INIT_DELAY_%d: Sorry, for security reasons, you will be able to begin downloading your data in %d seconds. We have notified all your devices about the export request to make sure it's authorized and to give you time to react if it's not.
//
// See https://core.telegram.org/method/account.initTakeoutSession for reference.
func ( *Client) ( context.Context,  *AccountInitTakeoutSessionRequest) (*AccountTakeout, error) {
	var  AccountTakeout

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