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 PaymentsSaveStarGiftRequest struct {
Flags bin .Fields
Unsave bool
Stargift InputSavedStarGiftClass
}
const PaymentsSaveStarGiftRequestTypeID = 0x2a2a697c
var (
_ bin .Encoder = &PaymentsSaveStarGiftRequest {}
_ bin .Decoder = &PaymentsSaveStarGiftRequest {}
_ bin .BareEncoder = &PaymentsSaveStarGiftRequest {}
_ bin .BareDecoder = &PaymentsSaveStarGiftRequest {}
)
func (s *PaymentsSaveStarGiftRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Unsave == false ) {
return false
}
if !(s .Stargift == nil ) {
return false
}
return true
}
func (s *PaymentsSaveStarGiftRequest ) String () string {
if s == nil {
return "PaymentsSaveStarGiftRequest(nil)"
}
type Alias PaymentsSaveStarGiftRequest
return fmt .Sprintf ("PaymentsSaveStarGiftRequest%+v" , Alias (*s ))
}
func (s *PaymentsSaveStarGiftRequest ) FillFrom (from interface {
GetUnsave () (value bool )
GetStargift () (value InputSavedStarGiftClass )
}) {
s .Unsave = from .GetUnsave ()
s .Stargift = from .GetStargift ()
}
func (*PaymentsSaveStarGiftRequest ) TypeID () uint32 {
return PaymentsSaveStarGiftRequestTypeID
}
func (*PaymentsSaveStarGiftRequest ) TypeName () string {
return "payments.saveStarGift"
}
func (s *PaymentsSaveStarGiftRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.saveStarGift" ,
ID : PaymentsSaveStarGiftRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Unsave" ,
SchemaName : "unsave" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Stargift" ,
SchemaName : "stargift" ,
},
}
return typ
}
func (s *PaymentsSaveStarGiftRequest ) SetFlags () {
if !(s .Unsave == false ) {
s .Flags .Set (0 )
}
}
func (s *PaymentsSaveStarGiftRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.saveStarGift#2a2a697c as nil" )
}
b .PutID (PaymentsSaveStarGiftRequestTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsSaveStarGiftRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.saveStarGift#2a2a697c as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.saveStarGift#2a2a697c: field flags: %w" , err )
}
if s .Stargift == nil {
return fmt .Errorf ("unable to encode payments.saveStarGift#2a2a697c: field stargift is nil" )
}
if err := s .Stargift .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.saveStarGift#2a2a697c: field stargift: %w" , err )
}
return nil
}
func (s *PaymentsSaveStarGiftRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.saveStarGift#2a2a697c to nil" )
}
if err := b .ConsumeID (PaymentsSaveStarGiftRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.saveStarGift#2a2a697c: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsSaveStarGiftRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.saveStarGift#2a2a697c to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.saveStarGift#2a2a697c: field flags: %w" , err )
}
}
s .Unsave = s .Flags .Has (0 )
{
value , err := DecodeInputSavedStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.saveStarGift#2a2a697c: field stargift: %w" , err )
}
s .Stargift = value
}
return nil
}
func (s *PaymentsSaveStarGiftRequest ) SetUnsave (value bool ) {
if value {
s .Flags .Set (0 )
s .Unsave = true
} else {
s .Flags .Unset (0 )
s .Unsave = false
}
}
func (s *PaymentsSaveStarGiftRequest ) GetUnsave () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *PaymentsSaveStarGiftRequest ) GetStargift () (value InputSavedStarGiftClass ) {
if s == nil {
return
}
return s .Stargift
}
func (c *Client ) PaymentsSaveStarGift (ctx context .Context , request *PaymentsSaveStarGiftRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , 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 .