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 PremiumApplyBoostRequest struct {
Flags bin .Fields
Slots []int
Peer InputPeerClass
}
const PremiumApplyBoostRequestTypeID = 0x6b7da746
var (
_ bin .Encoder = &PremiumApplyBoostRequest {}
_ bin .Decoder = &PremiumApplyBoostRequest {}
_ bin .BareEncoder = &PremiumApplyBoostRequest {}
_ bin .BareDecoder = &PremiumApplyBoostRequest {}
)
func (a *PremiumApplyBoostRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .Slots == nil ) {
return false
}
if !(a .Peer == nil ) {
return false
}
return true
}
func (a *PremiumApplyBoostRequest ) String () string {
if a == nil {
return "PremiumApplyBoostRequest(nil)"
}
type Alias PremiumApplyBoostRequest
return fmt .Sprintf ("PremiumApplyBoostRequest%+v" , Alias (*a ))
}
func (a *PremiumApplyBoostRequest ) FillFrom (from interface {
GetSlots () (value []int , ok bool )
GetPeer () (value InputPeerClass )
}) {
if val , ok := from .GetSlots (); ok {
a .Slots = val
}
a .Peer = from .GetPeer ()
}
func (*PremiumApplyBoostRequest ) TypeID () uint32 {
return PremiumApplyBoostRequestTypeID
}
func (*PremiumApplyBoostRequest ) TypeName () string {
return "premium.applyBoost"
}
func (a *PremiumApplyBoostRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "premium.applyBoost" ,
ID : PremiumApplyBoostRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Slots" ,
SchemaName : "slots" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
}
return typ
}
func (a *PremiumApplyBoostRequest ) SetFlags () {
if !(a .Slots == nil ) {
a .Flags .Set (0 )
}
}
func (a *PremiumApplyBoostRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode premium.applyBoost#6b7da746 as nil" )
}
b .PutID (PremiumApplyBoostRequestTypeID )
return a .EncodeBare (b )
}
func (a *PremiumApplyBoostRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode premium.applyBoost#6b7da746 as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode premium.applyBoost#6b7da746: field flags: %w" , err )
}
if a .Flags .Has (0 ) {
b .PutVectorHeader (len (a .Slots ))
for _ , v := range a .Slots {
b .PutInt (v )
}
}
if a .Peer == nil {
return fmt .Errorf ("unable to encode premium.applyBoost#6b7da746: field peer is nil" )
}
if err := a .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode premium.applyBoost#6b7da746: field peer: %w" , err )
}
return nil
}
func (a *PremiumApplyBoostRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode premium.applyBoost#6b7da746 to nil" )
}
if err := b .ConsumeID (PremiumApplyBoostRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode premium.applyBoost#6b7da746: %w" , err )
}
return a .DecodeBare (b )
}
func (a *PremiumApplyBoostRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode premium.applyBoost#6b7da746 to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode premium.applyBoost#6b7da746: field flags: %w" , err )
}
}
if a .Flags .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode premium.applyBoost#6b7da746: field slots: %w" , err )
}
if headerLen > 0 {
a .Slots = 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 premium.applyBoost#6b7da746: field slots: %w" , err )
}
a .Slots = append (a .Slots , value )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode premium.applyBoost#6b7da746: field peer: %w" , err )
}
a .Peer = value
}
return nil
}
func (a *PremiumApplyBoostRequest ) SetSlots (value []int ) {
a .Flags .Set (0 )
a .Slots = value
}
func (a *PremiumApplyBoostRequest ) GetSlots () (value []int , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (0 ) {
return value , false
}
return a .Slots , true
}
func (a *PremiumApplyBoostRequest ) GetPeer () (value InputPeerClass ) {
if a == nil {
return
}
return a .Peer
}
func (c *Client ) PremiumApplyBoost (ctx context .Context , request *PremiumApplyBoostRequest ) (*PremiumMyBoosts , error ) {
var result PremiumMyBoosts
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 .