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 AuthImportBotAuthorizationRequest struct {
Flags int
APIID int
APIHash string
BotAuthToken string
}
const AuthImportBotAuthorizationRequestTypeID = 0x67a3ff2c
var (
_ bin .Encoder = &AuthImportBotAuthorizationRequest {}
_ bin .Decoder = &AuthImportBotAuthorizationRequest {}
_ bin .BareEncoder = &AuthImportBotAuthorizationRequest {}
_ bin .BareDecoder = &AuthImportBotAuthorizationRequest {}
)
func (i *AuthImportBotAuthorizationRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags == 0 ) {
return false
}
if !(i .APIID == 0 ) {
return false
}
if !(i .APIHash == "" ) {
return false
}
if !(i .BotAuthToken == "" ) {
return false
}
return true
}
func (i *AuthImportBotAuthorizationRequest ) String () string {
if i == nil {
return "AuthImportBotAuthorizationRequest(nil)"
}
type Alias AuthImportBotAuthorizationRequest
return fmt .Sprintf ("AuthImportBotAuthorizationRequest%+v" , Alias (*i ))
}
func (i *AuthImportBotAuthorizationRequest ) FillFrom (from interface {
GetFlags () (value int )
GetAPIID () (value int )
GetAPIHash () (value string )
GetBotAuthToken () (value string )
}) {
i .Flags = from .GetFlags ()
i .APIID = from .GetAPIID ()
i .APIHash = from .GetAPIHash ()
i .BotAuthToken = from .GetBotAuthToken ()
}
func (*AuthImportBotAuthorizationRequest ) TypeID () uint32 {
return AuthImportBotAuthorizationRequestTypeID
}
func (*AuthImportBotAuthorizationRequest ) TypeName () string {
return "auth.importBotAuthorization"
}
func (i *AuthImportBotAuthorizationRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.importBotAuthorization" ,
ID : AuthImportBotAuthorizationRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Flags" ,
SchemaName : "flags" ,
},
{
Name : "APIID" ,
SchemaName : "api_id" ,
},
{
Name : "APIHash" ,
SchemaName : "api_hash" ,
},
{
Name : "BotAuthToken" ,
SchemaName : "bot_auth_token" ,
},
}
return typ
}
func (i *AuthImportBotAuthorizationRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode auth.importBotAuthorization#67a3ff2c as nil" )
}
b .PutID (AuthImportBotAuthorizationRequestTypeID )
return i .EncodeBare (b )
}
func (i *AuthImportBotAuthorizationRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode auth.importBotAuthorization#67a3ff2c as nil" )
}
b .PutInt (i .Flags )
b .PutInt (i .APIID )
b .PutString (i .APIHash )
b .PutString (i .BotAuthToken )
return nil
}
func (i *AuthImportBotAuthorizationRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode auth.importBotAuthorization#67a3ff2c to nil" )
}
if err := b .ConsumeID (AuthImportBotAuthorizationRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.importBotAuthorization#67a3ff2c: %w" , err )
}
return i .DecodeBare (b )
}
func (i *AuthImportBotAuthorizationRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode auth.importBotAuthorization#67a3ff2c to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importBotAuthorization#67a3ff2c: field flags: %w" , err )
}
i .Flags = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importBotAuthorization#67a3ff2c: field api_id: %w" , err )
}
i .APIID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importBotAuthorization#67a3ff2c: field api_hash: %w" , err )
}
i .APIHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importBotAuthorization#67a3ff2c: field bot_auth_token: %w" , err )
}
i .BotAuthToken = value
}
return nil
}
func (i *AuthImportBotAuthorizationRequest ) GetFlags () (value int ) {
if i == nil {
return
}
return i .Flags
}
func (i *AuthImportBotAuthorizationRequest ) GetAPIID () (value int ) {
if i == nil {
return
}
return i .APIID
}
func (i *AuthImportBotAuthorizationRequest ) GetAPIHash () (value string ) {
if i == nil {
return
}
return i .APIHash
}
func (i *AuthImportBotAuthorizationRequest ) GetBotAuthToken () (value string ) {
if i == nil {
return
}
return i .BotAuthToken
}
func (c *Client ) AuthImportBotAuthorization (ctx context .Context , request *AuthImportBotAuthorizationRequest ) (AuthAuthorizationClass , error ) {
var result AuthAuthorizationBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Authorization , 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 .