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 AccountRegisterDeviceRequest struct {
Flags bin .Fields
NoMuted bool
TokenType int
Token string
AppSandbox bool
Secret []byte
OtherUIDs []int64
}
const AccountRegisterDeviceRequestTypeID = 0xec86017a
var (
_ bin .Encoder = &AccountRegisterDeviceRequest {}
_ bin .Decoder = &AccountRegisterDeviceRequest {}
_ bin .BareEncoder = &AccountRegisterDeviceRequest {}
_ bin .BareDecoder = &AccountRegisterDeviceRequest {}
)
func (r *AccountRegisterDeviceRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .NoMuted == false ) {
return false
}
if !(r .TokenType == 0 ) {
return false
}
if !(r .Token == "" ) {
return false
}
if !(r .AppSandbox == false ) {
return false
}
if !(r .Secret == nil ) {
return false
}
if !(r .OtherUIDs == nil ) {
return false
}
return true
}
func (r *AccountRegisterDeviceRequest ) String () string {
if r == nil {
return "AccountRegisterDeviceRequest(nil)"
}
type Alias AccountRegisterDeviceRequest
return fmt .Sprintf ("AccountRegisterDeviceRequest%+v" , Alias (*r ))
}
func (r *AccountRegisterDeviceRequest ) FillFrom (from interface {
GetNoMuted () (value bool )
GetTokenType () (value int )
GetToken () (value string )
GetAppSandbox () (value bool )
GetSecret () (value []byte )
GetOtherUIDs () (value []int64 )
}) {
r .NoMuted = from .GetNoMuted ()
r .TokenType = from .GetTokenType ()
r .Token = from .GetToken ()
r .AppSandbox = from .GetAppSandbox ()
r .Secret = from .GetSecret ()
r .OtherUIDs = from .GetOtherUIDs ()
}
func (*AccountRegisterDeviceRequest ) TypeID () uint32 {
return AccountRegisterDeviceRequestTypeID
}
func (*AccountRegisterDeviceRequest ) TypeName () string {
return "account.registerDevice"
}
func (r *AccountRegisterDeviceRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.registerDevice" ,
ID : AccountRegisterDeviceRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NoMuted" ,
SchemaName : "no_muted" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "TokenType" ,
SchemaName : "token_type" ,
},
{
Name : "Token" ,
SchemaName : "token" ,
},
{
Name : "AppSandbox" ,
SchemaName : "app_sandbox" ,
},
{
Name : "Secret" ,
SchemaName : "secret" ,
},
{
Name : "OtherUIDs" ,
SchemaName : "other_uids" ,
},
}
return typ
}
func (r *AccountRegisterDeviceRequest ) SetFlags () {
if !(r .NoMuted == false ) {
r .Flags .Set (0 )
}
}
func (r *AccountRegisterDeviceRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode account.registerDevice#ec86017a as nil" )
}
b .PutID (AccountRegisterDeviceRequestTypeID )
return r .EncodeBare (b )
}
func (r *AccountRegisterDeviceRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode account.registerDevice#ec86017a as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.registerDevice#ec86017a: field flags: %w" , err )
}
b .PutInt (r .TokenType )
b .PutString (r .Token )
b .PutBool (r .AppSandbox )
b .PutBytes (r .Secret )
b .PutVectorHeader (len (r .OtherUIDs ))
for _ , v := range r .OtherUIDs {
b .PutLong (v )
}
return nil
}
func (r *AccountRegisterDeviceRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode account.registerDevice#ec86017a to nil" )
}
if err := b .ConsumeID (AccountRegisterDeviceRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: %w" , err )
}
return r .DecodeBare (b )
}
func (r *AccountRegisterDeviceRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode account.registerDevice#ec86017a to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: field flags: %w" , err )
}
}
r .NoMuted = r .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: field token_type: %w" , err )
}
r .TokenType = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: field token: %w" , err )
}
r .Token = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: field app_sandbox: %w" , err )
}
r .AppSandbox = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: field secret: %w" , err )
}
r .Secret = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.registerDevice#ec86017a: field other_uids: %w" , err )
}
if headerLen > 0 {
r .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.registerDevice#ec86017a: field other_uids: %w" , err )
}
r .OtherUIDs = append (r .OtherUIDs , value )
}
}
return nil
}
func (r *AccountRegisterDeviceRequest ) SetNoMuted (value bool ) {
if value {
r .Flags .Set (0 )
r .NoMuted = true
} else {
r .Flags .Unset (0 )
r .NoMuted = false
}
}
func (r *AccountRegisterDeviceRequest ) GetNoMuted () (value bool ) {
if r == nil {
return
}
return r .Flags .Has (0 )
}
func (r *AccountRegisterDeviceRequest ) GetTokenType () (value int ) {
if r == nil {
return
}
return r .TokenType
}
func (r *AccountRegisterDeviceRequest ) GetToken () (value string ) {
if r == nil {
return
}
return r .Token
}
func (r *AccountRegisterDeviceRequest ) GetAppSandbox () (value bool ) {
if r == nil {
return
}
return r .AppSandbox
}
func (r *AccountRegisterDeviceRequest ) GetSecret () (value []byte ) {
if r == nil {
return
}
return r .Secret
}
func (r *AccountRegisterDeviceRequest ) GetOtherUIDs () (value []int64 ) {
if r == nil {
return
}
return r .OtherUIDs
}
func (c *Client ) AccountRegisterDevice (ctx context .Context , request *AccountRegisterDeviceRequest ) (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 .