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

// MessagesSendEncryptedServiceRequest represents TL type `messages.sendEncryptedService#32d439a4`.
// Sends a service message to a secret chat.
//
// See https://core.telegram.org/method/messages.sendEncryptedService for reference.
type MessagesSendEncryptedServiceRequest struct {
	// Secret chat ID
	Peer InputEncryptedChat
	// Unique client message ID required to prevent message resending
	RandomID int64
	// TL-serialization of  DecryptedMessage¹ type, encrypted with a key generated during
	// chat initialization
	//
	// Links:
	//  1) https://core.telegram.org/type/DecryptedMessage
	Data []byte
}

// MessagesSendEncryptedServiceRequestTypeID is TL type id of MessagesSendEncryptedServiceRequest.
const MessagesSendEncryptedServiceRequestTypeID = 0x32d439a4

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

func ( *MessagesSendEncryptedServiceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.Data == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendEncryptedServiceRequest from given interface.
func ( *MessagesSendEncryptedServiceRequest) ( interface {
	() ( InputEncryptedChat)
	() ( int64)
	() ( []byte)
}) {
	.Peer = .()
	.RandomID = .()
	.Data = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSendEncryptedServiceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendEncryptedService",
		ID:   MessagesSendEncryptedServiceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSendEncryptedServiceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendEncryptedService#32d439a4 as nil")
	}
	.PutID(MessagesSendEncryptedServiceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendEncryptedServiceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendEncryptedService#32d439a4 as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendEncryptedService#32d439a4: field peer: %w", )
	}
	.PutLong(.RandomID)
	.PutBytes(.Data)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendEncryptedServiceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendEncryptedService#32d439a4 to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedService#32d439a4: field peer: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedService#32d439a4: field random_id: %w", )
		}
		.RandomID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedService#32d439a4: field data: %w", )
		}
		.Data = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *MessagesSendEncryptedServiceRequest) () ( InputEncryptedChat) {
	if  == nil {
		return
	}
	return .Peer
}

// GetRandomID returns value of RandomID field.
func ( *MessagesSendEncryptedServiceRequest) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// GetData returns value of Data field.
func ( *MessagesSendEncryptedServiceRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .Data
}

// MessagesSendEncryptedService invokes method messages.sendEncryptedService#32d439a4 returning error if any.
// Sends a service message to a secret chat.
//
// Possible errors:
//
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 DATA_INVALID: Encrypted data invalid.
//	400 ENCRYPTION_DECLINED: The secret chat was declined.
//	400 ENCRYPTION_ID_INVALID: The provided secret chat ID is invalid.
//	500 MSG_WAIT_FAILED: A waiting call returned an error.
//	403 USER_DELETED: You can't send this secret message because the other participant deleted their account.
//	403 USER_IS_BLOCKED: You were blocked by this user.
//
// See https://core.telegram.org/method/messages.sendEncryptedService for reference.
func ( *Client) ( context.Context,  *MessagesSendEncryptedServiceRequest) (MessagesSentEncryptedMessageClass, error) {
	var  MessagesSentEncryptedMessageBox

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