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 ContactsToggleTopPeersRequest struct {
Enabled bool
}
const ContactsToggleTopPeersRequestTypeID = 0x8514bdda
var (
_ bin .Encoder = &ContactsToggleTopPeersRequest {}
_ bin .Decoder = &ContactsToggleTopPeersRequest {}
_ bin .BareEncoder = &ContactsToggleTopPeersRequest {}
_ bin .BareDecoder = &ContactsToggleTopPeersRequest {}
)
func (t *ContactsToggleTopPeersRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Enabled == false ) {
return false
}
return true
}
func (t *ContactsToggleTopPeersRequest ) String () string {
if t == nil {
return "ContactsToggleTopPeersRequest(nil)"
}
type Alias ContactsToggleTopPeersRequest
return fmt .Sprintf ("ContactsToggleTopPeersRequest%+v" , Alias (*t ))
}
func (t *ContactsToggleTopPeersRequest ) FillFrom (from interface {
GetEnabled () (value bool )
}) {
t .Enabled = from .GetEnabled ()
}
func (*ContactsToggleTopPeersRequest ) TypeID () uint32 {
return ContactsToggleTopPeersRequestTypeID
}
func (*ContactsToggleTopPeersRequest ) TypeName () string {
return "contacts.toggleTopPeers"
}
func (t *ContactsToggleTopPeersRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.toggleTopPeers" ,
ID : ContactsToggleTopPeersRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Enabled" ,
SchemaName : "enabled" ,
},
}
return typ
}
func (t *ContactsToggleTopPeersRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode contacts.toggleTopPeers#8514bdda as nil" )
}
b .PutID (ContactsToggleTopPeersRequestTypeID )
return t .EncodeBare (b )
}
func (t *ContactsToggleTopPeersRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode contacts.toggleTopPeers#8514bdda as nil" )
}
b .PutBool (t .Enabled )
return nil
}
func (t *ContactsToggleTopPeersRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode contacts.toggleTopPeers#8514bdda to nil" )
}
if err := b .ConsumeID (ContactsToggleTopPeersRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.toggleTopPeers#8514bdda: %w" , err )
}
return t .DecodeBare (b )
}
func (t *ContactsToggleTopPeersRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode contacts.toggleTopPeers#8514bdda to nil" )
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.toggleTopPeers#8514bdda: field enabled: %w" , err )
}
t .Enabled = value
}
return nil
}
func (t *ContactsToggleTopPeersRequest ) GetEnabled () (value bool ) {
if t == nil {
return
}
return t .Enabled
}
func (c *Client ) ContactsToggleTopPeers (ctx context .Context , enabled bool ) (bool , error ) {
var result BoolBox
request := &ContactsToggleTopPeersRequest {
Enabled : enabled ,
}
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 .