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 AccountInstallThemeRequest struct {
Flags bin .Fields
Dark bool
Theme InputThemeClass
Format string
BaseTheme BaseThemeClass
}
const AccountInstallThemeRequestTypeID = 0xc727bb3b
var (
_ bin .Encoder = &AccountInstallThemeRequest {}
_ bin .Decoder = &AccountInstallThemeRequest {}
_ bin .BareEncoder = &AccountInstallThemeRequest {}
_ bin .BareDecoder = &AccountInstallThemeRequest {}
)
func (i *AccountInstallThemeRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Dark == false ) {
return false
}
if !(i .Theme == nil ) {
return false
}
if !(i .Format == "" ) {
return false
}
if !(i .BaseTheme == nil ) {
return false
}
return true
}
func (i *AccountInstallThemeRequest ) String () string {
if i == nil {
return "AccountInstallThemeRequest(nil)"
}
type Alias AccountInstallThemeRequest
return fmt .Sprintf ("AccountInstallThemeRequest%+v" , Alias (*i ))
}
func (i *AccountInstallThemeRequest ) FillFrom (from interface {
GetDark () (value bool )
GetTheme () (value InputThemeClass , ok bool )
GetFormat () (value string , ok bool )
GetBaseTheme () (value BaseThemeClass , ok bool )
}) {
i .Dark = from .GetDark ()
if val , ok := from .GetTheme (); ok {
i .Theme = val
}
if val , ok := from .GetFormat (); ok {
i .Format = val
}
if val , ok := from .GetBaseTheme (); ok {
i .BaseTheme = val
}
}
func (*AccountInstallThemeRequest ) TypeID () uint32 {
return AccountInstallThemeRequestTypeID
}
func (*AccountInstallThemeRequest ) TypeName () string {
return "account.installTheme"
}
func (i *AccountInstallThemeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.installTheme" ,
ID : AccountInstallThemeRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Dark" ,
SchemaName : "dark" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "Theme" ,
SchemaName : "theme" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "Format" ,
SchemaName : "format" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "BaseTheme" ,
SchemaName : "base_theme" ,
Null : !i .Flags .Has (3 ),
},
}
return typ
}
func (i *AccountInstallThemeRequest ) SetFlags () {
if !(i .Dark == false ) {
i .Flags .Set (0 )
}
if !(i .Theme == nil ) {
i .Flags .Set (1 )
}
if !(i .Format == "" ) {
i .Flags .Set (2 )
}
if !(i .BaseTheme == nil ) {
i .Flags .Set (3 )
}
}
func (i *AccountInstallThemeRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode account.installTheme#c727bb3b as nil" )
}
b .PutID (AccountInstallThemeRequestTypeID )
return i .EncodeBare (b )
}
func (i *AccountInstallThemeRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode account.installTheme#c727bb3b as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.installTheme#c727bb3b: field flags: %w" , err )
}
if i .Flags .Has (1 ) {
if i .Theme == nil {
return fmt .Errorf ("unable to encode account.installTheme#c727bb3b: field theme is nil" )
}
if err := i .Theme .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.installTheme#c727bb3b: field theme: %w" , err )
}
}
if i .Flags .Has (2 ) {
b .PutString (i .Format )
}
if i .Flags .Has (3 ) {
if i .BaseTheme == nil {
return fmt .Errorf ("unable to encode account.installTheme#c727bb3b: field base_theme is nil" )
}
if err := i .BaseTheme .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.installTheme#c727bb3b: field base_theme: %w" , err )
}
}
return nil
}
func (i *AccountInstallThemeRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode account.installTheme#c727bb3b to nil" )
}
if err := b .ConsumeID (AccountInstallThemeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.installTheme#c727bb3b: %w" , err )
}
return i .DecodeBare (b )
}
func (i *AccountInstallThemeRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode account.installTheme#c727bb3b to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.installTheme#c727bb3b: field flags: %w" , err )
}
}
i .Dark = i .Flags .Has (0 )
if i .Flags .Has (1 ) {
value , err := DecodeInputTheme (b )
if err != nil {
return fmt .Errorf ("unable to decode account.installTheme#c727bb3b: field theme: %w" , err )
}
i .Theme = value
}
if i .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.installTheme#c727bb3b: field format: %w" , err )
}
i .Format = value
}
if i .Flags .Has (3 ) {
value , err := DecodeBaseTheme (b )
if err != nil {
return fmt .Errorf ("unable to decode account.installTheme#c727bb3b: field base_theme: %w" , err )
}
i .BaseTheme = value
}
return nil
}
func (i *AccountInstallThemeRequest ) SetDark (value bool ) {
if value {
i .Flags .Set (0 )
i .Dark = true
} else {
i .Flags .Unset (0 )
i .Dark = false
}
}
func (i *AccountInstallThemeRequest ) GetDark () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (0 )
}
func (i *AccountInstallThemeRequest ) SetTheme (value InputThemeClass ) {
i .Flags .Set (1 )
i .Theme = value
}
func (i *AccountInstallThemeRequest ) GetTheme () (value InputThemeClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .Theme , true
}
func (i *AccountInstallThemeRequest ) SetFormat (value string ) {
i .Flags .Set (2 )
i .Format = value
}
func (i *AccountInstallThemeRequest ) GetFormat () (value string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (2 ) {
return value , false
}
return i .Format , true
}
func (i *AccountInstallThemeRequest ) SetBaseTheme (value BaseThemeClass ) {
i .Flags .Set (3 )
i .BaseTheme = value
}
func (i *AccountInstallThemeRequest ) GetBaseTheme () (value BaseThemeClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (3 ) {
return value , false
}
return i .BaseTheme , true
}
func (c *Client ) AccountInstallTheme (ctx context .Context , request *AccountInstallThemeRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , 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 .