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 AccountUpdateColorRequest struct {
Flags bin .Fields
ForProfile bool
Color int
BackgroundEmojiID int64
}
const AccountUpdateColorRequestTypeID = 0x7cefa15d
var (
_ bin .Encoder = &AccountUpdateColorRequest {}
_ bin .Decoder = &AccountUpdateColorRequest {}
_ bin .BareEncoder = &AccountUpdateColorRequest {}
_ bin .BareDecoder = &AccountUpdateColorRequest {}
)
func (u *AccountUpdateColorRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .ForProfile == false ) {
return false
}
if !(u .Color == 0 ) {
return false
}
if !(u .BackgroundEmojiID == 0 ) {
return false
}
return true
}
func (u *AccountUpdateColorRequest ) String () string {
if u == nil {
return "AccountUpdateColorRequest(nil)"
}
type Alias AccountUpdateColorRequest
return fmt .Sprintf ("AccountUpdateColorRequest%+v" , Alias (*u ))
}
func (u *AccountUpdateColorRequest ) FillFrom (from interface {
GetForProfile () (value bool )
GetColor () (value int , ok bool )
GetBackgroundEmojiID () (value int64 , ok bool )
}) {
u .ForProfile = from .GetForProfile ()
if val , ok := from .GetColor (); ok {
u .Color = val
}
if val , ok := from .GetBackgroundEmojiID (); ok {
u .BackgroundEmojiID = val
}
}
func (*AccountUpdateColorRequest ) TypeID () uint32 {
return AccountUpdateColorRequestTypeID
}
func (*AccountUpdateColorRequest ) TypeName () string {
return "account.updateColor"
}
func (u *AccountUpdateColorRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.updateColor" ,
ID : AccountUpdateColorRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ForProfile" ,
SchemaName : "for_profile" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "Color" ,
SchemaName : "color" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "BackgroundEmojiID" ,
SchemaName : "background_emoji_id" ,
Null : !u .Flags .Has (0 ),
},
}
return typ
}
func (u *AccountUpdateColorRequest ) SetFlags () {
if !(u .ForProfile == false ) {
u .Flags .Set (1 )
}
if !(u .Color == 0 ) {
u .Flags .Set (2 )
}
if !(u .BackgroundEmojiID == 0 ) {
u .Flags .Set (0 )
}
}
func (u *AccountUpdateColorRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.updateColor#7cefa15d as nil" )
}
b .PutID (AccountUpdateColorRequestTypeID )
return u .EncodeBare (b )
}
func (u *AccountUpdateColorRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.updateColor#7cefa15d as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.updateColor#7cefa15d: field flags: %w" , err )
}
if u .Flags .Has (2 ) {
b .PutInt (u .Color )
}
if u .Flags .Has (0 ) {
b .PutLong (u .BackgroundEmojiID )
}
return nil
}
func (u *AccountUpdateColorRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.updateColor#7cefa15d to nil" )
}
if err := b .ConsumeID (AccountUpdateColorRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.updateColor#7cefa15d: %w" , err )
}
return u .DecodeBare (b )
}
func (u *AccountUpdateColorRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.updateColor#7cefa15d to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.updateColor#7cefa15d: field flags: %w" , err )
}
}
u .ForProfile = u .Flags .Has (1 )
if u .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode account.updateColor#7cefa15d: field color: %w" , err )
}
u .Color = value
}
if u .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.updateColor#7cefa15d: field background_emoji_id: %w" , err )
}
u .BackgroundEmojiID = value
}
return nil
}
func (u *AccountUpdateColorRequest ) SetForProfile (value bool ) {
if value {
u .Flags .Set (1 )
u .ForProfile = true
} else {
u .Flags .Unset (1 )
u .ForProfile = false
}
}
func (u *AccountUpdateColorRequest ) GetForProfile () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (1 )
}
func (u *AccountUpdateColorRequest ) SetColor (value int ) {
u .Flags .Set (2 )
u .Color = value
}
func (u *AccountUpdateColorRequest ) GetColor () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .Color , true
}
func (u *AccountUpdateColorRequest ) SetBackgroundEmojiID (value int64 ) {
u .Flags .Set (0 )
u .BackgroundEmojiID = value
}
func (u *AccountUpdateColorRequest ) GetBackgroundEmojiID () (value int64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .BackgroundEmojiID , true
}
func (c *Client ) AccountUpdateColor (ctx context .Context , request *AccountUpdateColorRequest ) (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 .