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 WebAuthorization struct {
Hash int64
BotID int64
Domain string
Browser string
Platform string
DateCreated int
DateActive int
IP string
Region string
}
const WebAuthorizationTypeID = 0xa6f8f452
var (
_ bin .Encoder = &WebAuthorization {}
_ bin .Decoder = &WebAuthorization {}
_ bin .BareEncoder = &WebAuthorization {}
_ bin .BareDecoder = &WebAuthorization {}
)
func (w *WebAuthorization ) Zero () bool {
if w == nil {
return true
}
if !(w .Hash == 0 ) {
return false
}
if !(w .BotID == 0 ) {
return false
}
if !(w .Domain == "" ) {
return false
}
if !(w .Browser == "" ) {
return false
}
if !(w .Platform == "" ) {
return false
}
if !(w .DateCreated == 0 ) {
return false
}
if !(w .DateActive == 0 ) {
return false
}
if !(w .IP == "" ) {
return false
}
if !(w .Region == "" ) {
return false
}
return true
}
func (w *WebAuthorization ) String () string {
if w == nil {
return "WebAuthorization(nil)"
}
type Alias WebAuthorization
return fmt .Sprintf ("WebAuthorization%+v" , Alias (*w ))
}
func (w *WebAuthorization ) FillFrom (from interface {
GetHash () (value int64 )
GetBotID () (value int64 )
GetDomain () (value string )
GetBrowser () (value string )
GetPlatform () (value string )
GetDateCreated () (value int )
GetDateActive () (value int )
GetIP () (value string )
GetRegion () (value string )
}) {
w .Hash = from .GetHash ()
w .BotID = from .GetBotID ()
w .Domain = from .GetDomain ()
w .Browser = from .GetBrowser ()
w .Platform = from .GetPlatform ()
w .DateCreated = from .GetDateCreated ()
w .DateActive = from .GetDateActive ()
w .IP = from .GetIP ()
w .Region = from .GetRegion ()
}
func (*WebAuthorization ) TypeID () uint32 {
return WebAuthorizationTypeID
}
func (*WebAuthorization ) TypeName () string {
return "webAuthorization"
}
func (w *WebAuthorization ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webAuthorization" ,
ID : WebAuthorizationTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "Domain" ,
SchemaName : "domain" ,
},
{
Name : "Browser" ,
SchemaName : "browser" ,
},
{
Name : "Platform" ,
SchemaName : "platform" ,
},
{
Name : "DateCreated" ,
SchemaName : "date_created" ,
},
{
Name : "DateActive" ,
SchemaName : "date_active" ,
},
{
Name : "IP" ,
SchemaName : "ip" ,
},
{
Name : "Region" ,
SchemaName : "region" ,
},
}
return typ
}
func (w *WebAuthorization ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webAuthorization#a6f8f452 as nil" )
}
b .PutID (WebAuthorizationTypeID )
return w .EncodeBare (b )
}
func (w *WebAuthorization ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webAuthorization#a6f8f452 as nil" )
}
b .PutLong (w .Hash )
b .PutLong (w .BotID )
b .PutString (w .Domain )
b .PutString (w .Browser )
b .PutString (w .Platform )
b .PutInt (w .DateCreated )
b .PutInt (w .DateActive )
b .PutString (w .IP )
b .PutString (w .Region )
return nil
}
func (w *WebAuthorization ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webAuthorization#a6f8f452 to nil" )
}
if err := b .ConsumeID (WebAuthorizationTypeID ); err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebAuthorization ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webAuthorization#a6f8f452 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field hash: %w" , err )
}
w .Hash = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field bot_id: %w" , err )
}
w .BotID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field domain: %w" , err )
}
w .Domain = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field browser: %w" , err )
}
w .Browser = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field platform: %w" , err )
}
w .Platform = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field date_created: %w" , err )
}
w .DateCreated = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field date_active: %w" , err )
}
w .DateActive = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field ip: %w" , err )
}
w .IP = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webAuthorization#a6f8f452: field region: %w" , err )
}
w .Region = value
}
return nil
}
func (w *WebAuthorization ) GetHash () (value int64 ) {
if w == nil {
return
}
return w .Hash
}
func (w *WebAuthorization ) GetBotID () (value int64 ) {
if w == nil {
return
}
return w .BotID
}
func (w *WebAuthorization ) GetDomain () (value string ) {
if w == nil {
return
}
return w .Domain
}
func (w *WebAuthorization ) GetBrowser () (value string ) {
if w == nil {
return
}
return w .Browser
}
func (w *WebAuthorization ) GetPlatform () (value string ) {
if w == nil {
return
}
return w .Platform
}
func (w *WebAuthorization ) GetDateCreated () (value int ) {
if w == nil {
return
}
return w .DateCreated
}
func (w *WebAuthorization ) GetDateActive () (value int ) {
if w == nil {
return
}
return w .DateActive
}
func (w *WebAuthorization ) GetIP () (value string ) {
if w == nil {
return
}
return w .IP
}
func (w *WebAuthorization ) GetRegion () (value string ) {
if w == nil {
return
}
return w .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 .