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 AuthImportWebTokenAuthorizationRequest struct {
APIID int
APIHash string
WebAuthToken string
}
const AuthImportWebTokenAuthorizationRequestTypeID = 0x2db873a9
var (
_ bin .Encoder = &AuthImportWebTokenAuthorizationRequest {}
_ bin .Decoder = &AuthImportWebTokenAuthorizationRequest {}
_ bin .BareEncoder = &AuthImportWebTokenAuthorizationRequest {}
_ bin .BareDecoder = &AuthImportWebTokenAuthorizationRequest {}
)
func (i *AuthImportWebTokenAuthorizationRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .APIID == 0 ) {
return false
}
if !(i .APIHash == "" ) {
return false
}
if !(i .WebAuthToken == "" ) {
return false
}
return true
}
func (i *AuthImportWebTokenAuthorizationRequest ) String () string {
if i == nil {
return "AuthImportWebTokenAuthorizationRequest(nil)"
}
type Alias AuthImportWebTokenAuthorizationRequest
return fmt .Sprintf ("AuthImportWebTokenAuthorizationRequest%+v" , Alias (*i ))
}
func (i *AuthImportWebTokenAuthorizationRequest ) FillFrom (from interface {
GetAPIID () (value int )
GetAPIHash () (value string )
GetWebAuthToken () (value string )
}) {
i .APIID = from .GetAPIID ()
i .APIHash = from .GetAPIHash ()
i .WebAuthToken = from .GetWebAuthToken ()
}
func (*AuthImportWebTokenAuthorizationRequest ) TypeID () uint32 {
return AuthImportWebTokenAuthorizationRequestTypeID
}
func (*AuthImportWebTokenAuthorizationRequest ) TypeName () string {
return "auth.importWebTokenAuthorization"
}
func (i *AuthImportWebTokenAuthorizationRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.importWebTokenAuthorization" ,
ID : AuthImportWebTokenAuthorizationRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "APIID" ,
SchemaName : "api_id" ,
},
{
Name : "APIHash" ,
SchemaName : "api_hash" ,
},
{
Name : "WebAuthToken" ,
SchemaName : "web_auth_token" ,
},
}
return typ
}
func (i *AuthImportWebTokenAuthorizationRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode auth.importWebTokenAuthorization#2db873a9 as nil" )
}
b .PutID (AuthImportWebTokenAuthorizationRequestTypeID )
return i .EncodeBare (b )
}
func (i *AuthImportWebTokenAuthorizationRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode auth.importWebTokenAuthorization#2db873a9 as nil" )
}
b .PutInt (i .APIID )
b .PutString (i .APIHash )
b .PutString (i .WebAuthToken )
return nil
}
func (i *AuthImportWebTokenAuthorizationRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode auth.importWebTokenAuthorization#2db873a9 to nil" )
}
if err := b .ConsumeID (AuthImportWebTokenAuthorizationRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.importWebTokenAuthorization#2db873a9: %w" , err )
}
return i .DecodeBare (b )
}
func (i *AuthImportWebTokenAuthorizationRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode auth.importWebTokenAuthorization#2db873a9 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importWebTokenAuthorization#2db873a9: field api_id: %w" , err )
}
i .APIID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importWebTokenAuthorization#2db873a9: field api_hash: %w" , err )
}
i .APIHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.importWebTokenAuthorization#2db873a9: field web_auth_token: %w" , err )
}
i .WebAuthToken = value
}
return nil
}
func (i *AuthImportWebTokenAuthorizationRequest ) GetAPIID () (value int ) {
if i == nil {
return
}
return i .APIID
}
func (i *AuthImportWebTokenAuthorizationRequest ) GetAPIHash () (value string ) {
if i == nil {
return
}
return i .APIHash
}
func (i *AuthImportWebTokenAuthorizationRequest ) GetWebAuthToken () (value string ) {
if i == nil {
return
}
return i .WebAuthToken
}
func (c *Client ) AuthImportWebTokenAuthorization (ctx context .Context , request *AuthImportWebTokenAuthorizationRequest ) (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 .