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 ChatlistsEditExportedInviteRequest struct {
Flags bin .Fields
Chatlist InputChatlistDialogFilter
Slug string
Title string
Peers []InputPeerClass
}
const ChatlistsEditExportedInviteRequestTypeID = 0x653db63d
var (
_ bin .Encoder = &ChatlistsEditExportedInviteRequest {}
_ bin .Decoder = &ChatlistsEditExportedInviteRequest {}
_ bin .BareEncoder = &ChatlistsEditExportedInviteRequest {}
_ bin .BareDecoder = &ChatlistsEditExportedInviteRequest {}
)
func (e *ChatlistsEditExportedInviteRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .Flags .Zero ()) {
return false
}
if !(e .Chatlist .Zero ()) {
return false
}
if !(e .Slug == "" ) {
return false
}
if !(e .Title == "" ) {
return false
}
if !(e .Peers == nil ) {
return false
}
return true
}
func (e *ChatlistsEditExportedInviteRequest ) String () string {
if e == nil {
return "ChatlistsEditExportedInviteRequest(nil)"
}
type Alias ChatlistsEditExportedInviteRequest
return fmt .Sprintf ("ChatlistsEditExportedInviteRequest%+v" , Alias (*e ))
}
func (e *ChatlistsEditExportedInviteRequest ) FillFrom (from interface {
GetChatlist () (value InputChatlistDialogFilter )
GetSlug () (value string )
GetTitle () (value string , ok bool )
GetPeers () (value []InputPeerClass , ok bool )
}) {
e .Chatlist = from .GetChatlist ()
e .Slug = from .GetSlug ()
if val , ok := from .GetTitle (); ok {
e .Title = val
}
if val , ok := from .GetPeers (); ok {
e .Peers = val
}
}
func (*ChatlistsEditExportedInviteRequest ) TypeID () uint32 {
return ChatlistsEditExportedInviteRequestTypeID
}
func (*ChatlistsEditExportedInviteRequest ) TypeName () string {
return "chatlists.editExportedInvite"
}
func (e *ChatlistsEditExportedInviteRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatlists.editExportedInvite" ,
ID : ChatlistsEditExportedInviteRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Chatlist" ,
SchemaName : "chatlist" ,
},
{
Name : "Slug" ,
SchemaName : "slug" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !e .Flags .Has (1 ),
},
{
Name : "Peers" ,
SchemaName : "peers" ,
Null : !e .Flags .Has (2 ),
},
}
return typ
}
func (e *ChatlistsEditExportedInviteRequest ) SetFlags () {
if !(e .Title == "" ) {
e .Flags .Set (1 )
}
if !(e .Peers == nil ) {
e .Flags .Set (2 )
}
}
func (e *ChatlistsEditExportedInviteRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode chatlists.editExportedInvite#653db63d as nil" )
}
b .PutID (ChatlistsEditExportedInviteRequestTypeID )
return e .EncodeBare (b )
}
func (e *ChatlistsEditExportedInviteRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode chatlists.editExportedInvite#653db63d as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatlists.editExportedInvite#653db63d: field flags: %w" , err )
}
if err := e .Chatlist .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatlists.editExportedInvite#653db63d: field chatlist: %w" , err )
}
b .PutString (e .Slug )
if e .Flags .Has (1 ) {
b .PutString (e .Title )
}
if e .Flags .Has (2 ) {
b .PutVectorHeader (len (e .Peers ))
for idx , v := range e .Peers {
if v == nil {
return fmt .Errorf ("unable to encode chatlists.editExportedInvite#653db63d: field peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatlists.editExportedInvite#653db63d: field peers element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (e *ChatlistsEditExportedInviteRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode chatlists.editExportedInvite#653db63d to nil" )
}
if err := b .ConsumeID (ChatlistsEditExportedInviteRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: %w" , err )
}
return e .DecodeBare (b )
}
func (e *ChatlistsEditExportedInviteRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode chatlists.editExportedInvite#653db63d to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: field flags: %w" , err )
}
}
{
if err := e .Chatlist .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: field chatlist: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: field slug: %w" , err )
}
e .Slug = value
}
if e .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: field title: %w" , err )
}
e .Title = value
}
if e .Flags .Has (2 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: field peers: %w" , err )
}
if headerLen > 0 {
e .Peers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode chatlists.editExportedInvite#653db63d: field peers: %w" , err )
}
e .Peers = append (e .Peers , value )
}
}
return nil
}
func (e *ChatlistsEditExportedInviteRequest ) GetChatlist () (value InputChatlistDialogFilter ) {
if e == nil {
return
}
return e .Chatlist
}
func (e *ChatlistsEditExportedInviteRequest ) GetSlug () (value string ) {
if e == nil {
return
}
return e .Slug
}
func (e *ChatlistsEditExportedInviteRequest ) SetTitle (value string ) {
e .Flags .Set (1 )
e .Title = value
}
func (e *ChatlistsEditExportedInviteRequest ) GetTitle () (value string , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (1 ) {
return value , false
}
return e .Title , true
}
func (e *ChatlistsEditExportedInviteRequest ) SetPeers (value []InputPeerClass ) {
e .Flags .Set (2 )
e .Peers = value
}
func (e *ChatlistsEditExportedInviteRequest ) GetPeers () (value []InputPeerClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (2 ) {
return value , false
}
return e .Peers , true
}
func (e *ChatlistsEditExportedInviteRequest ) MapPeers () (value InputPeerClassArray , ok bool ) {
if !e .Flags .Has (2 ) {
return value , false
}
return InputPeerClassArray (e .Peers ), true
}
func (c *Client ) ChatlistsEditExportedInvite (ctx context .Context , request *ChatlistsEditExportedInviteRequest ) (*ExportedChatlistInvite , error ) {
var result ExportedChatlistInvite
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .