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 PhotosUpdateProfilePhotoRequest struct {
Flags bin .Fields
Fallback bool
Bot InputUserClass
ID InputPhotoClass
}
const PhotosUpdateProfilePhotoRequestTypeID = 0x9e82039
var (
_ bin .Encoder = &PhotosUpdateProfilePhotoRequest {}
_ bin .Decoder = &PhotosUpdateProfilePhotoRequest {}
_ bin .BareEncoder = &PhotosUpdateProfilePhotoRequest {}
_ bin .BareDecoder = &PhotosUpdateProfilePhotoRequest {}
)
func (u *PhotosUpdateProfilePhotoRequest ) 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 .ID == nil ) {
return false
}
return true
}
func (u *PhotosUpdateProfilePhotoRequest ) String () string {
if u == nil {
return "PhotosUpdateProfilePhotoRequest(nil)"
}
type Alias PhotosUpdateProfilePhotoRequest
return fmt .Sprintf ("PhotosUpdateProfilePhotoRequest%+v" , Alias (*u ))
}
func (u *PhotosUpdateProfilePhotoRequest ) FillFrom (from interface {
GetFallback () (value bool )
GetBot () (value InputUserClass , ok bool )
GetID () (value InputPhotoClass )
}) {
u .Fallback = from .GetFallback ()
if val , ok := from .GetBot (); ok {
u .Bot = val
}
u .ID = from .GetID ()
}
func (*PhotosUpdateProfilePhotoRequest ) TypeID () uint32 {
return PhotosUpdateProfilePhotoRequestTypeID
}
func (*PhotosUpdateProfilePhotoRequest ) TypeName () string {
return "photos.updateProfilePhoto"
}
func (u *PhotosUpdateProfilePhotoRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photos.updateProfilePhoto" ,
ID : PhotosUpdateProfilePhotoRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Fallback" ,
SchemaName : "fallback" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (u *PhotosUpdateProfilePhotoRequest ) SetFlags () {
if !(u .Fallback == false ) {
u .Flags .Set (0 )
}
if !(u .Bot == nil ) {
u .Flags .Set (1 )
}
}
func (u *PhotosUpdateProfilePhotoRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode photos.updateProfilePhoto#9e82039 as nil" )
}
b .PutID (PhotosUpdateProfilePhotoRequestTypeID )
return u .EncodeBare (b )
}
func (u *PhotosUpdateProfilePhotoRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode photos.updateProfilePhoto#9e82039 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.updateProfilePhoto#9e82039: field flags: %w" , err )
}
if u .Flags .Has (1 ) {
if u .Bot == nil {
return fmt .Errorf ("unable to encode photos.updateProfilePhoto#9e82039: field bot is nil" )
}
if err := u .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.updateProfilePhoto#9e82039: field bot: %w" , err )
}
}
if u .ID == nil {
return fmt .Errorf ("unable to encode photos.updateProfilePhoto#9e82039: field id is nil" )
}
if err := u .ID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.updateProfilePhoto#9e82039: field id: %w" , err )
}
return nil
}
func (u *PhotosUpdateProfilePhotoRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode photos.updateProfilePhoto#9e82039 to nil" )
}
if err := b .ConsumeID (PhotosUpdateProfilePhotoRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode photos.updateProfilePhoto#9e82039: %w" , err )
}
return u .DecodeBare (b )
}
func (u *PhotosUpdateProfilePhotoRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode photos.updateProfilePhoto#9e82039 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode photos.updateProfilePhoto#9e82039: field flags: %w" , err )
}
}
u .Fallback = u .Flags .Has (0 )
if u .Flags .Has (1 ) {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.updateProfilePhoto#9e82039: field bot: %w" , err )
}
u .Bot = value
}
{
value , err := DecodeInputPhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.updateProfilePhoto#9e82039: field id: %w" , err )
}
u .ID = value
}
return nil
}
func (u *PhotosUpdateProfilePhotoRequest ) SetFallback (value bool ) {
if value {
u .Flags .Set (0 )
u .Fallback = true
} else {
u .Flags .Unset (0 )
u .Fallback = false
}
}
func (u *PhotosUpdateProfilePhotoRequest ) GetFallback () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (0 )
}
func (u *PhotosUpdateProfilePhotoRequest ) SetBot (value InputUserClass ) {
u .Flags .Set (1 )
u .Bot = value
}
func (u *PhotosUpdateProfilePhotoRequest ) GetBot () (value InputUserClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (1 ) {
return value , false
}
return u .Bot , true
}
func (u *PhotosUpdateProfilePhotoRequest ) GetID () (value InputPhotoClass ) {
if u == nil {
return
}
return u .ID
}
func (u *PhotosUpdateProfilePhotoRequest ) GetIDAsNotEmpty () (*InputPhoto , bool ) {
return u .ID .AsNotEmpty ()
}
func (c *Client ) PhotosUpdateProfilePhoto (ctx context .Context , request *PhotosUpdateProfilePhotoRequest ) (*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 .