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