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 AccountUnregisterDeviceRequest struct {
TokenType int
Token string
OtherUIDs []int64
}
const AccountUnregisterDeviceRequestTypeID = 0x6a0d3206
var (
_ bin .Encoder = &AccountUnregisterDeviceRequest {}
_ bin .Decoder = &AccountUnregisterDeviceRequest {}
_ bin .BareEncoder = &AccountUnregisterDeviceRequest {}
_ bin .BareDecoder = &AccountUnregisterDeviceRequest {}
)
func (u *AccountUnregisterDeviceRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .TokenType == 0 ) {
return false
}
if !(u .Token == "" ) {
return false
}
if !(u .OtherUIDs == nil ) {
return false
}
return true
}
func (u *AccountUnregisterDeviceRequest ) String () string {
if u == nil {
return "AccountUnregisterDeviceRequest(nil)"
}
type Alias AccountUnregisterDeviceRequest
return fmt .Sprintf ("AccountUnregisterDeviceRequest%+v" , Alias (*u ))
}
func (u *AccountUnregisterDeviceRequest ) FillFrom (from interface {
GetTokenType () (value int )
GetToken () (value string )
GetOtherUIDs () (value []int64 )
}) {
u .TokenType = from .GetTokenType ()
u .Token = from .GetToken ()
u .OtherUIDs = from .GetOtherUIDs ()
}
func (*AccountUnregisterDeviceRequest ) TypeID () uint32 {
return AccountUnregisterDeviceRequestTypeID
}
func (*AccountUnregisterDeviceRequest ) TypeName () string {
return "account.unregisterDevice"
}
func (u *AccountUnregisterDeviceRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.unregisterDevice" ,
ID : AccountUnregisterDeviceRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "TokenType" ,
SchemaName : "token_type" ,
},
{
Name : "Token" ,
SchemaName : "token" ,
},
{
Name : "OtherUIDs" ,
SchemaName : "other_uids" ,
},
}
return typ
}
func (u *AccountUnregisterDeviceRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.unregisterDevice#6a0d3206 as nil" )
}
b .PutID (AccountUnregisterDeviceRequestTypeID )
return u .EncodeBare (b )
}
func (u *AccountUnregisterDeviceRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.unregisterDevice#6a0d3206 as nil" )
}
b .PutInt (u .TokenType )
b .PutString (u .Token )
b .PutVectorHeader (len (u .OtherUIDs ))
for _ , v := range u .OtherUIDs {
b .PutLong (v )
}
return nil
}
func (u *AccountUnregisterDeviceRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.unregisterDevice#6a0d3206 to nil" )
}
if err := b .ConsumeID (AccountUnregisterDeviceRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.unregisterDevice#6a0d3206: %w" , err )
}
return u .DecodeBare (b )
}
func (u *AccountUnregisterDeviceRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.unregisterDevice#6a0d3206 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode account.unregisterDevice#6a0d3206: field token_type: %w" , err )
}
u .TokenType = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.unregisterDevice#6a0d3206: field token: %w" , err )
}
u .Token = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.unregisterDevice#6a0d3206: field other_uids: %w" , err )
}
if headerLen > 0 {
u .OtherUIDs = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.unregisterDevice#6a0d3206: field other_uids: %w" , err )
}
u .OtherUIDs = append (u .OtherUIDs , value )
}
}
return nil
}
func (u *AccountUnregisterDeviceRequest ) GetTokenType () (value int ) {
if u == nil {
return
}
return u .TokenType
}
func (u *AccountUnregisterDeviceRequest ) GetToken () (value string ) {
if u == nil {
return
}
return u .Token
}
func (u *AccountUnregisterDeviceRequest ) GetOtherUIDs () (value []int64 ) {
if u == nil {
return
}
return u .OtherUIDs
}
func (c *Client ) AccountUnregisterDevice (ctx context .Context , request *AccountUnregisterDeviceRequest ) (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 .