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 ChannelsReorderUsernamesRequest struct {
Channel InputChannelClass
Order []string
}
const ChannelsReorderUsernamesRequestTypeID = 0xb45ced1d
var (
_ bin .Encoder = &ChannelsReorderUsernamesRequest {}
_ bin .Decoder = &ChannelsReorderUsernamesRequest {}
_ bin .BareEncoder = &ChannelsReorderUsernamesRequest {}
_ bin .BareDecoder = &ChannelsReorderUsernamesRequest {}
)
func (r *ChannelsReorderUsernamesRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Channel == nil ) {
return false
}
if !(r .Order == nil ) {
return false
}
return true
}
func (r *ChannelsReorderUsernamesRequest ) String () string {
if r == nil {
return "ChannelsReorderUsernamesRequest(nil)"
}
type Alias ChannelsReorderUsernamesRequest
return fmt .Sprintf ("ChannelsReorderUsernamesRequest%+v" , Alias (*r ))
}
func (r *ChannelsReorderUsernamesRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetOrder () (value []string )
}) {
r .Channel = from .GetChannel ()
r .Order = from .GetOrder ()
}
func (*ChannelsReorderUsernamesRequest ) TypeID () uint32 {
return ChannelsReorderUsernamesRequestTypeID
}
func (*ChannelsReorderUsernamesRequest ) TypeName () string {
return "channels.reorderUsernames"
}
func (r *ChannelsReorderUsernamesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.reorderUsernames" ,
ID : ChannelsReorderUsernamesRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Order" ,
SchemaName : "order" ,
},
}
return typ
}
func (r *ChannelsReorderUsernamesRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode channels.reorderUsernames#b45ced1d as nil" )
}
b .PutID (ChannelsReorderUsernamesRequestTypeID )
return r .EncodeBare (b )
}
func (r *ChannelsReorderUsernamesRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode channels.reorderUsernames#b45ced1d as nil" )
}
if r .Channel == nil {
return fmt .Errorf ("unable to encode channels.reorderUsernames#b45ced1d: field channel is nil" )
}
if err := r .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.reorderUsernames#b45ced1d: field channel: %w" , err )
}
b .PutVectorHeader (len (r .Order ))
for _ , v := range r .Order {
b .PutString (v )
}
return nil
}
func (r *ChannelsReorderUsernamesRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode channels.reorderUsernames#b45ced1d to nil" )
}
if err := b .ConsumeID (ChannelsReorderUsernamesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.reorderUsernames#b45ced1d: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ChannelsReorderUsernamesRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode channels.reorderUsernames#b45ced1d to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.reorderUsernames#b45ced1d: field channel: %w" , err )
}
r .Channel = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channels.reorderUsernames#b45ced1d: field order: %w" , err )
}
if headerLen > 0 {
r .Order = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.reorderUsernames#b45ced1d: field order: %w" , err )
}
r .Order = append (r .Order , value )
}
}
return nil
}
func (r *ChannelsReorderUsernamesRequest ) GetChannel () (value InputChannelClass ) {
if r == nil {
return
}
return r .Channel
}
func (r *ChannelsReorderUsernamesRequest ) GetOrder () (value []string ) {
if r == nil {
return
}
return r .Order
}
func (r *ChannelsReorderUsernamesRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return r .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsReorderUsernames (ctx context .Context , request *ChannelsReorderUsernamesRequest ) (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 .