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 BusinessIntro struct {
Flags bin .Fields
Title string
Description string
Sticker DocumentClass
}
const BusinessIntroTypeID = 0x5a0a066d
var (
_ bin .Encoder = &BusinessIntro {}
_ bin .Decoder = &BusinessIntro {}
_ bin .BareEncoder = &BusinessIntro {}
_ bin .BareDecoder = &BusinessIntro {}
)
func (b *BusinessIntro ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .Title == "" ) {
return false
}
if !(b .Description == "" ) {
return false
}
if !(b .Sticker == nil ) {
return false
}
return true
}
func (b *BusinessIntro ) String () string {
if b == nil {
return "BusinessIntro(nil)"
}
type Alias BusinessIntro
return fmt .Sprintf ("BusinessIntro%+v" , Alias (*b ))
}
func (b *BusinessIntro ) FillFrom (from interface {
GetTitle () (value string )
GetDescription () (value string )
GetSticker () (value DocumentClass , ok bool )
}) {
b .Title = from .GetTitle ()
b .Description = from .GetDescription ()
if val , ok := from .GetSticker (); ok {
b .Sticker = val
}
}
func (*BusinessIntro ) TypeID () uint32 {
return BusinessIntroTypeID
}
func (*BusinessIntro ) TypeName () string {
return "businessIntro"
}
func (b *BusinessIntro ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "businessIntro" ,
ID : BusinessIntroTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Description" ,
SchemaName : "description" ,
},
{
Name : "Sticker" ,
SchemaName : "sticker" ,
Null : !b .Flags .Has (0 ),
},
}
return typ
}
func (b *BusinessIntro ) SetFlags () {
if !(b .Sticker == nil ) {
b .Flags .Set (0 )
}
}
func (b *BusinessIntro ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode businessIntro#5a0a066d as nil" )
}
buf .PutID (BusinessIntroTypeID )
return b .EncodeBare (buf )
}
func (b *BusinessIntro ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode businessIntro#5a0a066d as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode businessIntro#5a0a066d: field flags: %w" , err )
}
buf .PutString (b .Title )
buf .PutString (b .Description )
if b .Flags .Has (0 ) {
if b .Sticker == nil {
return fmt .Errorf ("unable to encode businessIntro#5a0a066d: field sticker is nil" )
}
if err := b .Sticker .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode businessIntro#5a0a066d: field sticker: %w" , err )
}
}
return nil
}
func (b *BusinessIntro ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode businessIntro#5a0a066d to nil" )
}
if err := buf .ConsumeID (BusinessIntroTypeID ); err != nil {
return fmt .Errorf ("unable to decode businessIntro#5a0a066d: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BusinessIntro ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode businessIntro#5a0a066d to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode businessIntro#5a0a066d: field flags: %w" , err )
}
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode businessIntro#5a0a066d: field title: %w" , err )
}
b .Title = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode businessIntro#5a0a066d: field description: %w" , err )
}
b .Description = value
}
if b .Flags .Has (0 ) {
value , err := DecodeDocument (buf )
if err != nil {
return fmt .Errorf ("unable to decode businessIntro#5a0a066d: field sticker: %w" , err )
}
b .Sticker = value
}
return nil
}
func (b *BusinessIntro ) GetTitle () (value string ) {
if b == nil {
return
}
return b .Title
}
func (b *BusinessIntro ) GetDescription () (value string ) {
if b == nil {
return
}
return b .Description
}
func (b *BusinessIntro ) SetSticker (value DocumentClass ) {
b .Flags .Set (0 )
b .Sticker = value
}
func (b *BusinessIntro ) GetSticker () (value DocumentClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .Sticker , true
}
func (b *BusinessIntro ) GetStickerAsNotEmpty () (*Document , bool ) {
if value , ok := b .GetSticker (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .