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 AccountChangeAuthorizationSettingsRequest struct {
Flags bin .Fields
Confirmed bool
Hash int64
EncryptedRequestsDisabled bool
CallRequestsDisabled bool
}
const AccountChangeAuthorizationSettingsRequestTypeID = 0x40f48462
var (
_ bin .Encoder = &AccountChangeAuthorizationSettingsRequest {}
_ bin .Decoder = &AccountChangeAuthorizationSettingsRequest {}
_ bin .BareEncoder = &AccountChangeAuthorizationSettingsRequest {}
_ bin .BareDecoder = &AccountChangeAuthorizationSettingsRequest {}
)
func (c *AccountChangeAuthorizationSettingsRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Confirmed == false ) {
return false
}
if !(c .Hash == 0 ) {
return false
}
if !(c .EncryptedRequestsDisabled == false ) {
return false
}
if !(c .CallRequestsDisabled == false ) {
return false
}
return true
}
func (c *AccountChangeAuthorizationSettingsRequest ) String () string {
if c == nil {
return "AccountChangeAuthorizationSettingsRequest(nil)"
}
type Alias AccountChangeAuthorizationSettingsRequest
return fmt .Sprintf ("AccountChangeAuthorizationSettingsRequest%+v" , Alias (*c ))
}
func (c *AccountChangeAuthorizationSettingsRequest ) FillFrom (from interface {
GetConfirmed () (value bool )
GetHash () (value int64 )
GetEncryptedRequestsDisabled () (value bool , ok bool )
GetCallRequestsDisabled () (value bool , ok bool )
}) {
c .Confirmed = from .GetConfirmed ()
c .Hash = from .GetHash ()
if val , ok := from .GetEncryptedRequestsDisabled (); ok {
c .EncryptedRequestsDisabled = val
}
if val , ok := from .GetCallRequestsDisabled (); ok {
c .CallRequestsDisabled = val
}
}
func (*AccountChangeAuthorizationSettingsRequest ) TypeID () uint32 {
return AccountChangeAuthorizationSettingsRequestTypeID
}
func (*AccountChangeAuthorizationSettingsRequest ) TypeName () string {
return "account.changeAuthorizationSettings"
}
func (c *AccountChangeAuthorizationSettingsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.changeAuthorizationSettings" ,
ID : AccountChangeAuthorizationSettingsRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Confirmed" ,
SchemaName : "confirmed" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "EncryptedRequestsDisabled" ,
SchemaName : "encrypted_requests_disabled" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "CallRequestsDisabled" ,
SchemaName : "call_requests_disabled" ,
Null : !c .Flags .Has (1 ),
},
}
return typ
}
func (c *AccountChangeAuthorizationSettingsRequest ) SetFlags () {
if !(c .Confirmed == false ) {
c .Flags .Set (3 )
}
if !(c .EncryptedRequestsDisabled == false ) {
c .Flags .Set (0 )
}
if !(c .CallRequestsDisabled == false ) {
c .Flags .Set (1 )
}
}
func (c *AccountChangeAuthorizationSettingsRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.changeAuthorizationSettings#40f48462 as nil" )
}
b .PutID (AccountChangeAuthorizationSettingsRequestTypeID )
return c .EncodeBare (b )
}
func (c *AccountChangeAuthorizationSettingsRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.changeAuthorizationSettings#40f48462 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.changeAuthorizationSettings#40f48462: field flags: %w" , err )
}
b .PutLong (c .Hash )
if c .Flags .Has (0 ) {
b .PutBool (c .EncryptedRequestsDisabled )
}
if c .Flags .Has (1 ) {
b .PutBool (c .CallRequestsDisabled )
}
return nil
}
func (c *AccountChangeAuthorizationSettingsRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.changeAuthorizationSettings#40f48462 to nil" )
}
if err := b .ConsumeID (AccountChangeAuthorizationSettingsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.changeAuthorizationSettings#40f48462: %w" , err )
}
return c .DecodeBare (b )
}
func (c *AccountChangeAuthorizationSettingsRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.changeAuthorizationSettings#40f48462 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.changeAuthorizationSettings#40f48462: field flags: %w" , err )
}
}
c .Confirmed = c .Flags .Has (3 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.changeAuthorizationSettings#40f48462: field hash: %w" , err )
}
c .Hash = value
}
if c .Flags .Has (0 ) {
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode account.changeAuthorizationSettings#40f48462: field encrypted_requests_disabled: %w" , err )
}
c .EncryptedRequestsDisabled = value
}
if c .Flags .Has (1 ) {
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode account.changeAuthorizationSettings#40f48462: field call_requests_disabled: %w" , err )
}
c .CallRequestsDisabled = value
}
return nil
}
func (c *AccountChangeAuthorizationSettingsRequest ) SetConfirmed (value bool ) {
if value {
c .Flags .Set (3 )
c .Confirmed = true
} else {
c .Flags .Unset (3 )
c .Confirmed = false
}
}
func (c *AccountChangeAuthorizationSettingsRequest ) GetConfirmed () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (3 )
}
func (c *AccountChangeAuthorizationSettingsRequest ) GetHash () (value int64 ) {
if c == nil {
return
}
return c .Hash
}
func (c *AccountChangeAuthorizationSettingsRequest ) SetEncryptedRequestsDisabled (value bool ) {
c .Flags .Set (0 )
c .EncryptedRequestsDisabled = value
}
func (c *AccountChangeAuthorizationSettingsRequest ) GetEncryptedRequestsDisabled () (value bool , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .EncryptedRequestsDisabled , true
}
func (c *AccountChangeAuthorizationSettingsRequest ) SetCallRequestsDisabled (value bool ) {
c .Flags .Set (1 )
c .CallRequestsDisabled = value
}
func (c *AccountChangeAuthorizationSettingsRequest ) GetCallRequestsDisabled () (value bool , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .CallRequestsDisabled , true
}
func (c *Client ) AccountChangeAuthorizationSettings (ctx context .Context , request *AccountChangeAuthorizationSettingsRequest ) (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 .