package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type MessagesMarkDialogUnreadRequest struct {
Flags bin .Fields
Unread bool
Peer InputDialogPeerClass
}
const MessagesMarkDialogUnreadRequestTypeID = 0xc286d98f
var (
_ bin .Encoder = &MessagesMarkDialogUnreadRequest {}
_ bin .Decoder = &MessagesMarkDialogUnreadRequest {}
_ bin .BareEncoder = &MessagesMarkDialogUnreadRequest {}
_ bin .BareDecoder = &MessagesMarkDialogUnreadRequest {}
)
func (m *MessagesMarkDialogUnreadRequest ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .Unread == false ) {
return false
}
if !(m .Peer == nil ) {
return false
}
return true
}
func (m *MessagesMarkDialogUnreadRequest ) String () string {
if m == nil {
return "MessagesMarkDialogUnreadRequest(nil)"
}
type Alias MessagesMarkDialogUnreadRequest
return fmt .Sprintf ("MessagesMarkDialogUnreadRequest%+v" , Alias (*m ))
}
func (m *MessagesMarkDialogUnreadRequest ) FillFrom (from interface {
GetUnread () (value bool )
GetPeer () (value InputDialogPeerClass )
}) {
m .Unread = from .GetUnread ()
m .Peer = from .GetPeer ()
}
func (*MessagesMarkDialogUnreadRequest ) TypeID () uint32 {
return MessagesMarkDialogUnreadRequestTypeID
}
func (*MessagesMarkDialogUnreadRequest ) TypeName () string {
return "messages.markDialogUnread"
}
func (m *MessagesMarkDialogUnreadRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.markDialogUnread" ,
ID : MessagesMarkDialogUnreadRequestTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Unread" ,
SchemaName : "unread" ,
Null : !m .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
}
return typ
}
func (m *MessagesMarkDialogUnreadRequest ) SetFlags () {
if !(m .Unread == false ) {
m .Flags .Set (0 )
}
}
func (m *MessagesMarkDialogUnreadRequest ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.markDialogUnread#c286d98f as nil" )
}
b .PutID (MessagesMarkDialogUnreadRequestTypeID )
return m .EncodeBare (b )
}
func (m *MessagesMarkDialogUnreadRequest ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.markDialogUnread#c286d98f as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.markDialogUnread#c286d98f: field flags: %w" , err )
}
if m .Peer == nil {
return fmt .Errorf ("unable to encode messages.markDialogUnread#c286d98f: field peer is nil" )
}
if err := m .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.markDialogUnread#c286d98f: field peer: %w" , err )
}
return nil
}
func (m *MessagesMarkDialogUnreadRequest ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.markDialogUnread#c286d98f to nil" )
}
if err := b .ConsumeID (MessagesMarkDialogUnreadRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.markDialogUnread#c286d98f: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagesMarkDialogUnreadRequest ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.markDialogUnread#c286d98f to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.markDialogUnread#c286d98f: field flags: %w" , err )
}
}
m .Unread = m .Flags .Has (0 )
{
value , err := DecodeInputDialogPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.markDialogUnread#c286d98f: field peer: %w" , err )
}
m .Peer = value
}
return nil
}
func (m *MessagesMarkDialogUnreadRequest ) SetUnread (value bool ) {
if value {
m .Flags .Set (0 )
m .Unread = true
} else {
m .Flags .Unset (0 )
m .Unread = false
}
}
func (m *MessagesMarkDialogUnreadRequest ) GetUnread () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (0 )
}
func (m *MessagesMarkDialogUnreadRequest ) GetPeer () (value InputDialogPeerClass ) {
if m == nil {
return
}
return m .Peer
}
func (c *Client ) MessagesMarkDialogUnread (ctx context .Context , request *MessagesMarkDialogUnreadRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .