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 PaymentsGetPremiumGiftCodeOptionsRequest struct {
Flags bin .Fields
BoostPeer InputPeerClass
}
const PaymentsGetPremiumGiftCodeOptionsRequestTypeID = 0x2757ba54
var (
_ bin .Encoder = &PaymentsGetPremiumGiftCodeOptionsRequest {}
_ bin .Decoder = &PaymentsGetPremiumGiftCodeOptionsRequest {}
_ bin .BareEncoder = &PaymentsGetPremiumGiftCodeOptionsRequest {}
_ bin .BareDecoder = &PaymentsGetPremiumGiftCodeOptionsRequest {}
)
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .BoostPeer == nil ) {
return false
}
return true
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) String () string {
if g == nil {
return "PaymentsGetPremiumGiftCodeOptionsRequest(nil)"
}
type Alias PaymentsGetPremiumGiftCodeOptionsRequest
return fmt .Sprintf ("PaymentsGetPremiumGiftCodeOptionsRequest%+v" , Alias (*g ))
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) FillFrom (from interface {
GetBoostPeer () (value InputPeerClass , ok bool )
}) {
if val , ok := from .GetBoostPeer (); ok {
g .BoostPeer = val
}
}
func (*PaymentsGetPremiumGiftCodeOptionsRequest ) TypeID () uint32 {
return PaymentsGetPremiumGiftCodeOptionsRequestTypeID
}
func (*PaymentsGetPremiumGiftCodeOptionsRequest ) TypeName () string {
return "payments.getPremiumGiftCodeOptions"
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.getPremiumGiftCodeOptions" ,
ID : PaymentsGetPremiumGiftCodeOptionsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "BoostPeer" ,
SchemaName : "boost_peer" ,
Null : !g .Flags .Has (0 ),
},
}
return typ
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) SetFlags () {
if !(g .BoostPeer == nil ) {
g .Flags .Set (0 )
}
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getPremiumGiftCodeOptions#2757ba54 as nil" )
}
b .PutID (PaymentsGetPremiumGiftCodeOptionsRequestTypeID )
return g .EncodeBare (b )
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getPremiumGiftCodeOptions#2757ba54 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getPremiumGiftCodeOptions#2757ba54: field flags: %w" , err )
}
if g .Flags .Has (0 ) {
if g .BoostPeer == nil {
return fmt .Errorf ("unable to encode payments.getPremiumGiftCodeOptions#2757ba54: field boost_peer is nil" )
}
if err := g .BoostPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getPremiumGiftCodeOptions#2757ba54: field boost_peer: %w" , err )
}
}
return nil
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getPremiumGiftCodeOptions#2757ba54 to nil" )
}
if err := b .ConsumeID (PaymentsGetPremiumGiftCodeOptionsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.getPremiumGiftCodeOptions#2757ba54: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getPremiumGiftCodeOptions#2757ba54 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.getPremiumGiftCodeOptions#2757ba54: field flags: %w" , err )
}
}
if g .Flags .Has (0 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.getPremiumGiftCodeOptions#2757ba54: field boost_peer: %w" , err )
}
g .BoostPeer = value
}
return nil
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) SetBoostPeer (value InputPeerClass ) {
g .Flags .Set (0 )
g .BoostPeer = value
}
func (g *PaymentsGetPremiumGiftCodeOptionsRequest ) GetBoostPeer () (value InputPeerClass , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .BoostPeer , true
}
func (c *Client ) PaymentsGetPremiumGiftCodeOptions (ctx context .Context , request *PaymentsGetPremiumGiftCodeOptionsRequest ) ([]PremiumGiftCodeOption , error ) {
var result PremiumGiftCodeOptionVector
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return []PremiumGiftCodeOption (result .Elems ), nil
}
The pages are generated with Golds v0.6.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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .