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

// MessagesReadHistoryRequest represents TL type `messages.readHistory#e306d3a`.
// Marks message history as read.
//
// See https://core.telegram.org/method/messages.readHistory for reference.
type MessagesReadHistoryRequest struct {
	// Target user or group
	Peer InputPeerClass
	// If a positive value is passed, only messages with identifiers less or equal than the
	// given one will be read
	MaxID int
}

// MessagesReadHistoryRequestTypeID is TL type id of MessagesReadHistoryRequest.
const MessagesReadHistoryRequestTypeID = 0xe306d3a

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

func ( *MessagesReadHistoryRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MaxID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReadHistoryRequest from given interface.
func ( *MessagesReadHistoryRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
}) {
	.Peer = .()
	.MaxID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesReadHistoryRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.readHistory",
		ID:   MessagesReadHistoryRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MaxID",
			SchemaName: "max_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesReadHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.readHistory#e306d3a as nil")
	}
	.PutID(MessagesReadHistoryRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReadHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.readHistory#e306d3a to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readHistory#e306d3a: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readHistory#e306d3a: field max_id: %w", )
		}
		.MaxID = 
	}
	return nil
}

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

// GetMaxID returns value of MaxID field.
func ( *MessagesReadHistoryRequest) () ( int) {
	if  == nil {
		return
	}
	return .MaxID
}

// MessagesReadHistory invokes method messages.readHistory#e306d3a returning error if any.
// Marks message history as read.
//
// Possible errors:
//
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.readHistory for reference.
func ( *Client) ( context.Context,  *MessagesReadHistoryRequest) (*MessagesAffectedMessages, error) {
	var  MessagesAffectedMessages

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