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 UploadGetFileRequest struct {
Flags bin .Fields
Precise bool
CDNSupported bool
Location InputFileLocationClass
Offset int64
Limit int
}
const UploadGetFileRequestTypeID = 0xbe5335be
var (
_ bin .Encoder = &UploadGetFileRequest {}
_ bin .Decoder = &UploadGetFileRequest {}
_ bin .BareEncoder = &UploadGetFileRequest {}
_ bin .BareDecoder = &UploadGetFileRequest {}
)
func (g *UploadGetFileRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Precise == false ) {
return false
}
if !(g .CDNSupported == false ) {
return false
}
if !(g .Location == nil ) {
return false
}
if !(g .Offset == 0 ) {
return false
}
if !(g .Limit == 0 ) {
return false
}
return true
}
func (g *UploadGetFileRequest ) String () string {
if g == nil {
return "UploadGetFileRequest(nil)"
}
type Alias UploadGetFileRequest
return fmt .Sprintf ("UploadGetFileRequest%+v" , Alias (*g ))
}
func (g *UploadGetFileRequest ) FillFrom (from interface {
GetPrecise () (value bool )
GetCDNSupported () (value bool )
GetLocation () (value InputFileLocationClass )
GetOffset () (value int64 )
GetLimit () (value int )
}) {
g .Precise = from .GetPrecise ()
g .CDNSupported = from .GetCDNSupported ()
g .Location = from .GetLocation ()
g .Offset = from .GetOffset ()
g .Limit = from .GetLimit ()
}
func (*UploadGetFileRequest ) TypeID () uint32 {
return UploadGetFileRequestTypeID
}
func (*UploadGetFileRequest ) TypeName () string {
return "upload.getFile"
}
func (g *UploadGetFileRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "upload.getFile" ,
ID : UploadGetFileRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Precise" ,
SchemaName : "precise" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "CDNSupported" ,
SchemaName : "cdn_supported" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "Location" ,
SchemaName : "location" ,
},
{
Name : "Offset" ,
SchemaName : "offset" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (g *UploadGetFileRequest ) SetFlags () {
if !(g .Precise == false ) {
g .Flags .Set (0 )
}
if !(g .CDNSupported == false ) {
g .Flags .Set (1 )
}
}
func (g *UploadGetFileRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode upload.getFile#be5335be as nil" )
}
b .PutID (UploadGetFileRequestTypeID )
return g .EncodeBare (b )
}
func (g *UploadGetFileRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode upload.getFile#be5335be as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode upload.getFile#be5335be: field flags: %w" , err )
}
if g .Location == nil {
return fmt .Errorf ("unable to encode upload.getFile#be5335be: field location is nil" )
}
if err := g .Location .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode upload.getFile#be5335be: field location: %w" , err )
}
b .PutLong (g .Offset )
b .PutInt (g .Limit )
return nil
}
func (g *UploadGetFileRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode upload.getFile#be5335be to nil" )
}
if err := b .ConsumeID (UploadGetFileRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode upload.getFile#be5335be: %w" , err )
}
return g .DecodeBare (b )
}
func (g *UploadGetFileRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode upload.getFile#be5335be to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode upload.getFile#be5335be: field flags: %w" , err )
}
}
g .Precise = g .Flags .Has (0 )
g .CDNSupported = g .Flags .Has (1 )
{
value , err := DecodeInputFileLocation (b )
if err != nil {
return fmt .Errorf ("unable to decode upload.getFile#be5335be: field location: %w" , err )
}
g .Location = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode upload.getFile#be5335be: field offset: %w" , err )
}
g .Offset = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode upload.getFile#be5335be: field limit: %w" , err )
}
g .Limit = value
}
return nil
}
func (g *UploadGetFileRequest ) SetPrecise (value bool ) {
if value {
g .Flags .Set (0 )
g .Precise = true
} else {
g .Flags .Unset (0 )
g .Precise = false
}
}
func (g *UploadGetFileRequest ) GetPrecise () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (0 )
}
func (g *UploadGetFileRequest ) SetCDNSupported (value bool ) {
if value {
g .Flags .Set (1 )
g .CDNSupported = true
} else {
g .Flags .Unset (1 )
g .CDNSupported = false
}
}
func (g *UploadGetFileRequest ) GetCDNSupported () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *UploadGetFileRequest ) GetLocation () (value InputFileLocationClass ) {
if g == nil {
return
}
return g .Location
}
func (g *UploadGetFileRequest ) GetOffset () (value int64 ) {
if g == nil {
return
}
return g .Offset
}
func (g *UploadGetFileRequest ) GetLimit () (value int ) {
if g == nil {
return
}
return g .Limit
}
func (c *Client ) UploadGetFile (ctx context .Context , request *UploadGetFileRequest ) (UploadFileClass , error ) {
var result UploadFileBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .File , 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 .