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 PhotosDeletePhotosRequest struct {
ID []InputPhotoClass
}
const PhotosDeletePhotosRequestTypeID = 0x87cf7f2f
var (
_ bin .Encoder = &PhotosDeletePhotosRequest {}
_ bin .Decoder = &PhotosDeletePhotosRequest {}
_ bin .BareEncoder = &PhotosDeletePhotosRequest {}
_ bin .BareDecoder = &PhotosDeletePhotosRequest {}
)
func (d *PhotosDeletePhotosRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .ID == nil ) {
return false
}
return true
}
func (d *PhotosDeletePhotosRequest ) String () string {
if d == nil {
return "PhotosDeletePhotosRequest(nil)"
}
type Alias PhotosDeletePhotosRequest
return fmt .Sprintf ("PhotosDeletePhotosRequest%+v" , Alias (*d ))
}
func (d *PhotosDeletePhotosRequest ) FillFrom (from interface {
GetID () (value []InputPhotoClass )
}) {
d .ID = from .GetID ()
}
func (*PhotosDeletePhotosRequest ) TypeID () uint32 {
return PhotosDeletePhotosRequestTypeID
}
func (*PhotosDeletePhotosRequest ) TypeName () string {
return "photos.deletePhotos"
}
func (d *PhotosDeletePhotosRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photos.deletePhotos" ,
ID : PhotosDeletePhotosRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (d *PhotosDeletePhotosRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode photos.deletePhotos#87cf7f2f as nil" )
}
b .PutID (PhotosDeletePhotosRequestTypeID )
return d .EncodeBare (b )
}
func (d *PhotosDeletePhotosRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode photos.deletePhotos#87cf7f2f as nil" )
}
b .PutVectorHeader (len (d .ID ))
for idx , v := range d .ID {
if v == nil {
return fmt .Errorf ("unable to encode photos.deletePhotos#87cf7f2f: field id element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.deletePhotos#87cf7f2f: field id element with index %d: %w" , idx , err )
}
}
return nil
}
func (d *PhotosDeletePhotosRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode photos.deletePhotos#87cf7f2f to nil" )
}
if err := b .ConsumeID (PhotosDeletePhotosRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode photos.deletePhotos#87cf7f2f: %w" , err )
}
return d .DecodeBare (b )
}
func (d *PhotosDeletePhotosRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode photos.deletePhotos#87cf7f2f to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode photos.deletePhotos#87cf7f2f: field id: %w" , err )
}
if headerLen > 0 {
d .ID = make ([]InputPhotoClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.deletePhotos#87cf7f2f: field id: %w" , err )
}
d .ID = append (d .ID , value )
}
}
return nil
}
func (d *PhotosDeletePhotosRequest ) GetID () (value []InputPhotoClass ) {
if d == nil {
return
}
return d .ID
}
func (d *PhotosDeletePhotosRequest ) MapID () (value InputPhotoClassArray ) {
return InputPhotoClassArray (d .ID )
}
func (c *Client ) PhotosDeletePhotos (ctx context .Context , id []InputPhotoClass ) ([]int64 , error ) {
var result LongVector
request := &PhotosDeletePhotosRequest {
ID : id ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return []int64 (result .Elems ), 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 .