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 AuthRecoverPasswordRequest struct {
Flags bin .Fields
Code string
NewSettings AccountPasswordInputSettings
}
const AuthRecoverPasswordRequestTypeID = 0x37096c70
var (
_ bin .Encoder = &AuthRecoverPasswordRequest {}
_ bin .Decoder = &AuthRecoverPasswordRequest {}
_ bin .BareEncoder = &AuthRecoverPasswordRequest {}
_ bin .BareDecoder = &AuthRecoverPasswordRequest {}
)
func (r *AuthRecoverPasswordRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .Code == "" ) {
return false
}
if !(r .NewSettings .Zero ()) {
return false
}
return true
}
func (r *AuthRecoverPasswordRequest ) String () string {
if r == nil {
return "AuthRecoverPasswordRequest(nil)"
}
type Alias AuthRecoverPasswordRequest
return fmt .Sprintf ("AuthRecoverPasswordRequest%+v" , Alias (*r ))
}
func (r *AuthRecoverPasswordRequest ) FillFrom (from interface {
GetCode () (value string )
GetNewSettings () (value AccountPasswordInputSettings , ok bool )
}) {
r .Code = from .GetCode ()
if val , ok := from .GetNewSettings (); ok {
r .NewSettings = val
}
}
func (*AuthRecoverPasswordRequest ) TypeID () uint32 {
return AuthRecoverPasswordRequestTypeID
}
func (*AuthRecoverPasswordRequest ) TypeName () string {
return "auth.recoverPassword"
}
func (r *AuthRecoverPasswordRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.recoverPassword" ,
ID : AuthRecoverPasswordRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Code" ,
SchemaName : "code" ,
},
{
Name : "NewSettings" ,
SchemaName : "new_settings" ,
Null : !r .Flags .Has (0 ),
},
}
return typ
}
func (r *AuthRecoverPasswordRequest ) SetFlags () {
if !(r .NewSettings .Zero ()) {
r .Flags .Set (0 )
}
}
func (r *AuthRecoverPasswordRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode auth.recoverPassword#37096c70 as nil" )
}
b .PutID (AuthRecoverPasswordRequestTypeID )
return r .EncodeBare (b )
}
func (r *AuthRecoverPasswordRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode auth.recoverPassword#37096c70 as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.recoverPassword#37096c70: field flags: %w" , err )
}
b .PutString (r .Code )
if r .Flags .Has (0 ) {
if err := r .NewSettings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.recoverPassword#37096c70: field new_settings: %w" , err )
}
}
return nil
}
func (r *AuthRecoverPasswordRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode auth.recoverPassword#37096c70 to nil" )
}
if err := b .ConsumeID (AuthRecoverPasswordRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.recoverPassword#37096c70: %w" , err )
}
return r .DecodeBare (b )
}
func (r *AuthRecoverPasswordRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode auth.recoverPassword#37096c70 to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode auth.recoverPassword#37096c70: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.recoverPassword#37096c70: field code: %w" , err )
}
r .Code = value
}
if r .Flags .Has (0 ) {
if err := r .NewSettings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode auth.recoverPassword#37096c70: field new_settings: %w" , err )
}
}
return nil
}
func (r *AuthRecoverPasswordRequest ) GetCode () (value string ) {
if r == nil {
return
}
return r .Code
}
func (r *AuthRecoverPasswordRequest ) SetNewSettings (value AccountPasswordInputSettings ) {
r .Flags .Set (0 )
r .NewSettings = value
}
func (r *AuthRecoverPasswordRequest ) GetNewSettings () (value AccountPasswordInputSettings , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (0 ) {
return value , false
}
return r .NewSettings , true
}
func (c *Client ) AuthRecoverPassword (ctx context .Context , request *AuthRecoverPasswordRequest ) (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 .