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 AccountUploadThemeRequest struct {
Flags bin .Fields
File InputFileClass
Thumb InputFileClass
FileName string
MimeType string
}
const AccountUploadThemeRequestTypeID = 0x1c3db333
var (
_ bin .Encoder = &AccountUploadThemeRequest {}
_ bin .Decoder = &AccountUploadThemeRequest {}
_ bin .BareEncoder = &AccountUploadThemeRequest {}
_ bin .BareDecoder = &AccountUploadThemeRequest {}
)
func (u *AccountUploadThemeRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .File == nil ) {
return false
}
if !(u .Thumb == nil ) {
return false
}
if !(u .FileName == "" ) {
return false
}
if !(u .MimeType == "" ) {
return false
}
return true
}
func (u *AccountUploadThemeRequest ) String () string {
if u == nil {
return "AccountUploadThemeRequest(nil)"
}
type Alias AccountUploadThemeRequest
return fmt .Sprintf ("AccountUploadThemeRequest%+v" , Alias (*u ))
}
func (u *AccountUploadThemeRequest ) FillFrom (from interface {
GetFile () (value InputFileClass )
GetThumb () (value InputFileClass , ok bool )
GetFileName () (value string )
GetMimeType () (value string )
}) {
u .File = from .GetFile ()
if val , ok := from .GetThumb (); ok {
u .Thumb = val
}
u .FileName = from .GetFileName ()
u .MimeType = from .GetMimeType ()
}
func (*AccountUploadThemeRequest ) TypeID () uint32 {
return AccountUploadThemeRequestTypeID
}
func (*AccountUploadThemeRequest ) TypeName () string {
return "account.uploadTheme"
}
func (u *AccountUploadThemeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.uploadTheme" ,
ID : AccountUploadThemeRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "File" ,
SchemaName : "file" ,
},
{
Name : "Thumb" ,
SchemaName : "thumb" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "FileName" ,
SchemaName : "file_name" ,
},
{
Name : "MimeType" ,
SchemaName : "mime_type" ,
},
}
return typ
}
func (u *AccountUploadThemeRequest ) SetFlags () {
if !(u .Thumb == nil ) {
u .Flags .Set (0 )
}
}
func (u *AccountUploadThemeRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.uploadTheme#1c3db333 as nil" )
}
b .PutID (AccountUploadThemeRequestTypeID )
return u .EncodeBare (b )
}
func (u *AccountUploadThemeRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.uploadTheme#1c3db333 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadTheme#1c3db333: field flags: %w" , err )
}
if u .File == nil {
return fmt .Errorf ("unable to encode account.uploadTheme#1c3db333: field file is nil" )
}
if err := u .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadTheme#1c3db333: field file: %w" , err )
}
if u .Flags .Has (0 ) {
if u .Thumb == nil {
return fmt .Errorf ("unable to encode account.uploadTheme#1c3db333: field thumb is nil" )
}
if err := u .Thumb .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadTheme#1c3db333: field thumb: %w" , err )
}
}
b .PutString (u .FileName )
b .PutString (u .MimeType )
return nil
}
func (u *AccountUploadThemeRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.uploadTheme#1c3db333 to nil" )
}
if err := b .ConsumeID (AccountUploadThemeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.uploadTheme#1c3db333: %w" , err )
}
return u .DecodeBare (b )
}
func (u *AccountUploadThemeRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.uploadTheme#1c3db333 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.uploadTheme#1c3db333: field flags: %w" , err )
}
}
{
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode account.uploadTheme#1c3db333: field file: %w" , err )
}
u .File = value
}
if u .Flags .Has (0 ) {
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode account.uploadTheme#1c3db333: field thumb: %w" , err )
}
u .Thumb = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.uploadTheme#1c3db333: field file_name: %w" , err )
}
u .FileName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.uploadTheme#1c3db333: field mime_type: %w" , err )
}
u .MimeType = value
}
return nil
}
func (u *AccountUploadThemeRequest ) GetFile () (value InputFileClass ) {
if u == nil {
return
}
return u .File
}
func (u *AccountUploadThemeRequest ) SetThumb (value InputFileClass ) {
u .Flags .Set (0 )
u .Thumb = value
}
func (u *AccountUploadThemeRequest ) GetThumb () (value InputFileClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .Thumb , true
}
func (u *AccountUploadThemeRequest ) GetFileName () (value string ) {
if u == nil {
return
}
return u .FileName
}
func (u *AccountUploadThemeRequest ) GetMimeType () (value string ) {
if u == nil {
return
}
return u .MimeType
}
func (c *Client ) AccountUploadTheme (ctx context .Context , request *AccountUploadThemeRequest ) (DocumentClass , error ) {
var result DocumentBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Document , 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 .