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

// AccountFinishTakeoutSessionRequest represents TL type `account.finishTakeoutSession#1d2652ee`.
// Terminate a takeout session, see here » for more info¹.
//
// Links:
//  1. https://core.telegram.org/api/takeout
//
// See https://core.telegram.org/method/account.finishTakeoutSession for reference.
type AccountFinishTakeoutSessionRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Data exported successfully
	Success bool
}

// AccountFinishTakeoutSessionRequestTypeID is TL type id of AccountFinishTakeoutSessionRequest.
const AccountFinishTakeoutSessionRequestTypeID = 0x1d2652ee

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

func ( *AccountFinishTakeoutSessionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Success == false) {
		return false
	}

	return true
}

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

// FillFrom fills AccountFinishTakeoutSessionRequest from given interface.
func ( *AccountFinishTakeoutSessionRequest) ( interface {
	() ( bool)
}) {
	.Success = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountFinishTakeoutSessionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.finishTakeoutSession",
		ID:   AccountFinishTakeoutSessionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Success",
			SchemaName: "success",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountFinishTakeoutSessionRequest) () {
	if !(.Success == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountFinishTakeoutSessionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.finishTakeoutSession#1d2652ee as nil")
	}
	.PutID(AccountFinishTakeoutSessionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountFinishTakeoutSessionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.finishTakeoutSession#1d2652ee as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.finishTakeoutSession#1d2652ee: field flags: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountFinishTakeoutSessionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.finishTakeoutSession#1d2652ee to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.finishTakeoutSession#1d2652ee: field flags: %w", )
		}
	}
	.Success = .Flags.Has(0)
	return nil
}

// SetSuccess sets value of Success conditional field.
func ( *AccountFinishTakeoutSessionRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Success = true
	} else {
		.Flags.Unset(0)
		.Success = false
	}
}

// GetSuccess returns value of Success conditional field.
func ( *AccountFinishTakeoutSessionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// AccountFinishTakeoutSession invokes method account.finishTakeoutSession#1d2652ee returning error if any.
// Terminate a takeout session, see here » for more info¹.
//
// Links:
//  1. https://core.telegram.org/api/takeout
//
// Possible errors:
//
//	403 TAKEOUT_REQUIRED: A takeout session needs to be initialized first, see here » for more info.
//
// See https://core.telegram.org/method/account.finishTakeoutSession for reference.
func ( *Client) ( context.Context,  *AccountFinishTakeoutSessionRequest) (bool, error) {
	var  BoolBox

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