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

// MessagesReadReactionsRequest represents TL type `messages.readReactions#54aa7f8e`.
// Mark message reactions »¹ as read
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// See https://core.telegram.org/method/messages.readReactions for reference.
type MessagesReadReactionsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Peer
	Peer InputPeerClass
	// Mark as read only reactions to messages within the specified forum topic¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum#forum-topics
	//
	// Use SetTopMsgID and GetTopMsgID helpers.
	TopMsgID int
}

// MessagesReadReactionsRequestTypeID is TL type id of MessagesReadReactionsRequest.
const MessagesReadReactionsRequestTypeID = 0x54aa7f8e

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

func ( *MessagesReadReactionsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.TopMsgID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReadReactionsRequest from given interface.
func ( *MessagesReadReactionsRequest) ( interface {
	() ( InputPeerClass)
	() ( int,  bool)
}) {
	.Peer = .()
	if ,  := .();  {
		.TopMsgID = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesReadReactionsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.readReactions",
		ID:   MessagesReadReactionsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "TopMsgID",
			SchemaName: "top_msg_id",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesReadReactionsRequest) () {
	if !(.TopMsgID == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesReadReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.readReactions#54aa7f8e as nil")
	}
	.PutID(MessagesReadReactionsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesReadReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.readReactions#54aa7f8e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.readReactions#54aa7f8e: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.readReactions#54aa7f8e: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.readReactions#54aa7f8e: field peer: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.TopMsgID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReadReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.readReactions#54aa7f8e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: field top_msg_id: %w", )
		}
		.TopMsgID = 
	}
	return nil
}

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

// SetTopMsgID sets value of TopMsgID conditional field.
func ( *MessagesReadReactionsRequest) ( int) {
	.Flags.Set(0)
	.TopMsgID = 
}

// GetTopMsgID returns value of TopMsgID conditional field and
// boolean which is true if field was set.
func ( *MessagesReadReactionsRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .TopMsgID, true
}

// MessagesReadReactions invokes method messages.readReactions#54aa7f8e returning error if any.
// Mark message reactions »¹ as read
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.readReactions for reference.
func ( *Client) ( context.Context,  *MessagesReadReactionsRequest) (*MessagesAffectedHistory, error) {
	var  MessagesAffectedHistory

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