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