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 StatsGraphAsync struct {
Token string
}
const StatsGraphAsyncTypeID = 0x4a27eb2d
func (s StatsGraphAsync ) construct () StatsGraphClass { return &s }
var (
_ bin .Encoder = &StatsGraphAsync {}
_ bin .Decoder = &StatsGraphAsync {}
_ bin .BareEncoder = &StatsGraphAsync {}
_ bin .BareDecoder = &StatsGraphAsync {}
_ StatsGraphClass = &StatsGraphAsync {}
)
func (s *StatsGraphAsync ) Zero () bool {
if s == nil {
return true
}
if !(s .Token == "" ) {
return false
}
return true
}
func (s *StatsGraphAsync ) String () string {
if s == nil {
return "StatsGraphAsync(nil)"
}
type Alias StatsGraphAsync
return fmt .Sprintf ("StatsGraphAsync%+v" , Alias (*s ))
}
func (s *StatsGraphAsync ) FillFrom (from interface {
GetToken () (value string )
}) {
s .Token = from .GetToken ()
}
func (*StatsGraphAsync ) TypeID () uint32 {
return StatsGraphAsyncTypeID
}
func (*StatsGraphAsync ) TypeName () string {
return "statsGraphAsync"
}
func (s *StatsGraphAsync ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "statsGraphAsync" ,
ID : StatsGraphAsyncTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Token" ,
SchemaName : "token" ,
},
}
return typ
}
func (s *StatsGraphAsync ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode statsGraphAsync#4a27eb2d as nil" )
}
b .PutID (StatsGraphAsyncTypeID )
return s .EncodeBare (b )
}
func (s *StatsGraphAsync ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode statsGraphAsync#4a27eb2d as nil" )
}
b .PutString (s .Token )
return nil
}
func (s *StatsGraphAsync ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode statsGraphAsync#4a27eb2d to nil" )
}
if err := b .ConsumeID (StatsGraphAsyncTypeID ); err != nil {
return fmt .Errorf ("unable to decode statsGraphAsync#4a27eb2d: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StatsGraphAsync ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode statsGraphAsync#4a27eb2d to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode statsGraphAsync#4a27eb2d: field token: %w" , err )
}
s .Token = value
}
return nil
}
func (s *StatsGraphAsync ) GetToken () (value string ) {
if s == nil {
return
}
return s .Token
}
type StatsGraphError struct {
Error string
}
const StatsGraphErrorTypeID = 0xbedc9822
func (s StatsGraphError ) construct () StatsGraphClass { return &s }
var (
_ bin .Encoder = &StatsGraphError {}
_ bin .Decoder = &StatsGraphError {}
_ bin .BareEncoder = &StatsGraphError {}
_ bin .BareDecoder = &StatsGraphError {}
_ StatsGraphClass = &StatsGraphError {}
)
func (s *StatsGraphError ) Zero () bool {
if s == nil {
return true
}
if !(s .Error == "" ) {
return false
}
return true
}
func (s *StatsGraphError ) String () string {
if s == nil {
return "StatsGraphError(nil)"
}
type Alias StatsGraphError
return fmt .Sprintf ("StatsGraphError%+v" , Alias (*s ))
}
func (s *StatsGraphError ) FillFrom (from interface {
GetError () (value string )
}) {
s .Error = from .GetError ()
}
func (*StatsGraphError ) TypeID () uint32 {
return StatsGraphErrorTypeID
}
func (*StatsGraphError ) TypeName () string {
return "statsGraphError"
}
func (s *StatsGraphError ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "statsGraphError" ,
ID : StatsGraphErrorTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Error" ,
SchemaName : "error" ,
},
}
return typ
}
func (s *StatsGraphError ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode statsGraphError#bedc9822 as nil" )
}
b .PutID (StatsGraphErrorTypeID )
return s .EncodeBare (b )
}
func (s *StatsGraphError ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode statsGraphError#bedc9822 as nil" )
}
b .PutString (s .Error )
return nil
}
func (s *StatsGraphError ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode statsGraphError#bedc9822 to nil" )
}
if err := b .ConsumeID (StatsGraphErrorTypeID ); err != nil {
return fmt .Errorf ("unable to decode statsGraphError#bedc9822: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StatsGraphError ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode statsGraphError#bedc9822 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode statsGraphError#bedc9822: field error: %w" , err )
}
s .Error = value
}
return nil
}
func (s *StatsGraphError ) GetError () (value string ) {
if s == nil {
return
}
return s .Error
}
type StatsGraph struct {
Flags bin .Fields
JSON DataJSON
ZoomToken string
}
const StatsGraphTypeID = 0x8ea464b6
func (s StatsGraph ) construct () StatsGraphClass { return &s }
var (
_ bin .Encoder = &StatsGraph {}
_ bin .Decoder = &StatsGraph {}
_ bin .BareEncoder = &StatsGraph {}
_ bin .BareDecoder = &StatsGraph {}
_ StatsGraphClass = &StatsGraph {}
)
func (s *StatsGraph ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .JSON .Zero ()) {
return false
}
if !(s .ZoomToken == "" ) {
return false
}
return true
}
func (s *StatsGraph ) String () string {
if s == nil {
return "StatsGraph(nil)"
}
type Alias StatsGraph
return fmt .Sprintf ("StatsGraph%+v" , Alias (*s ))
}
func (s *StatsGraph ) FillFrom (from interface {
GetJSON () (value DataJSON )
GetZoomToken () (value string , ok bool )
}) {
s .JSON = from .GetJSON ()
if val , ok := from .GetZoomToken (); ok {
s .ZoomToken = val
}
}
func (*StatsGraph ) TypeID () uint32 {
return StatsGraphTypeID
}
func (*StatsGraph ) TypeName () string {
return "statsGraph"
}
func (s *StatsGraph ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "statsGraph" ,
ID : StatsGraphTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "JSON" ,
SchemaName : "json" ,
},
{
Name : "ZoomToken" ,
SchemaName : "zoom_token" ,
Null : !s .Flags .Has (0 ),
},
}
return typ
}
func (s *StatsGraph ) SetFlags () {
if !(s .ZoomToken == "" ) {
s .Flags .Set (0 )
}
}
func (s *StatsGraph ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode statsGraph#8ea464b6 as nil" )
}
b .PutID (StatsGraphTypeID )
return s .EncodeBare (b )
}
func (s *StatsGraph ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode statsGraph#8ea464b6 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode statsGraph#8ea464b6: field flags: %w" , err )
}
if err := s .JSON .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode statsGraph#8ea464b6: field json: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutString (s .ZoomToken )
}
return nil
}
func (s *StatsGraph ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode statsGraph#8ea464b6 to nil" )
}
if err := b .ConsumeID (StatsGraphTypeID ); err != nil {
return fmt .Errorf ("unable to decode statsGraph#8ea464b6: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StatsGraph ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode statsGraph#8ea464b6 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode statsGraph#8ea464b6: field flags: %w" , err )
}
}
{
if err := s .JSON .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode statsGraph#8ea464b6: field json: %w" , err )
}
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode statsGraph#8ea464b6: field zoom_token: %w" , err )
}
s .ZoomToken = value
}
return nil
}
func (s *StatsGraph ) GetJSON () (value DataJSON ) {
if s == nil {
return
}
return s .JSON
}
func (s *StatsGraph ) SetZoomToken (value string ) {
s .Flags .Set (0 )
s .ZoomToken = value
}
func (s *StatsGraph ) GetZoomToken () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .ZoomToken , true
}
const StatsGraphClassName = "StatsGraph"
type StatsGraphClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StatsGraphClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeStatsGraph (buf *bin .Buffer ) (StatsGraphClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StatsGraphAsyncTypeID :
v := StatsGraphAsync {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StatsGraphClass: %w" , err )
}
return &v , nil
case StatsGraphErrorTypeID :
v := StatsGraphError {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StatsGraphClass: %w" , err )
}
return &v , nil
case StatsGraphTypeID :
v := StatsGraph {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StatsGraphClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StatsGraphClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StatsGraphBox struct {
StatsGraph StatsGraphClass
}
func (b *StatsGraphBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StatsGraphBox to nil" )
}
v , err := DecodeStatsGraph (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .StatsGraph = v
return nil
}
func (b *StatsGraphBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .StatsGraph == nil {
return fmt .Errorf ("unable to encode StatsGraphClass as nil" )
}
return b .StatsGraph .Encode (buf )
}
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 .