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 PaymentsUpdateStarGiftCollectionRequest struct {
Flags bin .Fields
Peer InputPeerClass
CollectionID int
Title string
DeleteStargift []InputSavedStarGiftClass
AddStargift []InputSavedStarGiftClass
Order []InputSavedStarGiftClass
}
const PaymentsUpdateStarGiftCollectionRequestTypeID = 0x4fddbee7
var (
_ bin .Encoder = &PaymentsUpdateStarGiftCollectionRequest {}
_ bin .Decoder = &PaymentsUpdateStarGiftCollectionRequest {}
_ bin .BareEncoder = &PaymentsUpdateStarGiftCollectionRequest {}
_ bin .BareDecoder = &PaymentsUpdateStarGiftCollectionRequest {}
)
func (u *PaymentsUpdateStarGiftCollectionRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Peer == nil ) {
return false
}
if !(u .CollectionID == 0 ) {
return false
}
if !(u .Title == "" ) {
return false
}
if !(u .DeleteStargift == nil ) {
return false
}
if !(u .AddStargift == nil ) {
return false
}
if !(u .Order == nil ) {
return false
}
return true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) String () string {
if u == nil {
return "PaymentsUpdateStarGiftCollectionRequest(nil)"
}
type Alias PaymentsUpdateStarGiftCollectionRequest
return fmt .Sprintf ("PaymentsUpdateStarGiftCollectionRequest%+v" , Alias (*u ))
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetCollectionID () (value int )
GetTitle () (value string , ok bool )
GetDeleteStargift () (value []InputSavedStarGiftClass , ok bool )
GetAddStargift () (value []InputSavedStarGiftClass , ok bool )
GetOrder () (value []InputSavedStarGiftClass , ok bool )
}) {
u .Peer = from .GetPeer ()
u .CollectionID = from .GetCollectionID ()
if val , ok := from .GetTitle (); ok {
u .Title = val
}
if val , ok := from .GetDeleteStargift (); ok {
u .DeleteStargift = val
}
if val , ok := from .GetAddStargift (); ok {
u .AddStargift = val
}
if val , ok := from .GetOrder (); ok {
u .Order = val
}
}
func (*PaymentsUpdateStarGiftCollectionRequest ) TypeID () uint32 {
return PaymentsUpdateStarGiftCollectionRequestTypeID
}
func (*PaymentsUpdateStarGiftCollectionRequest ) TypeName () string {
return "payments.updateStarGiftCollection"
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.updateStarGiftCollection" ,
ID : PaymentsUpdateStarGiftCollectionRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "CollectionID" ,
SchemaName : "collection_id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "DeleteStargift" ,
SchemaName : "delete_stargift" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "AddStargift" ,
SchemaName : "add_stargift" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "Order" ,
SchemaName : "order" ,
Null : !u .Flags .Has (3 ),
},
}
return typ
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) SetFlags () {
if !(u .Title == "" ) {
u .Flags .Set (0 )
}
if !(u .DeleteStargift == nil ) {
u .Flags .Set (1 )
}
if !(u .AddStargift == nil ) {
u .Flags .Set (2 )
}
if !(u .Order == nil ) {
u .Flags .Set (3 )
}
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode payments.updateStarGiftCollection#4fddbee7 as nil" )
}
b .PutID (PaymentsUpdateStarGiftCollectionRequestTypeID )
return u .EncodeBare (b )
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode payments.updateStarGiftCollection#4fddbee7 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field flags: %w" , err )
}
if u .Peer == nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field peer is nil" )
}
if err := u .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field peer: %w" , err )
}
b .PutInt (u .CollectionID )
if u .Flags .Has (0 ) {
b .PutString (u .Title )
}
if u .Flags .Has (1 ) {
b .PutVectorHeader (len (u .DeleteStargift ))
for idx , v := range u .DeleteStargift {
if v == nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field delete_stargift element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field delete_stargift element with index %d: %w" , idx , err )
}
}
}
if u .Flags .Has (2 ) {
b .PutVectorHeader (len (u .AddStargift ))
for idx , v := range u .AddStargift {
if v == nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field add_stargift element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field add_stargift element with index %d: %w" , idx , err )
}
}
}
if u .Flags .Has (3 ) {
b .PutVectorHeader (len (u .Order ))
for idx , v := range u .Order {
if v == nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field order element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.updateStarGiftCollection#4fddbee7: field order element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode payments.updateStarGiftCollection#4fddbee7 to nil" )
}
if err := b .ConsumeID (PaymentsUpdateStarGiftCollectionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: %w" , err )
}
return u .DecodeBare (b )
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode payments.updateStarGiftCollection#4fddbee7 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field flags: %w" , err )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field peer: %w" , err )
}
u .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field collection_id: %w" , err )
}
u .CollectionID = value
}
if u .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field title: %w" , err )
}
u .Title = value
}
if u .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field delete_stargift: %w" , err )
}
if headerLen > 0 {
u .DeleteStargift = 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.updateStarGiftCollection#4fddbee7: field delete_stargift: %w" , err )
}
u .DeleteStargift = append (u .DeleteStargift , value )
}
}
if u .Flags .Has (2 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field add_stargift: %w" , err )
}
if headerLen > 0 {
u .AddStargift = 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.updateStarGiftCollection#4fddbee7: field add_stargift: %w" , err )
}
u .AddStargift = append (u .AddStargift , value )
}
}
if u .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.updateStarGiftCollection#4fddbee7: field order: %w" , err )
}
if headerLen > 0 {
u .Order = 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.updateStarGiftCollection#4fddbee7: field order: %w" , err )
}
u .Order = append (u .Order , value )
}
}
return nil
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) GetPeer () (value InputPeerClass ) {
if u == nil {
return
}
return u .Peer
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) GetCollectionID () (value int ) {
if u == nil {
return
}
return u .CollectionID
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) SetTitle (value string ) {
u .Flags .Set (0 )
u .Title = value
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) GetTitle () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .Title , true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) SetDeleteStargift (value []InputSavedStarGiftClass ) {
u .Flags .Set (1 )
u .DeleteStargift = value
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) GetDeleteStargift () (value []InputSavedStarGiftClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (1 ) {
return value , false
}
return u .DeleteStargift , true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) SetAddStargift (value []InputSavedStarGiftClass ) {
u .Flags .Set (2 )
u .AddStargift = value
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) GetAddStargift () (value []InputSavedStarGiftClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .AddStargift , true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) SetOrder (value []InputSavedStarGiftClass ) {
u .Flags .Set (3 )
u .Order = value
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) GetOrder () (value []InputSavedStarGiftClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (3 ) {
return value , false
}
return u .Order , true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) MapDeleteStargift () (value InputSavedStarGiftClassArray , ok bool ) {
if !u .Flags .Has (1 ) {
return value , false
}
return InputSavedStarGiftClassArray (u .DeleteStargift ), true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) MapAddStargift () (value InputSavedStarGiftClassArray , ok bool ) {
if !u .Flags .Has (2 ) {
return value , false
}
return InputSavedStarGiftClassArray (u .AddStargift ), true
}
func (u *PaymentsUpdateStarGiftCollectionRequest ) MapOrder () (value InputSavedStarGiftClassArray , ok bool ) {
if !u .Flags .Has (3 ) {
return value , false
}
return InputSavedStarGiftClassArray (u .Order ), true
}
func (c *Client ) PaymentsUpdateStarGiftCollection (ctx context .Context , request *PaymentsUpdateStarGiftCollectionRequest ) (*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 .