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 AccountToggleUsernameRequest struct {
Username string
Active bool
}
const AccountToggleUsernameRequestTypeID = 0x58d6b376
var (
_ bin .Encoder = &AccountToggleUsernameRequest {}
_ bin .Decoder = &AccountToggleUsernameRequest {}
_ bin .BareEncoder = &AccountToggleUsernameRequest {}
_ bin .BareDecoder = &AccountToggleUsernameRequest {}
)
func (t *AccountToggleUsernameRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Username == "" ) {
return false
}
if !(t .Active == false ) {
return false
}
return true
}
func (t *AccountToggleUsernameRequest ) String () string {
if t == nil {
return "AccountToggleUsernameRequest(nil)"
}
type Alias AccountToggleUsernameRequest
return fmt .Sprintf ("AccountToggleUsernameRequest%+v" , Alias (*t ))
}
func (t *AccountToggleUsernameRequest ) FillFrom (from interface {
GetUsername () (value string )
GetActive () (value bool )
}) {
t .Username = from .GetUsername ()
t .Active = from .GetActive ()
}
func (*AccountToggleUsernameRequest ) TypeID () uint32 {
return AccountToggleUsernameRequestTypeID
}
func (*AccountToggleUsernameRequest ) TypeName () string {
return "account.toggleUsername"
}
func (t *AccountToggleUsernameRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.toggleUsername" ,
ID : AccountToggleUsernameRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Username" ,
SchemaName : "username" ,
},
{
Name : "Active" ,
SchemaName : "active" ,
},
}
return typ
}
func (t *AccountToggleUsernameRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode account.toggleUsername#58d6b376 as nil" )
}
b .PutID (AccountToggleUsernameRequestTypeID )
return t .EncodeBare (b )
}
func (t *AccountToggleUsernameRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode account.toggleUsername#58d6b376 as nil" )
}
b .PutString (t .Username )
b .PutBool (t .Active )
return nil
}
func (t *AccountToggleUsernameRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode account.toggleUsername#58d6b376 to nil" )
}
if err := b .ConsumeID (AccountToggleUsernameRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.toggleUsername#58d6b376: %w" , err )
}
return t .DecodeBare (b )
}
func (t *AccountToggleUsernameRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode account.toggleUsername#58d6b376 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.toggleUsername#58d6b376: field username: %w" , err )
}
t .Username = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode account.toggleUsername#58d6b376: field active: %w" , err )
}
t .Active = value
}
return nil
}
func (t *AccountToggleUsernameRequest ) GetUsername () (value string ) {
if t == nil {
return
}
return t .Username
}
func (t *AccountToggleUsernameRequest ) GetActive () (value bool ) {
if t == nil {
return
}
return t .Active
}
func (c *Client ) AccountToggleUsername (ctx context .Context , request *AccountToggleUsernameRequest ) (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 .