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

// MessagesAcceptEncryptionRequest represents TL type `messages.acceptEncryption#3dbc0415`.
// Confirms creation of a secret chat
//
// See https://core.telegram.org/method/messages.acceptEncryption for reference.
type MessagesAcceptEncryptionRequest struct {
	// Secret chat ID
	Peer InputEncryptedChat
	// B = g ^ b mod p, see Wikipedia¹
	//
	// Links:
	//  1) https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
	GB []byte
	// 64-bit fingerprint of the received key
	KeyFingerprint int64
}

// MessagesAcceptEncryptionRequestTypeID is TL type id of MessagesAcceptEncryptionRequest.
const MessagesAcceptEncryptionRequestTypeID = 0x3dbc0415

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

func ( *MessagesAcceptEncryptionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.GB == nil) {
		return false
	}
	if !(.KeyFingerprint == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesAcceptEncryptionRequest from given interface.
func ( *MessagesAcceptEncryptionRequest) ( interface {
	() ( InputEncryptedChat)
	() ( []byte)
	() ( int64)
}) {
	.Peer = .()
	.GB = .()
	.KeyFingerprint = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesAcceptEncryptionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.acceptEncryption",
		ID:   MessagesAcceptEncryptionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "GB",
			SchemaName: "g_b",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesAcceptEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.acceptEncryption#3dbc0415 as nil")
	}
	.PutID(MessagesAcceptEncryptionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesAcceptEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.acceptEncryption#3dbc0415 as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.acceptEncryption#3dbc0415: field peer: %w", )
	}
	.PutBytes(.GB)
	.PutLong(.KeyFingerprint)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesAcceptEncryptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.acceptEncryption#3dbc0415 to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.acceptEncryption#3dbc0415: field peer: %w", )
		}
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode messages.acceptEncryption#3dbc0415: field g_b: %w", )
		}
		.GB = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.acceptEncryption#3dbc0415: field key_fingerprint: %w", )
		}
		.KeyFingerprint = 
	}
	return nil
}

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

// GetGB returns value of GB field.
func ( *MessagesAcceptEncryptionRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .GB
}

// GetKeyFingerprint returns value of KeyFingerprint field.
func ( *MessagesAcceptEncryptionRequest) () ( int64) {
	if  == nil {
		return
	}
	return .KeyFingerprint
}

// MessagesAcceptEncryption invokes method messages.acceptEncryption#3dbc0415 returning error if any.
// Confirms creation of a secret chat
//
// Possible errors:
//
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 ENCRYPTION_ALREADY_ACCEPTED: Secret chat already accepted.
//	400 ENCRYPTION_ALREADY_DECLINED: The secret chat was already declined.
//
// See https://core.telegram.org/method/messages.acceptEncryption for reference.
func ( *Client) ( context.Context,  *MessagesAcceptEncryptionRequest) (EncryptedChatClass, error) {
	var  EncryptedChatBox

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