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 AccountCreateThemeRequest struct {
Flags bin .Fields
Slug string
Title string
Document InputDocumentClass
Settings []InputThemeSettings
}
const AccountCreateThemeRequestTypeID = 0x652e4400
var (
_ bin .Encoder = &AccountCreateThemeRequest {}
_ bin .Decoder = &AccountCreateThemeRequest {}
_ bin .BareEncoder = &AccountCreateThemeRequest {}
_ bin .BareDecoder = &AccountCreateThemeRequest {}
)
func (c *AccountCreateThemeRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Slug == "" ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .Document == nil ) {
return false
}
if !(c .Settings == nil ) {
return false
}
return true
}
func (c *AccountCreateThemeRequest ) String () string {
if c == nil {
return "AccountCreateThemeRequest(nil)"
}
type Alias AccountCreateThemeRequest
return fmt .Sprintf ("AccountCreateThemeRequest%+v" , Alias (*c ))
}
func (c *AccountCreateThemeRequest ) FillFrom (from interface {
GetSlug () (value string )
GetTitle () (value string )
GetDocument () (value InputDocumentClass , ok bool )
GetSettings () (value []InputThemeSettings , ok bool )
}) {
c .Slug = from .GetSlug ()
c .Title = from .GetTitle ()
if val , ok := from .GetDocument (); ok {
c .Document = val
}
if val , ok := from .GetSettings (); ok {
c .Settings = val
}
}
func (*AccountCreateThemeRequest ) TypeID () uint32 {
return AccountCreateThemeRequestTypeID
}
func (*AccountCreateThemeRequest ) TypeName () string {
return "account.createTheme"
}
func (c *AccountCreateThemeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.createTheme" ,
ID : AccountCreateThemeRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Slug" ,
SchemaName : "slug" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Document" ,
SchemaName : "document" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Settings" ,
SchemaName : "settings" ,
Null : !c .Flags .Has (3 ),
},
}
return typ
}
func (c *AccountCreateThemeRequest ) SetFlags () {
if !(c .Document == nil ) {
c .Flags .Set (2 )
}
if !(c .Settings == nil ) {
c .Flags .Set (3 )
}
}
func (c *AccountCreateThemeRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.createTheme#652e4400 as nil" )
}
b .PutID (AccountCreateThemeRequestTypeID )
return c .EncodeBare (b )
}
func (c *AccountCreateThemeRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.createTheme#652e4400 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.createTheme#652e4400: field flags: %w" , err )
}
b .PutString (c .Slug )
b .PutString (c .Title )
if c .Flags .Has (2 ) {
if c .Document == nil {
return fmt .Errorf ("unable to encode account.createTheme#652e4400: field document is nil" )
}
if err := c .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.createTheme#652e4400: field document: %w" , err )
}
}
if c .Flags .Has (3 ) {
b .PutVectorHeader (len (c .Settings ))
for idx , v := range c .Settings {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.createTheme#652e4400: field settings element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (c *AccountCreateThemeRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.createTheme#652e4400 to nil" )
}
if err := b .ConsumeID (AccountCreateThemeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: %w" , err )
}
return c .DecodeBare (b )
}
func (c *AccountCreateThemeRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.createTheme#652e4400 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: field slug: %w" , err )
}
c .Slug = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (2 ) {
value , err := DecodeInputDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: field document: %w" , err )
}
c .Document = value
}
if c .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: field settings: %w" , err )
}
if headerLen > 0 {
c .Settings = make ([]InputThemeSettings , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value InputThemeSettings
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.createTheme#652e4400: field settings: %w" , err )
}
c .Settings = append (c .Settings , value )
}
}
return nil
}
func (c *AccountCreateThemeRequest ) GetSlug () (value string ) {
if c == nil {
return
}
return c .Slug
}
func (c *AccountCreateThemeRequest ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *AccountCreateThemeRequest ) SetDocument (value InputDocumentClass ) {
c .Flags .Set (2 )
c .Document = value
}
func (c *AccountCreateThemeRequest ) GetDocument () (value InputDocumentClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .Document , true
}
func (c *AccountCreateThemeRequest ) SetSettings (value []InputThemeSettings ) {
c .Flags .Set (3 )
c .Settings = value
}
func (c *AccountCreateThemeRequest ) GetSettings () (value []InputThemeSettings , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (3 ) {
return value , false
}
return c .Settings , true
}
func (c *AccountCreateThemeRequest ) GetDocumentAsNotEmpty () (*InputDocument , bool ) {
if value , ok := c .GetDocument (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (c *Client ) AccountCreateTheme (ctx context .Context , request *AccountCreateThemeRequest ) (*Theme , error ) {
var result Theme
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 .