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

// MessagesReadDiscussionRequest represents TL type `messages.readDiscussion#f731a9f4`.
// Mark a thread¹ as read
//
// Links:
//  1. https://core.telegram.org/api/threads
//
// See https://core.telegram.org/method/messages.readDiscussion for reference.
type MessagesReadDiscussionRequest struct {
	// Group ID
	Peer InputPeerClass
	// ID of message that started the thread
	MsgID int
	// ID up to which thread messages were read
	ReadMaxID int
}

// MessagesReadDiscussionRequestTypeID is TL type id of MessagesReadDiscussionRequest.
const MessagesReadDiscussionRequestTypeID = 0xf731a9f4

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

func ( *MessagesReadDiscussionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.ReadMaxID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReadDiscussionRequest from given interface.
func ( *MessagesReadDiscussionRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( int)
}) {
	.Peer = .()
	.MsgID = .()
	.ReadMaxID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesReadDiscussionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.readDiscussion",
		ID:   MessagesReadDiscussionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "ReadMaxID",
			SchemaName: "read_max_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesReadDiscussionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.readDiscussion#f731a9f4 as nil")
	}
	.PutID(MessagesReadDiscussionRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReadDiscussionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.readDiscussion#f731a9f4 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readDiscussion#f731a9f4: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readDiscussion#f731a9f4: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readDiscussion#f731a9f4: field read_max_id: %w", )
		}
		.ReadMaxID = 
	}
	return nil
}

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

// GetMsgID returns value of MsgID field.
func ( *MessagesReadDiscussionRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetReadMaxID returns value of ReadMaxID field.
func ( *MessagesReadDiscussionRequest) () ( int) {
	if  == nil {
		return
	}
	return .ReadMaxID
}

// MessagesReadDiscussion invokes method messages.readDiscussion#f731a9f4 returning error if any.
// Mark a thread¹ as read
//
// Links:
//  1. https://core.telegram.org/api/threads
//
// Possible errors:
//
//	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.readDiscussion for reference.
func ( *Client) ( context.Context,  *MessagesReadDiscussionRequest) (bool, error) {
	var  BoolBox

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