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