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 AccountUploadRingtoneRequest struct {
File InputFileClass
FileName string
MimeType string
}
const AccountUploadRingtoneRequestTypeID = 0x831a83a2
var (
_ bin .Encoder = &AccountUploadRingtoneRequest {}
_ bin .Decoder = &AccountUploadRingtoneRequest {}
_ bin .BareEncoder = &AccountUploadRingtoneRequest {}
_ bin .BareDecoder = &AccountUploadRingtoneRequest {}
)
func (u *AccountUploadRingtoneRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .File == nil ) {
return false
}
if !(u .FileName == "" ) {
return false
}
if !(u .MimeType == "" ) {
return false
}
return true
}
func (u *AccountUploadRingtoneRequest ) String () string {
if u == nil {
return "AccountUploadRingtoneRequest(nil)"
}
type Alias AccountUploadRingtoneRequest
return fmt .Sprintf ("AccountUploadRingtoneRequest%+v" , Alias (*u ))
}
func (u *AccountUploadRingtoneRequest ) FillFrom (from interface {
GetFile () (value InputFileClass )
GetFileName () (value string )
GetMimeType () (value string )
}) {
u .File = from .GetFile ()
u .FileName = from .GetFileName ()
u .MimeType = from .GetMimeType ()
}
func (*AccountUploadRingtoneRequest ) TypeID () uint32 {
return AccountUploadRingtoneRequestTypeID
}
func (*AccountUploadRingtoneRequest ) TypeName () string {
return "account.uploadRingtone"
}
func (u *AccountUploadRingtoneRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.uploadRingtone" ,
ID : AccountUploadRingtoneRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "File" ,
SchemaName : "file" ,
},
{
Name : "FileName" ,
SchemaName : "file_name" ,
},
{
Name : "MimeType" ,
SchemaName : "mime_type" ,
},
}
return typ
}
func (u *AccountUploadRingtoneRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.uploadRingtone#831a83a2 as nil" )
}
b .PutID (AccountUploadRingtoneRequestTypeID )
return u .EncodeBare (b )
}
func (u *AccountUploadRingtoneRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode account.uploadRingtone#831a83a2 as nil" )
}
if u .File == nil {
return fmt .Errorf ("unable to encode account.uploadRingtone#831a83a2: field file is nil" )
}
if err := u .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.uploadRingtone#831a83a2: field file: %w" , err )
}
b .PutString (u .FileName )
b .PutString (u .MimeType )
return nil
}
func (u *AccountUploadRingtoneRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.uploadRingtone#831a83a2 to nil" )
}
if err := b .ConsumeID (AccountUploadRingtoneRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.uploadRingtone#831a83a2: %w" , err )
}
return u .DecodeBare (b )
}
func (u *AccountUploadRingtoneRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode account.uploadRingtone#831a83a2 to nil" )
}
{
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode account.uploadRingtone#831a83a2: field file: %w" , err )
}
u .File = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.uploadRingtone#831a83a2: field file_name: %w" , err )
}
u .FileName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.uploadRingtone#831a83a2: field mime_type: %w" , err )
}
u .MimeType = value
}
return nil
}
func (u *AccountUploadRingtoneRequest ) GetFile () (value InputFileClass ) {
if u == nil {
return
}
return u .File
}
func (u *AccountUploadRingtoneRequest ) GetFileName () (value string ) {
if u == nil {
return
}
return u .FileName
}
func (u *AccountUploadRingtoneRequest ) GetMimeType () (value string ) {
if u == nil {
return
}
return u .MimeType
}
func (c *Client ) AccountUploadRingtone (ctx context .Context , request *AccountUploadRingtoneRequest ) (DocumentClass , error ) {
var result DocumentBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Document , 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 .