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