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 StoriesGetStoriesViewsRequest struct {
Peer InputPeerClass
ID []int
}
const StoriesGetStoriesViewsRequestTypeID = 0x28e16cc8
var (
_ bin .Encoder = &StoriesGetStoriesViewsRequest {}
_ bin .Decoder = &StoriesGetStoriesViewsRequest {}
_ bin .BareEncoder = &StoriesGetStoriesViewsRequest {}
_ bin .BareDecoder = &StoriesGetStoriesViewsRequest {}
)
func (g *StoriesGetStoriesViewsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Peer == nil ) {
return false
}
if !(g .ID == nil ) {
return false
}
return true
}
func (g *StoriesGetStoriesViewsRequest ) String () string {
if g == nil {
return "StoriesGetStoriesViewsRequest(nil)"
}
type Alias StoriesGetStoriesViewsRequest
return fmt .Sprintf ("StoriesGetStoriesViewsRequest%+v" , Alias (*g ))
}
func (g *StoriesGetStoriesViewsRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetID () (value []int )
}) {
g .Peer = from .GetPeer ()
g .ID = from .GetID ()
}
func (*StoriesGetStoriesViewsRequest ) TypeID () uint32 {
return StoriesGetStoriesViewsRequestTypeID
}
func (*StoriesGetStoriesViewsRequest ) TypeName () string {
return "stories.getStoriesViews"
}
func (g *StoriesGetStoriesViewsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.getStoriesViews" ,
ID : StoriesGetStoriesViewsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (g *StoriesGetStoriesViewsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode stories.getStoriesViews#28e16cc8 as nil" )
}
b .PutID (StoriesGetStoriesViewsRequestTypeID )
return g .EncodeBare (b )
}
func (g *StoriesGetStoriesViewsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode stories.getStoriesViews#28e16cc8 as nil" )
}
if g .Peer == nil {
return fmt .Errorf ("unable to encode stories.getStoriesViews#28e16cc8: field peer is nil" )
}
if err := g .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.getStoriesViews#28e16cc8: field peer: %w" , err )
}
b .PutVectorHeader (len (g .ID ))
for _ , v := range g .ID {
b .PutInt (v )
}
return nil
}
func (g *StoriesGetStoriesViewsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode stories.getStoriesViews#28e16cc8 to nil" )
}
if err := b .ConsumeID (StoriesGetStoriesViewsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.getStoriesViews#28e16cc8: %w" , err )
}
return g .DecodeBare (b )
}
func (g *StoriesGetStoriesViewsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode stories.getStoriesViews#28e16cc8 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.getStoriesViews#28e16cc8: field peer: %w" , err )
}
g .Peer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.getStoriesViews#28e16cc8: field id: %w" , err )
}
if headerLen > 0 {
g .ID = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.getStoriesViews#28e16cc8: field id: %w" , err )
}
g .ID = append (g .ID , value )
}
}
return nil
}
func (g *StoriesGetStoriesViewsRequest ) GetPeer () (value InputPeerClass ) {
if g == nil {
return
}
return g .Peer
}
func (g *StoriesGetStoriesViewsRequest ) GetID () (value []int ) {
if g == nil {
return
}
return g .ID
}
func (c *Client ) StoriesGetStoriesViews (ctx context .Context , request *StoriesGetStoriesViewsRequest ) (*StoriesStoryViews , error ) {
var result StoriesStoryViews
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .