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 PaymentsGetResaleStarGiftsRequest struct {
Flags bin .Fields
SortByPrice bool
SortByNum bool
ForCraft bool
StarsOnly bool
AttributesHash int64
GiftID int64
Attributes []StarGiftAttributeIDClass
Offset string
Limit int
}
const PaymentsGetResaleStarGiftsRequestTypeID = 0x7a5fa236
var (
_ bin .Encoder = &PaymentsGetResaleStarGiftsRequest {}
_ bin .Decoder = &PaymentsGetResaleStarGiftsRequest {}
_ bin .BareEncoder = &PaymentsGetResaleStarGiftsRequest {}
_ bin .BareDecoder = &PaymentsGetResaleStarGiftsRequest {}
)
func (g *PaymentsGetResaleStarGiftsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .SortByPrice == false ) {
return false
}
if !(g .SortByNum == false ) {
return false
}
if !(g .ForCraft == false ) {
return false
}
if !(g .StarsOnly == false ) {
return false
}
if !(g .AttributesHash == 0 ) {
return false
}
if !(g .GiftID == 0 ) {
return false
}
if !(g .Attributes == nil ) {
return false
}
if !(g .Offset == "" ) {
return false
}
if !(g .Limit == 0 ) {
return false
}
return true
}
func (g *PaymentsGetResaleStarGiftsRequest ) String () string {
if g == nil {
return "PaymentsGetResaleStarGiftsRequest(nil)"
}
type Alias PaymentsGetResaleStarGiftsRequest
return fmt .Sprintf ("PaymentsGetResaleStarGiftsRequest%+v" , Alias (*g ))
}
func (g *PaymentsGetResaleStarGiftsRequest ) FillFrom (from interface {
GetSortByPrice () (value bool )
GetSortByNum () (value bool )
GetForCraft () (value bool )
GetStarsOnly () (value bool )
GetAttributesHash () (value int64 , ok bool )
GetGiftID () (value int64 )
GetAttributes () (value []StarGiftAttributeIDClass , ok bool )
GetOffset () (value string )
GetLimit () (value int )
}) {
g .SortByPrice = from .GetSortByPrice ()
g .SortByNum = from .GetSortByNum ()
g .ForCraft = from .GetForCraft ()
g .StarsOnly = from .GetStarsOnly ()
if val , ok := from .GetAttributesHash (); ok {
g .AttributesHash = val
}
g .GiftID = from .GetGiftID ()
if val , ok := from .GetAttributes (); ok {
g .Attributes = val
}
g .Offset = from .GetOffset ()
g .Limit = from .GetLimit ()
}
func (*PaymentsGetResaleStarGiftsRequest ) TypeID () uint32 {
return PaymentsGetResaleStarGiftsRequestTypeID
}
func (*PaymentsGetResaleStarGiftsRequest ) TypeName () string {
return "payments.getResaleStarGifts"
}
func (g *PaymentsGetResaleStarGiftsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.getResaleStarGifts" ,
ID : PaymentsGetResaleStarGiftsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "SortByPrice" ,
SchemaName : "sort_by_price" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "SortByNum" ,
SchemaName : "sort_by_num" ,
Null : !g .Flags .Has (2 ),
},
{
Name : "ForCraft" ,
SchemaName : "for_craft" ,
Null : !g .Flags .Has (4 ),
},
{
Name : "StarsOnly" ,
SchemaName : "stars_only" ,
Null : !g .Flags .Has (5 ),
},
{
Name : "AttributesHash" ,
SchemaName : "attributes_hash" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "GiftID" ,
SchemaName : "gift_id" ,
},
{
Name : "Attributes" ,
SchemaName : "attributes" ,
Null : !g .Flags .Has (3 ),
},
{
Name : "Offset" ,
SchemaName : "offset" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetFlags () {
if !(g .SortByPrice == false ) {
g .Flags .Set (1 )
}
if !(g .SortByNum == false ) {
g .Flags .Set (2 )
}
if !(g .ForCraft == false ) {
g .Flags .Set (4 )
}
if !(g .StarsOnly == false ) {
g .Flags .Set (5 )
}
if !(g .AttributesHash == 0 ) {
g .Flags .Set (0 )
}
if !(g .Attributes == nil ) {
g .Flags .Set (3 )
}
}
func (g *PaymentsGetResaleStarGiftsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getResaleStarGifts#7a5fa236 as nil" )
}
b .PutID (PaymentsGetResaleStarGiftsRequestTypeID )
return g .EncodeBare (b )
}
func (g *PaymentsGetResaleStarGiftsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getResaleStarGifts#7a5fa236 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getResaleStarGifts#7a5fa236: field flags: %w" , err )
}
if g .Flags .Has (0 ) {
b .PutLong (g .AttributesHash )
}
b .PutLong (g .GiftID )
if g .Flags .Has (3 ) {
b .PutVectorHeader (len (g .Attributes ))
for idx , v := range g .Attributes {
if v == nil {
return fmt .Errorf ("unable to encode payments.getResaleStarGifts#7a5fa236: field attributes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getResaleStarGifts#7a5fa236: field attributes element with index %d: %w" , idx , err )
}
}
}
b .PutString (g .Offset )
b .PutInt (g .Limit )
return nil
}
func (g *PaymentsGetResaleStarGiftsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getResaleStarGifts#7a5fa236 to nil" )
}
if err := b .ConsumeID (PaymentsGetResaleStarGiftsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PaymentsGetResaleStarGiftsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getResaleStarGifts#7a5fa236 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field flags: %w" , err )
}
}
g .SortByPrice = g .Flags .Has (1 )
g .SortByNum = g .Flags .Has (2 )
g .ForCraft = g .Flags .Has (4 )
g .StarsOnly = g .Flags .Has (5 )
if g .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field attributes_hash: %w" , err )
}
g .AttributesHash = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field gift_id: %w" , err )
}
g .GiftID = value
}
if g .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field attributes: %w" , err )
}
if headerLen > 0 {
g .Attributes = make ([]StarGiftAttributeIDClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeStarGiftAttributeID (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field attributes: %w" , err )
}
g .Attributes = append (g .Attributes , value )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field offset: %w" , err )
}
g .Offset = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getResaleStarGifts#7a5fa236: field limit: %w" , err )
}
g .Limit = value
}
return nil
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetSortByPrice (value bool ) {
if value {
g .Flags .Set (1 )
g .SortByPrice = true
} else {
g .Flags .Unset (1 )
g .SortByPrice = false
}
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetSortByPrice () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetSortByNum (value bool ) {
if value {
g .Flags .Set (2 )
g .SortByNum = true
} else {
g .Flags .Unset (2 )
g .SortByNum = false
}
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetSortByNum () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (2 )
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetForCraft (value bool ) {
if value {
g .Flags .Set (4 )
g .ForCraft = true
} else {
g .Flags .Unset (4 )
g .ForCraft = false
}
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetForCraft () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (4 )
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetStarsOnly (value bool ) {
if value {
g .Flags .Set (5 )
g .StarsOnly = true
} else {
g .Flags .Unset (5 )
g .StarsOnly = false
}
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetStarsOnly () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (5 )
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetAttributesHash (value int64 ) {
g .Flags .Set (0 )
g .AttributesHash = value
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetAttributesHash () (value int64 , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .AttributesHash , true
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetGiftID () (value int64 ) {
if g == nil {
return
}
return g .GiftID
}
func (g *PaymentsGetResaleStarGiftsRequest ) SetAttributes (value []StarGiftAttributeIDClass ) {
g .Flags .Set (3 )
g .Attributes = value
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetAttributes () (value []StarGiftAttributeIDClass , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (3 ) {
return value , false
}
return g .Attributes , true
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetOffset () (value string ) {
if g == nil {
return
}
return g .Offset
}
func (g *PaymentsGetResaleStarGiftsRequest ) GetLimit () (value int ) {
if g == nil {
return
}
return g .Limit
}
func (g *PaymentsGetResaleStarGiftsRequest ) MapAttributes () (value StarGiftAttributeIDClassArray , ok bool ) {
if !g .Flags .Has (3 ) {
return value , false
}
return StarGiftAttributeIDClassArray (g .Attributes ), true
}
func (c *Client ) PaymentsGetResaleStarGifts (ctx context .Context , request *PaymentsGetResaleStarGiftsRequest ) (*PaymentsResaleStarGifts , error ) {
var result PaymentsResaleStarGifts
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 .