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

// MessagesReadEncryptedHistoryRequest represents TL type `messages.readEncryptedHistory#7f4b690a`.
// Marks message history within a secret chat as read.
//
// See https://core.telegram.org/method/messages.readEncryptedHistory for reference.
type MessagesReadEncryptedHistoryRequest struct {
	// Secret chat ID
	Peer InputEncryptedChat
	// Maximum date value for received messages in history
	MaxDate int
}

// MessagesReadEncryptedHistoryRequestTypeID is TL type id of MessagesReadEncryptedHistoryRequest.
const MessagesReadEncryptedHistoryRequestTypeID = 0x7f4b690a

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

func ( *MessagesReadEncryptedHistoryRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.MaxDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReadEncryptedHistoryRequest from given interface.
func ( *MessagesReadEncryptedHistoryRequest) ( interface {
	() ( InputEncryptedChat)
	() ( int)
}) {
	.Peer = .()
	.MaxDate = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesReadEncryptedHistoryRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.readEncryptedHistory",
		ID:   MessagesReadEncryptedHistoryRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MaxDate",
			SchemaName: "max_date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesReadEncryptedHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.readEncryptedHistory#7f4b690a as nil")
	}
	.PutID(MessagesReadEncryptedHistoryRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesReadEncryptedHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.readEncryptedHistory#7f4b690a as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.readEncryptedHistory#7f4b690a: field peer: %w", )
	}
	.PutInt(.MaxDate)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReadEncryptedHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.readEncryptedHistory#7f4b690a to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.readEncryptedHistory#7f4b690a: field peer: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readEncryptedHistory#7f4b690a: field max_date: %w", )
		}
		.MaxDate = 
	}
	return nil
}

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

// GetMaxDate returns value of MaxDate field.
func ( *MessagesReadEncryptedHistoryRequest) () ( int) {
	if  == nil {
		return
	}
	return .MaxDate
}

// MessagesReadEncryptedHistory invokes method messages.readEncryptedHistory#7f4b690a returning error if any.
// Marks message history within a secret chat as read.
//
// Possible errors:
//
//	400 MSG_WAIT_FAILED: A waiting call returned an error.
//
// See https://core.telegram.org/method/messages.readEncryptedHistory for reference.
func ( *Client) ( context.Context,  *MessagesReadEncryptedHistoryRequest) (bool, error) {
	var  BoolBox

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