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

// MessagesMarkDialogUnreadRequest represents TL type `messages.markDialogUnread#c286d98f`.
// Manually mark dialog as unread
//
// See https://core.telegram.org/method/messages.markDialogUnread for reference.
type MessagesMarkDialogUnreadRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Mark as unread/read
	Unread bool
	// Dialog
	Peer InputDialogPeerClass
}

// MessagesMarkDialogUnreadRequestTypeID is TL type id of MessagesMarkDialogUnreadRequest.
const MessagesMarkDialogUnreadRequestTypeID = 0xc286d98f

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

func ( *MessagesMarkDialogUnreadRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Unread == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesMarkDialogUnreadRequest from given interface.
func ( *MessagesMarkDialogUnreadRequest) ( interface {
	() ( bool)
	() ( InputDialogPeerClass)
}) {
	.Unread = .()
	.Peer = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesMarkDialogUnreadRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.markDialogUnread",
		ID:   MessagesMarkDialogUnreadRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Unread",
			SchemaName: "unread",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesMarkDialogUnreadRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.markDialogUnread#c286d98f as nil")
	}
	.PutID(MessagesMarkDialogUnreadRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesMarkDialogUnreadRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.markDialogUnread#c286d98f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.markDialogUnread#c286d98f: field flags: %w", )
		}
	}
	.Unread = .Flags.Has(0)
	{
		,  := DecodeInputDialogPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.markDialogUnread#c286d98f: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

// SetUnread sets value of Unread conditional field.
func ( *MessagesMarkDialogUnreadRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Unread = true
	} else {
		.Flags.Unset(0)
		.Unread = false
	}
}

// GetUnread returns value of Unread conditional field.
func ( *MessagesMarkDialogUnreadRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// MessagesMarkDialogUnread invokes method messages.markDialogUnread#c286d98f returning error if any.
// Manually mark dialog as unread
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.markDialogUnread for reference.
func ( *Client) ( context.Context,  *MessagesMarkDialogUnreadRequest) (bool, error) {
	var  BoolBox

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