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 AccountDeleteAccountRequest struct {
Flags bin .Fields
Reason string
Password InputCheckPasswordSRPClass
}
const AccountDeleteAccountRequestTypeID = 0xa2c0cf74
var (
_ bin .Encoder = &AccountDeleteAccountRequest {}
_ bin .Decoder = &AccountDeleteAccountRequest {}
_ bin .BareEncoder = &AccountDeleteAccountRequest {}
_ bin .BareDecoder = &AccountDeleteAccountRequest {}
)
func (d *AccountDeleteAccountRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Reason == "" ) {
return false
}
if !(d .Password == nil ) {
return false
}
return true
}
func (d *AccountDeleteAccountRequest ) String () string {
if d == nil {
return "AccountDeleteAccountRequest(nil)"
}
type Alias AccountDeleteAccountRequest
return fmt .Sprintf ("AccountDeleteAccountRequest%+v" , Alias (*d ))
}
func (d *AccountDeleteAccountRequest ) FillFrom (from interface {
GetReason () (value string )
GetPassword () (value InputCheckPasswordSRPClass , ok bool )
}) {
d .Reason = from .GetReason ()
if val , ok := from .GetPassword (); ok {
d .Password = val
}
}
func (*AccountDeleteAccountRequest ) TypeID () uint32 {
return AccountDeleteAccountRequestTypeID
}
func (*AccountDeleteAccountRequest ) TypeName () string {
return "account.deleteAccount"
}
func (d *AccountDeleteAccountRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.deleteAccount" ,
ID : AccountDeleteAccountRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Reason" ,
SchemaName : "reason" ,
},
{
Name : "Password" ,
SchemaName : "password" ,
Null : !d .Flags .Has (0 ),
},
}
return typ
}
func (d *AccountDeleteAccountRequest ) SetFlags () {
if !(d .Password == nil ) {
d .Flags .Set (0 )
}
}
func (d *AccountDeleteAccountRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode account.deleteAccount#a2c0cf74 as nil" )
}
b .PutID (AccountDeleteAccountRequestTypeID )
return d .EncodeBare (b )
}
func (d *AccountDeleteAccountRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode account.deleteAccount#a2c0cf74 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.deleteAccount#a2c0cf74: field flags: %w" , err )
}
b .PutString (d .Reason )
if d .Flags .Has (0 ) {
if d .Password == nil {
return fmt .Errorf ("unable to encode account.deleteAccount#a2c0cf74: field password is nil" )
}
if err := d .Password .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.deleteAccount#a2c0cf74: field password: %w" , err )
}
}
return nil
}
func (d *AccountDeleteAccountRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode account.deleteAccount#a2c0cf74 to nil" )
}
if err := b .ConsumeID (AccountDeleteAccountRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.deleteAccount#a2c0cf74: %w" , err )
}
return d .DecodeBare (b )
}
func (d *AccountDeleteAccountRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode account.deleteAccount#a2c0cf74 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.deleteAccount#a2c0cf74: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.deleteAccount#a2c0cf74: field reason: %w" , err )
}
d .Reason = value
}
if d .Flags .Has (0 ) {
value , err := DecodeInputCheckPasswordSRP (b )
if err != nil {
return fmt .Errorf ("unable to decode account.deleteAccount#a2c0cf74: field password: %w" , err )
}
d .Password = value
}
return nil
}
func (d *AccountDeleteAccountRequest ) GetReason () (value string ) {
if d == nil {
return
}
return d .Reason
}
func (d *AccountDeleteAccountRequest ) SetPassword (value InputCheckPasswordSRPClass ) {
d .Flags .Set (0 )
d .Password = value
}
func (d *AccountDeleteAccountRequest ) GetPassword () (value InputCheckPasswordSRPClass , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (0 ) {
return value , false
}
return d .Password , true
}
func (d *AccountDeleteAccountRequest ) GetPasswordAsNotEmpty () (*InputCheckPasswordSRP , bool ) {
if value , ok := d .GetPassword (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (c *Client ) AccountDeleteAccount (ctx context .Context , request *AccountDeleteAccountRequest ) (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 .