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