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