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 PaymentsGetStarsGiftOptionsRequest struct {
Flags bin .Fields
UserID InputUserClass
}
const PaymentsGetStarsGiftOptionsRequestTypeID = 0xd3c96bc8
var (
_ bin .Encoder = &PaymentsGetStarsGiftOptionsRequest {}
_ bin .Decoder = &PaymentsGetStarsGiftOptionsRequest {}
_ bin .BareEncoder = &PaymentsGetStarsGiftOptionsRequest {}
_ bin .BareDecoder = &PaymentsGetStarsGiftOptionsRequest {}
)
func (g *PaymentsGetStarsGiftOptionsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .UserID == nil ) {
return false
}
return true
}
func (g *PaymentsGetStarsGiftOptionsRequest ) String () string {
if g == nil {
return "PaymentsGetStarsGiftOptionsRequest(nil)"
}
type Alias PaymentsGetStarsGiftOptionsRequest
return fmt .Sprintf ("PaymentsGetStarsGiftOptionsRequest%+v" , Alias (*g ))
}
func (g *PaymentsGetStarsGiftOptionsRequest ) FillFrom (from interface {
GetUserID () (value InputUserClass , ok bool )
}) {
if val , ok := from .GetUserID (); ok {
g .UserID = val
}
}
func (*PaymentsGetStarsGiftOptionsRequest ) TypeID () uint32 {
return PaymentsGetStarsGiftOptionsRequestTypeID
}
func (*PaymentsGetStarsGiftOptionsRequest ) TypeName () string {
return "payments.getStarsGiftOptions"
}
func (g *PaymentsGetStarsGiftOptionsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.getStarsGiftOptions" ,
ID : PaymentsGetStarsGiftOptionsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
Null : !g .Flags .Has (0 ),
},
}
return typ
}
func (g *PaymentsGetStarsGiftOptionsRequest ) SetFlags () {
if !(g .UserID == nil ) {
g .Flags .Set (0 )
}
}
func (g *PaymentsGetStarsGiftOptionsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getStarsGiftOptions#d3c96bc8 as nil" )
}
b .PutID (PaymentsGetStarsGiftOptionsRequestTypeID )
return g .EncodeBare (b )
}
func (g *PaymentsGetStarsGiftOptionsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getStarsGiftOptions#d3c96bc8 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getStarsGiftOptions#d3c96bc8: field flags: %w" , err )
}
if g .Flags .Has (0 ) {
if g .UserID == nil {
return fmt .Errorf ("unable to encode payments.getStarsGiftOptions#d3c96bc8: field user_id is nil" )
}
if err := g .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getStarsGiftOptions#d3c96bc8: field user_id: %w" , err )
}
}
return nil
}
func (g *PaymentsGetStarsGiftOptionsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getStarsGiftOptions#d3c96bc8 to nil" )
}
if err := b .ConsumeID (PaymentsGetStarsGiftOptionsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.getStarsGiftOptions#d3c96bc8: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PaymentsGetStarsGiftOptionsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getStarsGiftOptions#d3c96bc8 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.getStarsGiftOptions#d3c96bc8: field flags: %w" , err )
}
}
if g .Flags .Has (0 ) {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.getStarsGiftOptions#d3c96bc8: field user_id: %w" , err )
}
g .UserID = value
}
return nil
}
func (g *PaymentsGetStarsGiftOptionsRequest ) SetUserID (value InputUserClass ) {
g .Flags .Set (0 )
g .UserID = value
}
func (g *PaymentsGetStarsGiftOptionsRequest ) GetUserID () (value InputUserClass , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .UserID , true
}
func (c *Client ) PaymentsGetStarsGiftOptions (ctx context .Context , request *PaymentsGetStarsGiftOptionsRequest ) ([]StarsGiftOption , error ) {
var result StarsGiftOptionVector
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return []StarsGiftOption (result .Elems ), 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 .