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 PhotosUploadContactProfilePhotoRequest struct {
Flags bin .Fields
Suggest bool
Save bool
UserID InputUserClass
File InputFileClass
Video InputFileClass
VideoStartTs float64
VideoEmojiMarkup VideoSizeClass
}
const PhotosUploadContactProfilePhotoRequestTypeID = 0xe14c4a71
var (
_ bin .Encoder = &PhotosUploadContactProfilePhotoRequest {}
_ bin .Decoder = &PhotosUploadContactProfilePhotoRequest {}
_ bin .BareEncoder = &PhotosUploadContactProfilePhotoRequest {}
_ bin .BareDecoder = &PhotosUploadContactProfilePhotoRequest {}
)
func (u *PhotosUploadContactProfilePhotoRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Suggest == false ) {
return false
}
if !(u .Save == false ) {
return false
}
if !(u .UserID == 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 *PhotosUploadContactProfilePhotoRequest ) String () string {
if u == nil {
return "PhotosUploadContactProfilePhotoRequest(nil)"
}
type Alias PhotosUploadContactProfilePhotoRequest
return fmt .Sprintf ("PhotosUploadContactProfilePhotoRequest%+v" , Alias (*u ))
}
func (u *PhotosUploadContactProfilePhotoRequest ) FillFrom (from interface {
GetSuggest () (value bool )
GetSave () (value bool )
GetUserID () (value InputUserClass )
GetFile () (value InputFileClass , ok bool )
GetVideo () (value InputFileClass , ok bool )
GetVideoStartTs () (value float64 , ok bool )
GetVideoEmojiMarkup () (value VideoSizeClass , ok bool )
}) {
u .Suggest = from .GetSuggest ()
u .Save = from .GetSave ()
u .UserID = from .GetUserID ()
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 (*PhotosUploadContactProfilePhotoRequest ) TypeID () uint32 {
return PhotosUploadContactProfilePhotoRequestTypeID
}
func (*PhotosUploadContactProfilePhotoRequest ) TypeName () string {
return "photos.uploadContactProfilePhoto"
}
func (u *PhotosUploadContactProfilePhotoRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photos.uploadContactProfilePhoto" ,
ID : PhotosUploadContactProfilePhotoRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Suggest" ,
SchemaName : "suggest" ,
Null : !u .Flags .Has (3 ),
},
{
Name : "Save" ,
SchemaName : "save" ,
Null : !u .Flags .Has (4 ),
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
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 (5 ),
},
}
return typ
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetFlags () {
if !(u .Suggest == false ) {
u .Flags .Set (3 )
}
if !(u .Save == false ) {
u .Flags .Set (4 )
}
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 (5 )
}
}
func (u *PhotosUploadContactProfilePhotoRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode photos.uploadContactProfilePhoto#e14c4a71 as nil" )
}
b .PutID (PhotosUploadContactProfilePhotoRequestTypeID )
return u .EncodeBare (b )
}
func (u *PhotosUploadContactProfilePhotoRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode photos.uploadContactProfilePhoto#e14c4a71 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field flags: %w" , err )
}
if u .UserID == nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field user_id is nil" )
}
if err := u .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field user_id: %w" , err )
}
if u .Flags .Has (0 ) {
if u .File == nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field file is nil" )
}
if err := u .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field file: %w" , err )
}
}
if u .Flags .Has (1 ) {
if u .Video == nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field video is nil" )
}
if err := u .Video .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field video: %w" , err )
}
}
if u .Flags .Has (2 ) {
b .PutDouble (u .VideoStartTs )
}
if u .Flags .Has (5 ) {
if u .VideoEmojiMarkup == nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field video_emoji_markup is nil" )
}
if err := u .VideoEmojiMarkup .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.uploadContactProfilePhoto#e14c4a71: field video_emoji_markup: %w" , err )
}
}
return nil
}
func (u *PhotosUploadContactProfilePhotoRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode photos.uploadContactProfilePhoto#e14c4a71 to nil" )
}
if err := b .ConsumeID (PhotosUploadContactProfilePhotoRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode photos.uploadContactProfilePhoto#e14c4a71: %w" , err )
}
return u .DecodeBare (b )
}
func (u *PhotosUploadContactProfilePhotoRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode photos.uploadContactProfilePhoto#e14c4a71 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode photos.uploadContactProfilePhoto#e14c4a71: field flags: %w" , err )
}
}
u .Suggest = u .Flags .Has (3 )
u .Save = u .Flags .Has (4 )
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadContactProfilePhoto#e14c4a71: field user_id: %w" , err )
}
u .UserID = value
}
if u .Flags .Has (0 ) {
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadContactProfilePhoto#e14c4a71: 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.uploadContactProfilePhoto#e14c4a71: 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.uploadContactProfilePhoto#e14c4a71: field video_start_ts: %w" , err )
}
u .VideoStartTs = value
}
if u .Flags .Has (5 ) {
value , err := DecodeVideoSize (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.uploadContactProfilePhoto#e14c4a71: field video_emoji_markup: %w" , err )
}
u .VideoEmojiMarkup = value
}
return nil
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetSuggest (value bool ) {
if value {
u .Flags .Set (3 )
u .Suggest = true
} else {
u .Flags .Unset (3 )
u .Suggest = false
}
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetSuggest () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (3 )
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetSave (value bool ) {
if value {
u .Flags .Set (4 )
u .Save = true
} else {
u .Flags .Unset (4 )
u .Save = false
}
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetSave () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (4 )
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetUserID () (value InputUserClass ) {
if u == nil {
return
}
return u .UserID
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetFile (value InputFileClass ) {
u .Flags .Set (0 )
u .File = value
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetFile () (value InputFileClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .File , true
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetVideo (value InputFileClass ) {
u .Flags .Set (1 )
u .Video = value
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetVideo () (value InputFileClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (1 ) {
return value , false
}
return u .Video , true
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetVideoStartTs (value float64 ) {
u .Flags .Set (2 )
u .VideoStartTs = value
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetVideoStartTs () (value float64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .VideoStartTs , true
}
func (u *PhotosUploadContactProfilePhotoRequest ) SetVideoEmojiMarkup (value VideoSizeClass ) {
u .Flags .Set (5 )
u .VideoEmojiMarkup = value
}
func (u *PhotosUploadContactProfilePhotoRequest ) GetVideoEmojiMarkup () (value VideoSizeClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (5 ) {
return value , false
}
return u .VideoEmojiMarkup , true
}
func (c *Client ) PhotosUploadContactProfilePhoto (ctx context .Context , request *PhotosUploadContactProfilePhotoRequest ) (*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 .