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 ChannelsUpdateUsernameRequest struct {
Channel InputChannelClass
Username string
}
const ChannelsUpdateUsernameRequestTypeID = 0x3514b3de
var (
_ bin .Encoder = &ChannelsUpdateUsernameRequest {}
_ bin .Decoder = &ChannelsUpdateUsernameRequest {}
_ bin .BareEncoder = &ChannelsUpdateUsernameRequest {}
_ bin .BareDecoder = &ChannelsUpdateUsernameRequest {}
)
func (u *ChannelsUpdateUsernameRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Channel == nil ) {
return false
}
if !(u .Username == "" ) {
return false
}
return true
}
func (u *ChannelsUpdateUsernameRequest ) String () string {
if u == nil {
return "ChannelsUpdateUsernameRequest(nil)"
}
type Alias ChannelsUpdateUsernameRequest
return fmt .Sprintf ("ChannelsUpdateUsernameRequest%+v" , Alias (*u ))
}
func (u *ChannelsUpdateUsernameRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetUsername () (value string )
}) {
u .Channel = from .GetChannel ()
u .Username = from .GetUsername ()
}
func (*ChannelsUpdateUsernameRequest ) TypeID () uint32 {
return ChannelsUpdateUsernameRequestTypeID
}
func (*ChannelsUpdateUsernameRequest ) TypeName () string {
return "channels.updateUsername"
}
func (u *ChannelsUpdateUsernameRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.updateUsername" ,
ID : ChannelsUpdateUsernameRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
},
}
return typ
}
func (u *ChannelsUpdateUsernameRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode channels.updateUsername#3514b3de as nil" )
}
b .PutID (ChannelsUpdateUsernameRequestTypeID )
return u .EncodeBare (b )
}
func (u *ChannelsUpdateUsernameRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode channels.updateUsername#3514b3de as nil" )
}
if u .Channel == nil {
return fmt .Errorf ("unable to encode channels.updateUsername#3514b3de: field channel is nil" )
}
if err := u .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.updateUsername#3514b3de: field channel: %w" , err )
}
b .PutString (u .Username )
return nil
}
func (u *ChannelsUpdateUsernameRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode channels.updateUsername#3514b3de to nil" )
}
if err := b .ConsumeID (ChannelsUpdateUsernameRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.updateUsername#3514b3de: %w" , err )
}
return u .DecodeBare (b )
}
func (u *ChannelsUpdateUsernameRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode channels.updateUsername#3514b3de to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.updateUsername#3514b3de: field channel: %w" , err )
}
u .Channel = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.updateUsername#3514b3de: field username: %w" , err )
}
u .Username = value
}
return nil
}
func (u *ChannelsUpdateUsernameRequest ) GetChannel () (value InputChannelClass ) {
if u == nil {
return
}
return u .Channel
}
func (u *ChannelsUpdateUsernameRequest ) GetUsername () (value string ) {
if u == nil {
return
}
return u .Username
}
func (u *ChannelsUpdateUsernameRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return u .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsUpdateUsername (ctx context .Context , request *ChannelsUpdateUsernameRequest ) (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 .