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 AuthSendCodeRequest struct {
PhoneNumber string
APIID int
APIHash string
Settings CodeSettings
}
const AuthSendCodeRequestTypeID = 0xa677244f
var (
_ bin .Encoder = &AuthSendCodeRequest {}
_ bin .Decoder = &AuthSendCodeRequest {}
_ bin .BareEncoder = &AuthSendCodeRequest {}
_ bin .BareDecoder = &AuthSendCodeRequest {}
)
func (s *AuthSendCodeRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .PhoneNumber == "" ) {
return false
}
if !(s .APIID == 0 ) {
return false
}
if !(s .APIHash == "" ) {
return false
}
if !(s .Settings .Zero ()) {
return false
}
return true
}
func (s *AuthSendCodeRequest ) String () string {
if s == nil {
return "AuthSendCodeRequest(nil)"
}
type Alias AuthSendCodeRequest
return fmt .Sprintf ("AuthSendCodeRequest%+v" , Alias (*s ))
}
func (s *AuthSendCodeRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetAPIID () (value int )
GetAPIHash () (value string )
GetSettings () (value CodeSettings )
}) {
s .PhoneNumber = from .GetPhoneNumber ()
s .APIID = from .GetAPIID ()
s .APIHash = from .GetAPIHash ()
s .Settings = from .GetSettings ()
}
func (*AuthSendCodeRequest ) TypeID () uint32 {
return AuthSendCodeRequestTypeID
}
func (*AuthSendCodeRequest ) TypeName () string {
return "auth.sendCode"
}
func (s *AuthSendCodeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.sendCode" ,
ID : AuthSendCodeRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "APIID" ,
SchemaName : "api_id" ,
},
{
Name : "APIHash" ,
SchemaName : "api_hash" ,
},
{
Name : "Settings" ,
SchemaName : "settings" ,
},
}
return typ
}
func (s *AuthSendCodeRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.sendCode#a677244f as nil" )
}
b .PutID (AuthSendCodeRequestTypeID )
return s .EncodeBare (b )
}
func (s *AuthSendCodeRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.sendCode#a677244f as nil" )
}
b .PutString (s .PhoneNumber )
b .PutInt (s .APIID )
b .PutString (s .APIHash )
if err := s .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.sendCode#a677244f: field settings: %w" , err )
}
return nil
}
func (s *AuthSendCodeRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.sendCode#a677244f to nil" )
}
if err := b .ConsumeID (AuthSendCodeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.sendCode#a677244f: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AuthSendCodeRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.sendCode#a677244f to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.sendCode#a677244f: field phone_number: %w" , err )
}
s .PhoneNumber = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.sendCode#a677244f: field api_id: %w" , err )
}
s .APIID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.sendCode#a677244f: field api_hash: %w" , err )
}
s .APIHash = value
}
{
if err := s .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode auth.sendCode#a677244f: field settings: %w" , err )
}
}
return nil
}
func (s *AuthSendCodeRequest ) GetPhoneNumber () (value string ) {
if s == nil {
return
}
return s .PhoneNumber
}
func (s *AuthSendCodeRequest ) GetAPIID () (value int ) {
if s == nil {
return
}
return s .APIID
}
func (s *AuthSendCodeRequest ) GetAPIHash () (value string ) {
if s == nil {
return
}
return s .APIHash
}
func (s *AuthSendCodeRequest ) GetSettings () (value CodeSettings ) {
if s == nil {
return
}
return s .Settings
}
func (c *Client ) AuthSendCode (ctx context .Context , request *AuthSendCodeRequest ) (AuthSentCodeClass , error ) {
var result AuthSentCodeBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .SentCode , 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 .