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 Authorization struct {
Flags bin .Fields
Current bool
OfficialApp bool
PasswordPending bool
EncryptedRequestsDisabled bool
CallRequestsDisabled bool
Unconfirmed bool
Hash int64
DeviceModel string
Platform string
SystemVersion string
APIID int
AppName string
AppVersion string
DateCreated int
DateActive int
IP string
Country string
Region string
}
const AuthorizationTypeID = 0xad01d61d
var (
_ bin .Encoder = &Authorization {}
_ bin .Decoder = &Authorization {}
_ bin .BareEncoder = &Authorization {}
_ bin .BareDecoder = &Authorization {}
)
func (a *Authorization ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .Current == false ) {
return false
}
if !(a .OfficialApp == false ) {
return false
}
if !(a .PasswordPending == false ) {
return false
}
if !(a .EncryptedRequestsDisabled == false ) {
return false
}
if !(a .CallRequestsDisabled == false ) {
return false
}
if !(a .Unconfirmed == false ) {
return false
}
if !(a .Hash == 0 ) {
return false
}
if !(a .DeviceModel == "" ) {
return false
}
if !(a .Platform == "" ) {
return false
}
if !(a .SystemVersion == "" ) {
return false
}
if !(a .APIID == 0 ) {
return false
}
if !(a .AppName == "" ) {
return false
}
if !(a .AppVersion == "" ) {
return false
}
if !(a .DateCreated == 0 ) {
return false
}
if !(a .DateActive == 0 ) {
return false
}
if !(a .IP == "" ) {
return false
}
if !(a .Country == "" ) {
return false
}
if !(a .Region == "" ) {
return false
}
return true
}
func (a *Authorization ) String () string {
if a == nil {
return "Authorization(nil)"
}
type Alias Authorization
return fmt .Sprintf ("Authorization%+v" , Alias (*a ))
}
func (a *Authorization ) FillFrom (from interface {
GetCurrent () (value bool )
GetOfficialApp () (value bool )
GetPasswordPending () (value bool )
GetEncryptedRequestsDisabled () (value bool )
GetCallRequestsDisabled () (value bool )
GetUnconfirmed () (value bool )
GetHash () (value int64 )
GetDeviceModel () (value string )
GetPlatform () (value string )
GetSystemVersion () (value string )
GetAPIID () (value int )
GetAppName () (value string )
GetAppVersion () (value string )
GetDateCreated () (value int )
GetDateActive () (value int )
GetIP () (value string )
GetCountry () (value string )
GetRegion () (value string )
}) {
a .Current = from .GetCurrent ()
a .OfficialApp = from .GetOfficialApp ()
a .PasswordPending = from .GetPasswordPending ()
a .EncryptedRequestsDisabled = from .GetEncryptedRequestsDisabled ()
a .CallRequestsDisabled = from .GetCallRequestsDisabled ()
a .Unconfirmed = from .GetUnconfirmed ()
a .Hash = from .GetHash ()
a .DeviceModel = from .GetDeviceModel ()
a .Platform = from .GetPlatform ()
a .SystemVersion = from .GetSystemVersion ()
a .APIID = from .GetAPIID ()
a .AppName = from .GetAppName ()
a .AppVersion = from .GetAppVersion ()
a .DateCreated = from .GetDateCreated ()
a .DateActive = from .GetDateActive ()
a .IP = from .GetIP ()
a .Country = from .GetCountry ()
a .Region = from .GetRegion ()
}
func (*Authorization ) TypeID () uint32 {
return AuthorizationTypeID
}
func (*Authorization ) TypeName () string {
return "authorization"
}
func (a *Authorization ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "authorization" ,
ID : AuthorizationTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Current" ,
SchemaName : "current" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "OfficialApp" ,
SchemaName : "official_app" ,
Null : !a .Flags .Has (1 ),
},
{
Name : "PasswordPending" ,
SchemaName : "password_pending" ,
Null : !a .Flags .Has (2 ),
},
{
Name : "EncryptedRequestsDisabled" ,
SchemaName : "encrypted_requests_disabled" ,
Null : !a .Flags .Has (3 ),
},
{
Name : "CallRequestsDisabled" ,
SchemaName : "call_requests_disabled" ,
Null : !a .Flags .Has (4 ),
},
{
Name : "Unconfirmed" ,
SchemaName : "unconfirmed" ,
Null : !a .Flags .Has (5 ),
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "DeviceModel" ,
SchemaName : "device_model" ,
},
{
Name : "Platform" ,
SchemaName : "platform" ,
},
{
Name : "SystemVersion" ,
SchemaName : "system_version" ,
},
{
Name : "APIID" ,
SchemaName : "api_id" ,
},
{
Name : "AppName" ,
SchemaName : "app_name" ,
},
{
Name : "AppVersion" ,
SchemaName : "app_version" ,
},
{
Name : "DateCreated" ,
SchemaName : "date_created" ,
},
{
Name : "DateActive" ,
SchemaName : "date_active" ,
},
{
Name : "IP" ,
SchemaName : "ip" ,
},
{
Name : "Country" ,
SchemaName : "country" ,
},
{
Name : "Region" ,
SchemaName : "region" ,
},
}
return typ
}
func (a *Authorization ) SetFlags () {
if !(a .Current == false ) {
a .Flags .Set (0 )
}
if !(a .OfficialApp == false ) {
a .Flags .Set (1 )
}
if !(a .PasswordPending == false ) {
a .Flags .Set (2 )
}
if !(a .EncryptedRequestsDisabled == false ) {
a .Flags .Set (3 )
}
if !(a .CallRequestsDisabled == false ) {
a .Flags .Set (4 )
}
if !(a .Unconfirmed == false ) {
a .Flags .Set (5 )
}
}
func (a *Authorization ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode authorization#ad01d61d as nil" )
}
b .PutID (AuthorizationTypeID )
return a .EncodeBare (b )
}
func (a *Authorization ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode authorization#ad01d61d as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode authorization#ad01d61d: field flags: %w" , err )
}
b .PutLong (a .Hash )
b .PutString (a .DeviceModel )
b .PutString (a .Platform )
b .PutString (a .SystemVersion )
b .PutInt (a .APIID )
b .PutString (a .AppName )
b .PutString (a .AppVersion )
b .PutInt (a .DateCreated )
b .PutInt (a .DateActive )
b .PutString (a .IP )
b .PutString (a .Country )
b .PutString (a .Region )
return nil
}
func (a *Authorization ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode authorization#ad01d61d to nil" )
}
if err := b .ConsumeID (AuthorizationTypeID ); err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: %w" , err )
}
return a .DecodeBare (b )
}
func (a *Authorization ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode authorization#ad01d61d to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field flags: %w" , err )
}
}
a .Current = a .Flags .Has (0 )
a .OfficialApp = a .Flags .Has (1 )
a .PasswordPending = a .Flags .Has (2 )
a .EncryptedRequestsDisabled = a .Flags .Has (3 )
a .CallRequestsDisabled = a .Flags .Has (4 )
a .Unconfirmed = a .Flags .Has (5 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field hash: %w" , err )
}
a .Hash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field device_model: %w" , err )
}
a .DeviceModel = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field platform: %w" , err )
}
a .Platform = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field system_version: %w" , err )
}
a .SystemVersion = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field api_id: %w" , err )
}
a .APIID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field app_name: %w" , err )
}
a .AppName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field app_version: %w" , err )
}
a .AppVersion = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field date_created: %w" , err )
}
a .DateCreated = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field date_active: %w" , err )
}
a .DateActive = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field ip: %w" , err )
}
a .IP = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field country: %w" , err )
}
a .Country = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode authorization#ad01d61d: field region: %w" , err )
}
a .Region = value
}
return nil
}
func (a *Authorization ) SetCurrent (value bool ) {
if value {
a .Flags .Set (0 )
a .Current = true
} else {
a .Flags .Unset (0 )
a .Current = false
}
}
func (a *Authorization ) GetCurrent () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (0 )
}
func (a *Authorization ) SetOfficialApp (value bool ) {
if value {
a .Flags .Set (1 )
a .OfficialApp = true
} else {
a .Flags .Unset (1 )
a .OfficialApp = false
}
}
func (a *Authorization ) GetOfficialApp () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (1 )
}
func (a *Authorization ) SetPasswordPending (value bool ) {
if value {
a .Flags .Set (2 )
a .PasswordPending = true
} else {
a .Flags .Unset (2 )
a .PasswordPending = false
}
}
func (a *Authorization ) GetPasswordPending () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (2 )
}
func (a *Authorization ) SetEncryptedRequestsDisabled (value bool ) {
if value {
a .Flags .Set (3 )
a .EncryptedRequestsDisabled = true
} else {
a .Flags .Unset (3 )
a .EncryptedRequestsDisabled = false
}
}
func (a *Authorization ) GetEncryptedRequestsDisabled () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (3 )
}
func (a *Authorization ) SetCallRequestsDisabled (value bool ) {
if value {
a .Flags .Set (4 )
a .CallRequestsDisabled = true
} else {
a .Flags .Unset (4 )
a .CallRequestsDisabled = false
}
}
func (a *Authorization ) GetCallRequestsDisabled () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (4 )
}
func (a *Authorization ) SetUnconfirmed (value bool ) {
if value {
a .Flags .Set (5 )
a .Unconfirmed = true
} else {
a .Flags .Unset (5 )
a .Unconfirmed = false
}
}
func (a *Authorization ) GetUnconfirmed () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (5 )
}
func (a *Authorization ) GetHash () (value int64 ) {
if a == nil {
return
}
return a .Hash
}
func (a *Authorization ) GetDeviceModel () (value string ) {
if a == nil {
return
}
return a .DeviceModel
}
func (a *Authorization ) GetPlatform () (value string ) {
if a == nil {
return
}
return a .Platform
}
func (a *Authorization ) GetSystemVersion () (value string ) {
if a == nil {
return
}
return a .SystemVersion
}
func (a *Authorization ) GetAPIID () (value int ) {
if a == nil {
return
}
return a .APIID
}
func (a *Authorization ) GetAppName () (value string ) {
if a == nil {
return
}
return a .AppName
}
func (a *Authorization ) GetAppVersion () (value string ) {
if a == nil {
return
}
return a .AppVersion
}
func (a *Authorization ) GetDateCreated () (value int ) {
if a == nil {
return
}
return a .DateCreated
}
func (a *Authorization ) GetDateActive () (value int ) {
if a == nil {
return
}
return a .DateActive
}
func (a *Authorization ) GetIP () (value string ) {
if a == nil {
return
}
return a .IP
}
func (a *Authorization ) GetCountry () (value string ) {
if a == nil {
return
}
return a .Country
}
func (a *Authorization ) GetRegion () (value string ) {
if a == nil {
return
}
return a .Region
}
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 .