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 MessagesRequestURLAuthRequest struct {
Flags bin .Fields
Peer InputPeerClass
MsgID int
ButtonID int
URL string
}
const MessagesRequestURLAuthRequestTypeID = 0x198fb446
var (
_ bin .Encoder = &MessagesRequestURLAuthRequest {}
_ bin .Decoder = &MessagesRequestURLAuthRequest {}
_ bin .BareEncoder = &MessagesRequestURLAuthRequest {}
_ bin .BareDecoder = &MessagesRequestURLAuthRequest {}
)
func (r *MessagesRequestURLAuthRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .Peer == nil ) {
return false
}
if !(r .MsgID == 0 ) {
return false
}
if !(r .ButtonID == 0 ) {
return false
}
if !(r .URL == "" ) {
return false
}
return true
}
func (r *MessagesRequestURLAuthRequest ) String () string {
if r == nil {
return "MessagesRequestURLAuthRequest(nil)"
}
type Alias MessagesRequestURLAuthRequest
return fmt .Sprintf ("MessagesRequestURLAuthRequest%+v" , Alias (*r ))
}
func (r *MessagesRequestURLAuthRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass , ok bool )
GetMsgID () (value int , ok bool )
GetButtonID () (value int , ok bool )
GetURL () (value string , ok bool )
}) {
if val , ok := from .GetPeer (); ok {
r .Peer = val
}
if val , ok := from .GetMsgID (); ok {
r .MsgID = val
}
if val , ok := from .GetButtonID (); ok {
r .ButtonID = val
}
if val , ok := from .GetURL (); ok {
r .URL = val
}
}
func (*MessagesRequestURLAuthRequest ) TypeID () uint32 {
return MessagesRequestURLAuthRequestTypeID
}
func (*MessagesRequestURLAuthRequest ) TypeName () string {
return "messages.requestUrlAuth"
}
func (r *MessagesRequestURLAuthRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.requestUrlAuth" ,
ID : MessagesRequestURLAuthRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "ButtonID" ,
SchemaName : "button_id" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !r .Flags .Has (2 ),
},
}
return typ
}
func (r *MessagesRequestURLAuthRequest ) SetFlags () {
if !(r .Peer == nil ) {
r .Flags .Set (1 )
}
if !(r .MsgID == 0 ) {
r .Flags .Set (1 )
}
if !(r .ButtonID == 0 ) {
r .Flags .Set (1 )
}
if !(r .URL == "" ) {
r .Flags .Set (2 )
}
}
func (r *MessagesRequestURLAuthRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.requestUrlAuth#198fb446 as nil" )
}
b .PutID (MessagesRequestURLAuthRequestTypeID )
return r .EncodeBare (b )
}
func (r *MessagesRequestURLAuthRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.requestUrlAuth#198fb446 as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestUrlAuth#198fb446: field flags: %w" , err )
}
if r .Flags .Has (1 ) {
if r .Peer == nil {
return fmt .Errorf ("unable to encode messages.requestUrlAuth#198fb446: field peer is nil" )
}
if err := r .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestUrlAuth#198fb446: field peer: %w" , err )
}
}
if r .Flags .Has (1 ) {
b .PutInt (r .MsgID )
}
if r .Flags .Has (1 ) {
b .PutInt (r .ButtonID )
}
if r .Flags .Has (2 ) {
b .PutString (r .URL )
}
return nil
}
func (r *MessagesRequestURLAuthRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.requestUrlAuth#198fb446 to nil" )
}
if err := b .ConsumeID (MessagesRequestURLAuthRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.requestUrlAuth#198fb446: %w" , err )
}
return r .DecodeBare (b )
}
func (r *MessagesRequestURLAuthRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.requestUrlAuth#198fb446 to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.requestUrlAuth#198fb446: field flags: %w" , err )
}
}
if r .Flags .Has (1 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.requestUrlAuth#198fb446: field peer: %w" , err )
}
r .Peer = value
}
if r .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestUrlAuth#198fb446: field msg_id: %w" , err )
}
r .MsgID = value
}
if r .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestUrlAuth#198fb446: field button_id: %w" , err )
}
r .ButtonID = value
}
if r .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestUrlAuth#198fb446: field url: %w" , err )
}
r .URL = value
}
return nil
}
func (r *MessagesRequestURLAuthRequest ) SetPeer (value InputPeerClass ) {
r .Flags .Set (1 )
r .Peer = value
}
func (r *MessagesRequestURLAuthRequest ) GetPeer () (value InputPeerClass , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .Peer , true
}
func (r *MessagesRequestURLAuthRequest ) SetMsgID (value int ) {
r .Flags .Set (1 )
r .MsgID = value
}
func (r *MessagesRequestURLAuthRequest ) GetMsgID () (value int , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .MsgID , true
}
func (r *MessagesRequestURLAuthRequest ) SetButtonID (value int ) {
r .Flags .Set (1 )
r .ButtonID = value
}
func (r *MessagesRequestURLAuthRequest ) GetButtonID () (value int , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .ButtonID , true
}
func (r *MessagesRequestURLAuthRequest ) SetURL (value string ) {
r .Flags .Set (2 )
r .URL = value
}
func (r *MessagesRequestURLAuthRequest ) GetURL () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (2 ) {
return value , false
}
return r .URL , true
}
func (c *Client ) MessagesRequestURLAuth (ctx context .Context , request *MessagesRequestURLAuthRequest ) (URLAuthResultClass , error ) {
var result URLAuthResultBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .UrlAuthResult , 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 .