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