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 WalletSetCardStickersRequest struct {
Flags bin .Fields
Stickers []InputWalletCardSticker
BgNftAddress string
}
const WalletSetCardStickersRequestTypeID = 0x68509ac
var (
_ bin .Encoder = &WalletSetCardStickersRequest {}
_ bin .Decoder = &WalletSetCardStickersRequest {}
_ bin .BareEncoder = &WalletSetCardStickersRequest {}
_ bin .BareDecoder = &WalletSetCardStickersRequest {}
)
func (s *WalletSetCardStickersRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Stickers == nil ) {
return false
}
if !(s .BgNftAddress == "" ) {
return false
}
return true
}
func (s *WalletSetCardStickersRequest ) String () string {
if s == nil {
return "WalletSetCardStickersRequest(nil)"
}
type Alias WalletSetCardStickersRequest
return fmt .Sprintf ("WalletSetCardStickersRequest%+v" , Alias (*s ))
}
func (s *WalletSetCardStickersRequest ) FillFrom (from interface {
GetStickers () (value []InputWalletCardSticker )
GetBgNftAddress () (value string , ok bool )
}) {
s .Stickers = from .GetStickers ()
if val , ok := from .GetBgNftAddress (); ok {
s .BgNftAddress = val
}
}
func (*WalletSetCardStickersRequest ) TypeID () uint32 {
return WalletSetCardStickersRequestTypeID
}
func (*WalletSetCardStickersRequest ) TypeName () string {
return "wallet.setCardStickers"
}
func (s *WalletSetCardStickersRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallet.setCardStickers" ,
ID : WalletSetCardStickersRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Stickers" ,
SchemaName : "stickers" ,
},
{
Name : "BgNftAddress" ,
SchemaName : "bg_nft_address" ,
Null : !s .Flags .Has (0 ),
},
}
return typ
}
func (s *WalletSetCardStickersRequest ) SetFlags () {
if !(s .BgNftAddress == "" ) {
s .Flags .Set (0 )
}
}
func (s *WalletSetCardStickersRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode wallet.setCardStickers#68509ac as nil" )
}
b .PutID (WalletSetCardStickersRequestTypeID )
return s .EncodeBare (b )
}
func (s *WalletSetCardStickersRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode wallet.setCardStickers#68509ac as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.setCardStickers#68509ac: field flags: %w" , err )
}
b .PutVectorHeader (len (s .Stickers ))
for idx , v := range s .Stickers {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.setCardStickers#68509ac: field stickers element with index %d: %w" , idx , err )
}
}
if s .Flags .Has (0 ) {
b .PutString (s .BgNftAddress )
}
return nil
}
func (s *WalletSetCardStickersRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode wallet.setCardStickers#68509ac to nil" )
}
if err := b .ConsumeID (WalletSetCardStickersRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallet.setCardStickers#68509ac: %w" , err )
}
return s .DecodeBare (b )
}
func (s *WalletSetCardStickersRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode wallet.setCardStickers#68509ac to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.setCardStickers#68509ac: field flags: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.setCardStickers#68509ac: field stickers: %w" , err )
}
if headerLen > 0 {
s .Stickers = make ([]InputWalletCardSticker , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value InputWalletCardSticker
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.setCardStickers#68509ac: field stickers: %w" , err )
}
s .Stickers = append (s .Stickers , value )
}
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.setCardStickers#68509ac: field bg_nft_address: %w" , err )
}
s .BgNftAddress = value
}
return nil
}
func (s *WalletSetCardStickersRequest ) GetStickers () (value []InputWalletCardSticker ) {
if s == nil {
return
}
return s .Stickers
}
func (s *WalletSetCardStickersRequest ) SetBgNftAddress (value string ) {
s .Flags .Set (0 )
s .BgNftAddress = value
}
func (s *WalletSetCardStickersRequest ) GetBgNftAddress () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .BgNftAddress , true
}
func (c *Client ) WalletSetCardStickers (ctx context .Context , request *WalletSetCardStickersRequest ) (*WalletCard , error ) {
var result WalletCard
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , nil
}
The pages are generated with Golds v0.8.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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .