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 AccountAcceptAuthorizationRequest struct {
BotID int64
Scope string
PublicKey string
ValueHashes []SecureValueHash
Credentials SecureCredentialsEncrypted
}
const AccountAcceptAuthorizationRequestTypeID = 0xf3ed4c73
var (
_ bin .Encoder = &AccountAcceptAuthorizationRequest {}
_ bin .Decoder = &AccountAcceptAuthorizationRequest {}
_ bin .BareEncoder = &AccountAcceptAuthorizationRequest {}
_ bin .BareDecoder = &AccountAcceptAuthorizationRequest {}
)
func (a *AccountAcceptAuthorizationRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .BotID == 0 ) {
return false
}
if !(a .Scope == "" ) {
return false
}
if !(a .PublicKey == "" ) {
return false
}
if !(a .ValueHashes == nil ) {
return false
}
if !(a .Credentials .Zero ()) {
return false
}
return true
}
func (a *AccountAcceptAuthorizationRequest ) String () string {
if a == nil {
return "AccountAcceptAuthorizationRequest(nil)"
}
type Alias AccountAcceptAuthorizationRequest
return fmt .Sprintf ("AccountAcceptAuthorizationRequest%+v" , Alias (*a ))
}
func (a *AccountAcceptAuthorizationRequest ) FillFrom (from interface {
GetBotID () (value int64 )
GetScope () (value string )
GetPublicKey () (value string )
GetValueHashes () (value []SecureValueHash )
GetCredentials () (value SecureCredentialsEncrypted )
}) {
a .BotID = from .GetBotID ()
a .Scope = from .GetScope ()
a .PublicKey = from .GetPublicKey ()
a .ValueHashes = from .GetValueHashes ()
a .Credentials = from .GetCredentials ()
}
func (*AccountAcceptAuthorizationRequest ) TypeID () uint32 {
return AccountAcceptAuthorizationRequestTypeID
}
func (*AccountAcceptAuthorizationRequest ) TypeName () string {
return "account.acceptAuthorization"
}
func (a *AccountAcceptAuthorizationRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.acceptAuthorization" ,
ID : AccountAcceptAuthorizationRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "Scope" ,
SchemaName : "scope" ,
},
{
Name : "PublicKey" ,
SchemaName : "public_key" ,
},
{
Name : "ValueHashes" ,
SchemaName : "value_hashes" ,
},
{
Name : "Credentials" ,
SchemaName : "credentials" ,
},
}
return typ
}
func (a *AccountAcceptAuthorizationRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode account.acceptAuthorization#f3ed4c73 as nil" )
}
b .PutID (AccountAcceptAuthorizationRequestTypeID )
return a .EncodeBare (b )
}
func (a *AccountAcceptAuthorizationRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode account.acceptAuthorization#f3ed4c73 as nil" )
}
b .PutLong (a .BotID )
b .PutString (a .Scope )
b .PutString (a .PublicKey )
b .PutVectorHeader (len (a .ValueHashes ))
for idx , v := range a .ValueHashes {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.acceptAuthorization#f3ed4c73: field value_hashes element with index %d: %w" , idx , err )
}
}
if err := a .Credentials .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.acceptAuthorization#f3ed4c73: field credentials: %w" , err )
}
return nil
}
func (a *AccountAcceptAuthorizationRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode account.acceptAuthorization#f3ed4c73 to nil" )
}
if err := b .ConsumeID (AccountAcceptAuthorizationRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AccountAcceptAuthorizationRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode account.acceptAuthorization#f3ed4c73 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: field bot_id: %w" , err )
}
a .BotID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: field scope: %w" , err )
}
a .Scope = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: field public_key: %w" , err )
}
a .PublicKey = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: field value_hashes: %w" , err )
}
if headerLen > 0 {
a .ValueHashes = make ([]SecureValueHash , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value SecureValueHash
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: field value_hashes: %w" , err )
}
a .ValueHashes = append (a .ValueHashes , value )
}
}
{
if err := a .Credentials .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.acceptAuthorization#f3ed4c73: field credentials: %w" , err )
}
}
return nil
}
func (a *AccountAcceptAuthorizationRequest ) GetBotID () (value int64 ) {
if a == nil {
return
}
return a .BotID
}
func (a *AccountAcceptAuthorizationRequest ) GetScope () (value string ) {
if a == nil {
return
}
return a .Scope
}
func (a *AccountAcceptAuthorizationRequest ) GetPublicKey () (value string ) {
if a == nil {
return
}
return a .PublicKey
}
func (a *AccountAcceptAuthorizationRequest ) GetValueHashes () (value []SecureValueHash ) {
if a == nil {
return
}
return a .ValueHashes
}
func (a *AccountAcceptAuthorizationRequest ) GetCredentials () (value SecureCredentialsEncrypted ) {
if a == nil {
return
}
return a .Credentials
}
func (c *Client ) AccountAcceptAuthorization (ctx context .Context , request *AccountAcceptAuthorizationRequest ) (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 .