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 AuthCancelCodeRequest struct {
PhoneNumber string
PhoneCodeHash string
}
const AuthCancelCodeRequestTypeID = 0x1f040578
var (
_ bin .Encoder = &AuthCancelCodeRequest {}
_ bin .Decoder = &AuthCancelCodeRequest {}
_ bin .BareEncoder = &AuthCancelCodeRequest {}
_ bin .BareDecoder = &AuthCancelCodeRequest {}
)
func (c *AuthCancelCodeRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .PhoneNumber == "" ) {
return false
}
if !(c .PhoneCodeHash == "" ) {
return false
}
return true
}
func (c *AuthCancelCodeRequest ) String () string {
if c == nil {
return "AuthCancelCodeRequest(nil)"
}
type Alias AuthCancelCodeRequest
return fmt .Sprintf ("AuthCancelCodeRequest%+v" , Alias (*c ))
}
func (c *AuthCancelCodeRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
}) {
c .PhoneNumber = from .GetPhoneNumber ()
c .PhoneCodeHash = from .GetPhoneCodeHash ()
}
func (*AuthCancelCodeRequest ) TypeID () uint32 {
return AuthCancelCodeRequestTypeID
}
func (*AuthCancelCodeRequest ) TypeName () string {
return "auth.cancelCode"
}
func (c *AuthCancelCodeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.cancelCode" ,
ID : AuthCancelCodeRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "PhoneCodeHash" ,
SchemaName : "phone_code_hash" ,
},
}
return typ
}
func (c *AuthCancelCodeRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode auth.cancelCode#1f040578 as nil" )
}
b .PutID (AuthCancelCodeRequestTypeID )
return c .EncodeBare (b )
}
func (c *AuthCancelCodeRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode auth.cancelCode#1f040578 as nil" )
}
b .PutString (c .PhoneNumber )
b .PutString (c .PhoneCodeHash )
return nil
}
func (c *AuthCancelCodeRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode auth.cancelCode#1f040578 to nil" )
}
if err := b .ConsumeID (AuthCancelCodeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.cancelCode#1f040578: %w" , err )
}
return c .DecodeBare (b )
}
func (c *AuthCancelCodeRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode auth.cancelCode#1f040578 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.cancelCode#1f040578: field phone_number: %w" , err )
}
c .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.cancelCode#1f040578: field phone_code_hash: %w" , err )
}
c .PhoneCodeHash = value
}
return nil
}
func (c *AuthCancelCodeRequest ) GetPhoneNumber () (value string ) {
if c == nil {
return
}
return c .PhoneNumber
}
func (c *AuthCancelCodeRequest ) GetPhoneCodeHash () (value string ) {
if c == nil {
return
}
return c .PhoneCodeHash
}
func (c *Client ) AuthCancelCode (ctx context .Context , request *AuthCancelCodeRequest ) (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 .