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 PaymentsApplyGiftCodeRequest struct {
Slug string
}
const PaymentsApplyGiftCodeRequestTypeID = 0xf6e26854
var (
_ bin .Encoder = &PaymentsApplyGiftCodeRequest {}
_ bin .Decoder = &PaymentsApplyGiftCodeRequest {}
_ bin .BareEncoder = &PaymentsApplyGiftCodeRequest {}
_ bin .BareDecoder = &PaymentsApplyGiftCodeRequest {}
)
func (a *PaymentsApplyGiftCodeRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .Slug == "" ) {
return false
}
return true
}
func (a *PaymentsApplyGiftCodeRequest ) String () string {
if a == nil {
return "PaymentsApplyGiftCodeRequest(nil)"
}
type Alias PaymentsApplyGiftCodeRequest
return fmt .Sprintf ("PaymentsApplyGiftCodeRequest%+v" , Alias (*a ))
}
func (a *PaymentsApplyGiftCodeRequest ) FillFrom (from interface {
GetSlug () (value string )
}) {
a .Slug = from .GetSlug ()
}
func (*PaymentsApplyGiftCodeRequest ) TypeID () uint32 {
return PaymentsApplyGiftCodeRequestTypeID
}
func (*PaymentsApplyGiftCodeRequest ) TypeName () string {
return "payments.applyGiftCode"
}
func (a *PaymentsApplyGiftCodeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.applyGiftCode" ,
ID : PaymentsApplyGiftCodeRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Slug" ,
SchemaName : "slug" ,
},
}
return typ
}
func (a *PaymentsApplyGiftCodeRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode payments.applyGiftCode#f6e26854 as nil" )
}
b .PutID (PaymentsApplyGiftCodeRequestTypeID )
return a .EncodeBare (b )
}
func (a *PaymentsApplyGiftCodeRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode payments.applyGiftCode#f6e26854 as nil" )
}
b .PutString (a .Slug )
return nil
}
func (a *PaymentsApplyGiftCodeRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode payments.applyGiftCode#f6e26854 to nil" )
}
if err := b .ConsumeID (PaymentsApplyGiftCodeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.applyGiftCode#f6e26854: %w" , err )
}
return a .DecodeBare (b )
}
func (a *PaymentsApplyGiftCodeRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode payments.applyGiftCode#f6e26854 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.applyGiftCode#f6e26854: field slug: %w" , err )
}
a .Slug = value
}
return nil
}
func (a *PaymentsApplyGiftCodeRequest ) GetSlug () (value string ) {
if a == nil {
return
}
return a .Slug
}
func (c *Client ) PaymentsApplyGiftCode (ctx context .Context , slug string ) (UpdatesClass , error ) {
var result UpdatesBox
request := &PaymentsApplyGiftCodeRequest {
Slug : slug ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .