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 AccountUploadWallPaperRequest struct {
Flags bin .Fields
ForChat bool
File InputFileClass
MimeType string
Settings WallPaperSettings
}
const AccountUploadWallPaperRequestTypeID = 0xe39a8f03
var (
_ bin .Encoder = &AccountUploadWallPaperRequest {}
_ bin .Decoder = &AccountUploadWallPaperRequest {}
_ bin .BareEncoder = &AccountUploadWallPaperRequest {}
_ bin .BareDecoder = &AccountUploadWallPaperRequest {}
)
func (u *AccountUploadWallPaperRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .ForChat == false ) {
return false
}
if !(u .File == nil ) {
return false
}
if !(u .MimeType == "" ) {
return false
}
if !(u .Settings .Zero ()) {
return false
}
return true
}
func (u *AccountUploadWallPaperRequest ) String () string {
if u == nil {
return "AccountUploadWallPaperRequest(nil)"
}
type Alias AccountUploadWallPaperRequest
return fmt .Sprintf ("AccountUploadWallPaperRequest%+v" , Alias (*u ))
}
func (u *AccountUploadWallPaperRequest ) FillFrom (from interface {
GetForChat () (value bool )
GetFile () (value InputFileClass )
GetMimeType () (value string )
GetSettings () (value WallPaperSettings )
}) {
u .ForChat = from .GetForChat ()
u .File = from .GetFile ()
u .MimeType = from .GetMimeType ()
u .Settings = from .GetSettings ()
}
func (*AccountUploadWallPaperRequest ) TypeID () uint32 {
return AccountUploadWallPaperRequestTypeID
}
func (*AccountUploadWallPaperRequest ) TypeName () string {
return "account.uploadWallPaper"
}
func (u *AccountUploadWallPaperRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.uploadWallPaper" ,
ID : AccountUploadWallPaperRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ForChat" ,
SchemaName : "for_chat" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "File" ,
SchemaName : "file" ,
},
{
Name : "MimeType" ,
SchemaName : "mime_type" ,
},
{
Name : "Settings" ,
SchemaName : "settings" ,
},
}
return typ
}
func (u *AccountUploadWallPaperRequest ) SetFlags () {
if !(u .ForChat == false ) {
u .Flags .Set (0 )
}
}
func (u *AccountUploadWallPaperRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.uploadWallPaper#e39a8f03 as nil" )
}
b .PutID (AccountUploadWallPaperRequestTypeID )
return u .EncodeBare (b )
}
func (u *AccountUploadWallPaperRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.uploadWallPaper#e39a8f03 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadWallPaper#e39a8f03: field flags: %w" , err )
}
if u .File == nil {
return fmt .Errorf ("unable to encode account.uploadWallPaper#e39a8f03: field file is nil" )
}
if err := u .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadWallPaper#e39a8f03: field file: %w" , err )
}
b .PutString (u .MimeType )
if err := u .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadWallPaper#e39a8f03: field settings: %w" , err )
}
return nil
}
func (u *AccountUploadWallPaperRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.uploadWallPaper#e39a8f03 to nil" )
}
if err := b .ConsumeID (AccountUploadWallPaperRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.uploadWallPaper#e39a8f03: %w" , err )
}
return u .DecodeBare (b )
}
func (u *AccountUploadWallPaperRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.uploadWallPaper#e39a8f03 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.uploadWallPaper#e39a8f03: field flags: %w" , err )
}
}
u .ForChat = u .Flags .Has (0 )
{
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode account.uploadWallPaper#e39a8f03: field file: %w" , err )
}
u .File = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.uploadWallPaper#e39a8f03: field mime_type: %w" , err )
}
u .MimeType = value
}
{
if err := u .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.uploadWallPaper#e39a8f03: field settings: %w" , err )
}
}
return nil
}
func (u *AccountUploadWallPaperRequest ) SetForChat (value bool ) {
if value {
u .Flags .Set (0 )
u .ForChat = true
} else {
u .Flags .Unset (0 )
u .ForChat = false
}
}
func (u *AccountUploadWallPaperRequest ) GetForChat () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (0 )
}
func (u *AccountUploadWallPaperRequest ) GetFile () (value InputFileClass ) {
if u == nil {
return
}
return u .File
}
func (u *AccountUploadWallPaperRequest ) GetMimeType () (value string ) {
if u == nil {
return
}
return u .MimeType
}
func (u *AccountUploadWallPaperRequest ) GetSettings () (value WallPaperSettings ) {
if u == nil {
return
}
return u .Settings
}
func (c *Client ) AccountUploadWallPaper (ctx context .Context , request *AccountUploadWallPaperRequest ) (WallPaperClass , error ) {
var result WallPaperBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .WallPaper , 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 .