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