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 PhotosUploadProfilePhotoRequest struct {
Flags bin .Fields
Fallback bool
Bot InputUserClass
File InputFileClass
Video InputFileClass
VideoStartTs float64
VideoEmojiMarkup VideoSizeClass
}
const PhotosUploadProfilePhotoRequestTypeID = 0x388a3b5
var (
_ bin .Encoder = &PhotosUploadProfilePhotoRequest {}
_ bin .Decoder = &PhotosUploadProfilePhotoRequest {}
_ bin .BareEncoder = &PhotosUploadProfilePhotoRequest {}
_ bin .BareDecoder = &PhotosUploadProfilePhotoRequest {}
)
func (u *PhotosUploadProfilePhotoRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Fallback == false ) {
return false
}
if !(u .Bot == nil ) {
return false
}
if !(u .File == nil ) {
return false
}
if !(u .Video == nil ) {
return false
}
if !(u .VideoStartTs == 0 ) {
return false
}
if !(u .VideoEmojiMarkup == nil ) {
return false
}
return true
}
func (u *PhotosUploadProfilePhotoRequest ) String () string {
if u == nil {
return "PhotosUploadProfilePhotoRequest(nil)"
}
type Alias PhotosUploadProfilePhotoRequest
return fmt .Sprintf ("PhotosUploadProfilePhotoRequest%+v" , Alias (*u ))
}
func (u *PhotosUploadProfilePhotoRequest ) FillFrom (from interface {
GetFallback () (value bool )
GetBot () (value InputUserClass , ok bool )
GetFile () (value InputFileClass , ok bool )
GetVideo () (value InputFileClass , ok bool )
GetVideoStartTs () (value float64 , ok bool )
GetVideoEmojiMarkup () (value VideoSizeClass , ok bool )
}) {
u .Fallback = from .GetFallback ()
if val , ok := from .GetBot (); ok {
u .Bot = val
}
if val , ok := from .GetFile (); ok {
u .File = val
}
if val , ok := from .GetVideo (); ok {
u .Video = val
}
if val , ok := from .GetVideoStartTs (); ok {
u .VideoStartTs = val
}
if val , ok := from .GetVideoEmojiMarkup (); ok {
u .VideoEmojiMarkup = val
}
}
func (*PhotosUploadProfilePhotoRequest ) TypeID () uint32 {
return PhotosUploadProfilePhotoRequestTypeID
}
func (*PhotosUploadProfilePhotoRequest ) TypeName () string {
return "photos.uploadProfilePhoto"
}
func (u *PhotosUploadProfilePhotoRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photos.uploadProfilePhoto" ,
ID : PhotosUploadProfilePhotoRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Fallback" ,
SchemaName : "fallback" ,
Null : !u .Flags .Has (3 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
Null : !u .Flags .Has (5 ),
},
{
Name : "File" ,
SchemaName : "file" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "Video" ,
SchemaName : "video" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "VideoStartTs" ,
SchemaName : "video_start_ts" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "VideoEmojiMarkup" ,
SchemaName : "video_emoji_markup" ,
Null : !u .Flags .Has (4 ),
},
}
return typ
}
func (u *PhotosUploadProfilePhotoRequest ) SetFlags () {
if !(u .Fallback == false ) {
u .Flags .Set (3 )
}
if !(u .Bot == nil ) {
u .Flags .Set (5 )
}
if !(u .File == nil ) {
u .Flags .Set (0 )
}
if !(u .Video == nil ) {
u .Flags .Set (1 )
}
if !(u .VideoStartTs == 0 ) {
u .Flags .Set (2 )
}
if !(u .VideoEmojiMarkup == nil ) {
u .Flags .Set (4 )
}
}
func (u *PhotosUploadProfilePhotoRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode photos.uploadProfilePhoto#388a3b5 as nil" )
}
b .PutID (PhotosUploadProfilePhotoRequestTypeID )
return u .EncodeBare (b )
}
func (u *PhotosUploadProfilePhotoRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode photos.uploadProfilePhoto#388a3b5 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field flags: %w" , err )
}
if u .Flags .Has (5 ) {
if u .Bot == nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field bot is nil" )
}
if err := u .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field bot: %w" , err )
}
}
if u .Flags .Has (0 ) {
if u .File == nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field file is nil" )
}
if err := u .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field file: %w" , err )
}
}
if u .Flags .Has (1 ) {
if u .Video == nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field video is nil" )
}
if err := u .Video .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field video: %w" , err )
}
}
if u .Flags .Has (2 ) {
b .PutDouble (u .VideoStartTs )
}
if u .Flags .Has (4 ) {
if u .VideoEmojiMarkup == nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field video_emoji_markup is nil" )
}
if err := u .VideoEmojiMarkup .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadProfilePhoto#388a3b5: field video_emoji_markup: %w" , err )
}
}
return nil
}
func (u *PhotosUploadProfilePhotoRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode photos.uploadProfilePhoto#388a3b5 to nil" )
}
if err := b .ConsumeID (PhotosUploadProfilePhotoRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: %w" , err )
}
return u .DecodeBare (b )
}
func (u *PhotosUploadProfilePhotoRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode photos.uploadProfilePhoto#388a3b5 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: field flags: %w" , err )
}
}
u .Fallback = u .Flags .Has (3 )
if u .Flags .Has (5 ) {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: field bot: %w" , err )
}
u .Bot = value
}
if u .Flags .Has (0 ) {
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: field file: %w" , err )
}
u .File = value
}
if u .Flags .Has (1 ) {
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: field video: %w" , err )
}
u .Video = value
}
if u .Flags .Has (2 ) {
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: field video_start_ts: %w" , err )
}
u .VideoStartTs = value
}
if u .Flags .Has (4 ) {
value , err := DecodeVideoSize (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadProfilePhoto#388a3b5: field video_emoji_markup: %w" , err )
}
u .VideoEmojiMarkup = value
}
return nil
}
func (u *PhotosUploadProfilePhotoRequest ) SetFallback (value bool ) {
if value {
u .Flags .Set (3 )
u .Fallback = true
} else {
u .Flags .Unset (3 )
u .Fallback = false
}
}
func (u *PhotosUploadProfilePhotoRequest ) GetFallback () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (3 )
}
func (u *PhotosUploadProfilePhotoRequest ) SetBot (value InputUserClass ) {
u .Flags .Set (5 )
u .Bot = value
}
func (u *PhotosUploadProfilePhotoRequest ) GetBot () (value InputUserClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (5 ) {
return value , false
}
return u .Bot , true
}
func (u *PhotosUploadProfilePhotoRequest ) SetFile (value InputFileClass ) {
u .Flags .Set (0 )
u .File = value
}
func (u *PhotosUploadProfilePhotoRequest ) GetFile () (value InputFileClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .File , true
}
func (u *PhotosUploadProfilePhotoRequest ) SetVideo (value InputFileClass ) {
u .Flags .Set (1 )
u .Video = value
}
func (u *PhotosUploadProfilePhotoRequest ) GetVideo () (value InputFileClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (1 ) {
return value , false
}
return u .Video , true
}
func (u *PhotosUploadProfilePhotoRequest ) SetVideoStartTs (value float64 ) {
u .Flags .Set (2 )
u .VideoStartTs = value
}
func (u *PhotosUploadProfilePhotoRequest ) GetVideoStartTs () (value float64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .VideoStartTs , true
}
func (u *PhotosUploadProfilePhotoRequest ) SetVideoEmojiMarkup (value VideoSizeClass ) {
u .Flags .Set (4 )
u .VideoEmojiMarkup = value
}
func (u *PhotosUploadProfilePhotoRequest ) GetVideoEmojiMarkup () (value VideoSizeClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (4 ) {
return value , false
}
return u .VideoEmojiMarkup , true
}
func (c *Client ) PhotosUploadProfilePhoto (ctx context .Context , request *PhotosUploadProfilePhotoRequest ) (*PhotosPhoto , error ) {
var result PhotosPhoto
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 .