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

// MessagesDiscardEncryptionRequest represents TL type `messages.discardEncryption#f393aea0`.
// Cancels a request for creation and/or delete info on secret chat.
//
// See https://core.telegram.org/method/messages.discardEncryption for reference.
type MessagesDiscardEncryptionRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to delete the entire chat history for the other user as well
	DeleteHistory bool
	// Secret chat ID
	ChatID int
}

// MessagesDiscardEncryptionRequestTypeID is TL type id of MessagesDiscardEncryptionRequest.
const MessagesDiscardEncryptionRequestTypeID = 0xf393aea0

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

func ( *MessagesDiscardEncryptionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.DeleteHistory == false) {
		return false
	}
	if !(.ChatID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesDiscardEncryptionRequest from given interface.
func ( *MessagesDiscardEncryptionRequest) ( interface {
	() ( bool)
	() ( int)
}) {
	.DeleteHistory = .()
	.ChatID = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesDiscardEncryptionRequest) () string {
	return "messages.discardEncryption"
}

// TypeInfo returns info about TL type.
func ( *MessagesDiscardEncryptionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.discardEncryption",
		ID:   MessagesDiscardEncryptionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DeleteHistory",
			SchemaName: "delete_history",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesDiscardEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.discardEncryption#f393aea0 as nil")
	}
	.PutID(MessagesDiscardEncryptionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesDiscardEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.discardEncryption#f393aea0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.discardEncryption#f393aea0: field flags: %w", )
	}
	.PutInt(.ChatID)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesDiscardEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.discardEncryption#f393aea0 to nil")
	}
	if  := .ConsumeID(MessagesDiscardEncryptionRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.discardEncryption#f393aea0: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesDiscardEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.discardEncryption#f393aea0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.discardEncryption#f393aea0: field flags: %w", )
		}
	}
	.DeleteHistory = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.discardEncryption#f393aea0: field chat_id: %w", )
		}
		.ChatID = 
	}
	return nil
}

// SetDeleteHistory sets value of DeleteHistory conditional field.
func ( *MessagesDiscardEncryptionRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.DeleteHistory = true
	} else {
		.Flags.Unset(0)
		.DeleteHistory = false
	}
}

// GetDeleteHistory returns value of DeleteHistory conditional field.
func ( *MessagesDiscardEncryptionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetChatID returns value of ChatID field.
func ( *MessagesDiscardEncryptionRequest) () ( int) {
	if  == nil {
		return
	}
	return .ChatID
}

// MessagesDiscardEncryption invokes method messages.discardEncryption#f393aea0 returning error if any.
// Cancels a request for creation and/or delete info on secret chat.
//
// Possible errors:
//
//	400 CHAT_ID_EMPTY: The provided chat ID is empty.
//	400 ENCRYPTION_ALREADY_ACCEPTED: Secret chat already accepted.
//	400 ENCRYPTION_ALREADY_DECLINED: The secret chat was already declined.
//	400 ENCRYPTION_ID_INVALID: The provided secret chat ID is invalid.
//
// See https://core.telegram.org/method/messages.discardEncryption for reference.
func ( *Client) ( context.Context,  *MessagesDiscardEncryptionRequest) (bool, error) {
	var  BoolBox

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