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 PaymentsToggleStarGiftsPinnedToTopRequest struct {
Peer InputPeerClass
Stargift []InputSavedStarGiftClass
}
const PaymentsToggleStarGiftsPinnedToTopRequestTypeID = 0x1513e7b0
var (
_ bin .Encoder = &PaymentsToggleStarGiftsPinnedToTopRequest {}
_ bin .Decoder = &PaymentsToggleStarGiftsPinnedToTopRequest {}
_ bin .BareEncoder = &PaymentsToggleStarGiftsPinnedToTopRequest {}
_ bin .BareDecoder = &PaymentsToggleStarGiftsPinnedToTopRequest {}
)
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Peer == nil ) {
return false
}
if !(t .Stargift == nil ) {
return false
}
return true
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) String () string {
if t == nil {
return "PaymentsToggleStarGiftsPinnedToTopRequest(nil)"
}
type Alias PaymentsToggleStarGiftsPinnedToTopRequest
return fmt .Sprintf ("PaymentsToggleStarGiftsPinnedToTopRequest%+v" , Alias (*t ))
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetStargift () (value []InputSavedStarGiftClass )
}) {
t .Peer = from .GetPeer ()
t .Stargift = from .GetStargift ()
}
func (*PaymentsToggleStarGiftsPinnedToTopRequest ) TypeID () uint32 {
return PaymentsToggleStarGiftsPinnedToTopRequestTypeID
}
func (*PaymentsToggleStarGiftsPinnedToTopRequest ) TypeName () string {
return "payments.toggleStarGiftsPinnedToTop"
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.toggleStarGiftsPinnedToTop" ,
ID : PaymentsToggleStarGiftsPinnedToTopRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Stargift" ,
SchemaName : "stargift" ,
},
}
return typ
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode payments.toggleStarGiftsPinnedToTop#1513e7b0 as nil" )
}
b .PutID (PaymentsToggleStarGiftsPinnedToTopRequestTypeID )
return t .EncodeBare (b )
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode payments.toggleStarGiftsPinnedToTop#1513e7b0 as nil" )
}
if t .Peer == nil {
return fmt .Errorf ("unable to encode payments.toggleStarGiftsPinnedToTop#1513e7b0: field peer is nil" )
}
if err := t .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.toggleStarGiftsPinnedToTop#1513e7b0: field peer: %w" , err )
}
b .PutVectorHeader (len (t .Stargift ))
for idx , v := range t .Stargift {
if v == nil {
return fmt .Errorf ("unable to encode payments.toggleStarGiftsPinnedToTop#1513e7b0: field stargift element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.toggleStarGiftsPinnedToTop#1513e7b0: field stargift element with index %d: %w" , idx , err )
}
}
return nil
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode payments.toggleStarGiftsPinnedToTop#1513e7b0 to nil" )
}
if err := b .ConsumeID (PaymentsToggleStarGiftsPinnedToTopRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.toggleStarGiftsPinnedToTop#1513e7b0: %w" , err )
}
return t .DecodeBare (b )
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode payments.toggleStarGiftsPinnedToTop#1513e7b0 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.toggleStarGiftsPinnedToTop#1513e7b0: field peer: %w" , err )
}
t .Peer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.toggleStarGiftsPinnedToTop#1513e7b0: field stargift: %w" , err )
}
if headerLen > 0 {
t .Stargift = make ([]InputSavedStarGiftClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputSavedStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.toggleStarGiftsPinnedToTop#1513e7b0: field stargift: %w" , err )
}
t .Stargift = append (t .Stargift , value )
}
}
return nil
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) GetPeer () (value InputPeerClass ) {
if t == nil {
return
}
return t .Peer
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) GetStargift () (value []InputSavedStarGiftClass ) {
if t == nil {
return
}
return t .Stargift
}
func (t *PaymentsToggleStarGiftsPinnedToTopRequest ) MapStargift () (value InputSavedStarGiftClassArray ) {
return InputSavedStarGiftClassArray (t .Stargift )
}
func (c *Client ) PaymentsToggleStarGiftsPinnedToTop (ctx context .Context , request *PaymentsToggleStarGiftsPinnedToTopRequest ) (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.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 .