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 InputPaymentCredentialsSaved struct {
ID string
TmpPassword []byte
}
const InputPaymentCredentialsSavedTypeID = 0xc10eb2cf
func (i InputPaymentCredentialsSaved ) construct () InputPaymentCredentialsClass { return &i }
var (
_ bin .Encoder = &InputPaymentCredentialsSaved {}
_ bin .Decoder = &InputPaymentCredentialsSaved {}
_ bin .BareEncoder = &InputPaymentCredentialsSaved {}
_ bin .BareDecoder = &InputPaymentCredentialsSaved {}
_ InputPaymentCredentialsClass = &InputPaymentCredentialsSaved {}
)
func (i *InputPaymentCredentialsSaved ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == "" ) {
return false
}
if !(i .TmpPassword == nil ) {
return false
}
return true
}
func (i *InputPaymentCredentialsSaved ) String () string {
if i == nil {
return "InputPaymentCredentialsSaved(nil)"
}
type Alias InputPaymentCredentialsSaved
return fmt .Sprintf ("InputPaymentCredentialsSaved%+v" , Alias (*i ))
}
func (i *InputPaymentCredentialsSaved ) FillFrom (from interface {
GetID () (value string )
GetTmpPassword () (value []byte )
}) {
i .ID = from .GetID ()
i .TmpPassword = from .GetTmpPassword ()
}
func (*InputPaymentCredentialsSaved ) TypeID () uint32 {
return InputPaymentCredentialsSavedTypeID
}
func (*InputPaymentCredentialsSaved ) TypeName () string {
return "inputPaymentCredentialsSaved"
}
func (i *InputPaymentCredentialsSaved ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPaymentCredentialsSaved" ,
ID : InputPaymentCredentialsSavedTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "TmpPassword" ,
SchemaName : "tmp_password" ,
},
}
return typ
}
func (i *InputPaymentCredentialsSaved ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentialsSaved#c10eb2cf as nil" )
}
b .PutID (InputPaymentCredentialsSavedTypeID )
return i .EncodeBare (b )
}
func (i *InputPaymentCredentialsSaved ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentialsSaved#c10eb2cf as nil" )
}
b .PutString (i .ID )
b .PutBytes (i .TmpPassword )
return nil
}
func (i *InputPaymentCredentialsSaved ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentialsSaved#c10eb2cf to nil" )
}
if err := b .ConsumeID (InputPaymentCredentialsSavedTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsSaved#c10eb2cf: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPaymentCredentialsSaved ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentialsSaved#c10eb2cf to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsSaved#c10eb2cf: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsSaved#c10eb2cf: field tmp_password: %w" , err )
}
i .TmpPassword = value
}
return nil
}
func (i *InputPaymentCredentialsSaved ) GetID () (value string ) {
if i == nil {
return
}
return i .ID
}
func (i *InputPaymentCredentialsSaved ) GetTmpPassword () (value []byte ) {
if i == nil {
return
}
return i .TmpPassword
}
type InputPaymentCredentials struct {
Flags bin .Fields
Save bool
Data DataJSON
}
const InputPaymentCredentialsTypeID = 0x3417d728
func (i InputPaymentCredentials ) construct () InputPaymentCredentialsClass { return &i }
var (
_ bin .Encoder = &InputPaymentCredentials {}
_ bin .Decoder = &InputPaymentCredentials {}
_ bin .BareEncoder = &InputPaymentCredentials {}
_ bin .BareDecoder = &InputPaymentCredentials {}
_ InputPaymentCredentialsClass = &InputPaymentCredentials {}
)
func (i *InputPaymentCredentials ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Save == false ) {
return false
}
if !(i .Data .Zero ()) {
return false
}
return true
}
func (i *InputPaymentCredentials ) String () string {
if i == nil {
return "InputPaymentCredentials(nil)"
}
type Alias InputPaymentCredentials
return fmt .Sprintf ("InputPaymentCredentials%+v" , Alias (*i ))
}
func (i *InputPaymentCredentials ) FillFrom (from interface {
GetSave () (value bool )
GetData () (value DataJSON )
}) {
i .Save = from .GetSave ()
i .Data = from .GetData ()
}
func (*InputPaymentCredentials ) TypeID () uint32 {
return InputPaymentCredentialsTypeID
}
func (*InputPaymentCredentials ) TypeName () string {
return "inputPaymentCredentials"
}
func (i *InputPaymentCredentials ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPaymentCredentials" ,
ID : InputPaymentCredentialsTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Save" ,
SchemaName : "save" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "Data" ,
SchemaName : "data" ,
},
}
return typ
}
func (i *InputPaymentCredentials ) SetFlags () {
if !(i .Save == false ) {
i .Flags .Set (0 )
}
}
func (i *InputPaymentCredentials ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentials#3417d728 as nil" )
}
b .PutID (InputPaymentCredentialsTypeID )
return i .EncodeBare (b )
}
func (i *InputPaymentCredentials ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentials#3417d728 as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputPaymentCredentials#3417d728: field flags: %w" , err )
}
if err := i .Data .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputPaymentCredentials#3417d728: field data: %w" , err )
}
return nil
}
func (i *InputPaymentCredentials ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentials#3417d728 to nil" )
}
if err := b .ConsumeID (InputPaymentCredentialsTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentials#3417d728: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPaymentCredentials ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentials#3417d728 to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentials#3417d728: field flags: %w" , err )
}
}
i .Save = i .Flags .Has (0 )
{
if err := i .Data .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentials#3417d728: field data: %w" , err )
}
}
return nil
}
func (i *InputPaymentCredentials ) SetSave (value bool ) {
if value {
i .Flags .Set (0 )
i .Save = true
} else {
i .Flags .Unset (0 )
i .Save = false
}
}
func (i *InputPaymentCredentials ) GetSave () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (0 )
}
func (i *InputPaymentCredentials ) GetData () (value DataJSON ) {
if i == nil {
return
}
return i .Data
}
type InputPaymentCredentialsApplePay struct {
PaymentData DataJSON
}
const InputPaymentCredentialsApplePayTypeID = 0xaa1c39f
func (i InputPaymentCredentialsApplePay ) construct () InputPaymentCredentialsClass { return &i }
var (
_ bin .Encoder = &InputPaymentCredentialsApplePay {}
_ bin .Decoder = &InputPaymentCredentialsApplePay {}
_ bin .BareEncoder = &InputPaymentCredentialsApplePay {}
_ bin .BareDecoder = &InputPaymentCredentialsApplePay {}
_ InputPaymentCredentialsClass = &InputPaymentCredentialsApplePay {}
)
func (i *InputPaymentCredentialsApplePay ) Zero () bool {
if i == nil {
return true
}
if !(i .PaymentData .Zero ()) {
return false
}
return true
}
func (i *InputPaymentCredentialsApplePay ) String () string {
if i == nil {
return "InputPaymentCredentialsApplePay(nil)"
}
type Alias InputPaymentCredentialsApplePay
return fmt .Sprintf ("InputPaymentCredentialsApplePay%+v" , Alias (*i ))
}
func (i *InputPaymentCredentialsApplePay ) FillFrom (from interface {
GetPaymentData () (value DataJSON )
}) {
i .PaymentData = from .GetPaymentData ()
}
func (*InputPaymentCredentialsApplePay ) TypeID () uint32 {
return InputPaymentCredentialsApplePayTypeID
}
func (*InputPaymentCredentialsApplePay ) TypeName () string {
return "inputPaymentCredentialsApplePay"
}
func (i *InputPaymentCredentialsApplePay ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPaymentCredentialsApplePay" ,
ID : InputPaymentCredentialsApplePayTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PaymentData" ,
SchemaName : "payment_data" ,
},
}
return typ
}
func (i *InputPaymentCredentialsApplePay ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentialsApplePay#aa1c39f as nil" )
}
b .PutID (InputPaymentCredentialsApplePayTypeID )
return i .EncodeBare (b )
}
func (i *InputPaymentCredentialsApplePay ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentialsApplePay#aa1c39f as nil" )
}
if err := i .PaymentData .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputPaymentCredentialsApplePay#aa1c39f: field payment_data: %w" , err )
}
return nil
}
func (i *InputPaymentCredentialsApplePay ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentialsApplePay#aa1c39f to nil" )
}
if err := b .ConsumeID (InputPaymentCredentialsApplePayTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsApplePay#aa1c39f: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPaymentCredentialsApplePay ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentialsApplePay#aa1c39f to nil" )
}
{
if err := i .PaymentData .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsApplePay#aa1c39f: field payment_data: %w" , err )
}
}
return nil
}
func (i *InputPaymentCredentialsApplePay ) GetPaymentData () (value DataJSON ) {
if i == nil {
return
}
return i .PaymentData
}
type InputPaymentCredentialsGooglePay struct {
PaymentToken DataJSON
}
const InputPaymentCredentialsGooglePayTypeID = 0x8ac32801
func (i InputPaymentCredentialsGooglePay ) construct () InputPaymentCredentialsClass { return &i }
var (
_ bin .Encoder = &InputPaymentCredentialsGooglePay {}
_ bin .Decoder = &InputPaymentCredentialsGooglePay {}
_ bin .BareEncoder = &InputPaymentCredentialsGooglePay {}
_ bin .BareDecoder = &InputPaymentCredentialsGooglePay {}
_ InputPaymentCredentialsClass = &InputPaymentCredentialsGooglePay {}
)
func (i *InputPaymentCredentialsGooglePay ) Zero () bool {
if i == nil {
return true
}
if !(i .PaymentToken .Zero ()) {
return false
}
return true
}
func (i *InputPaymentCredentialsGooglePay ) String () string {
if i == nil {
return "InputPaymentCredentialsGooglePay(nil)"
}
type Alias InputPaymentCredentialsGooglePay
return fmt .Sprintf ("InputPaymentCredentialsGooglePay%+v" , Alias (*i ))
}
func (i *InputPaymentCredentialsGooglePay ) FillFrom (from interface {
GetPaymentToken () (value DataJSON )
}) {
i .PaymentToken = from .GetPaymentToken ()
}
func (*InputPaymentCredentialsGooglePay ) TypeID () uint32 {
return InputPaymentCredentialsGooglePayTypeID
}
func (*InputPaymentCredentialsGooglePay ) TypeName () string {
return "inputPaymentCredentialsGooglePay"
}
func (i *InputPaymentCredentialsGooglePay ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPaymentCredentialsGooglePay" ,
ID : InputPaymentCredentialsGooglePayTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PaymentToken" ,
SchemaName : "payment_token" ,
},
}
return typ
}
func (i *InputPaymentCredentialsGooglePay ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentialsGooglePay#8ac32801 as nil" )
}
b .PutID (InputPaymentCredentialsGooglePayTypeID )
return i .EncodeBare (b )
}
func (i *InputPaymentCredentialsGooglePay ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPaymentCredentialsGooglePay#8ac32801 as nil" )
}
if err := i .PaymentToken .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputPaymentCredentialsGooglePay#8ac32801: field payment_token: %w" , err )
}
return nil
}
func (i *InputPaymentCredentialsGooglePay ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentialsGooglePay#8ac32801 to nil" )
}
if err := b .ConsumeID (InputPaymentCredentialsGooglePayTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsGooglePay#8ac32801: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPaymentCredentialsGooglePay ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPaymentCredentialsGooglePay#8ac32801 to nil" )
}
{
if err := i .PaymentToken .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputPaymentCredentialsGooglePay#8ac32801: field payment_token: %w" , err )
}
}
return nil
}
func (i *InputPaymentCredentialsGooglePay ) GetPaymentToken () (value DataJSON ) {
if i == nil {
return
}
return i .PaymentToken
}
const InputPaymentCredentialsClassName = "InputPaymentCredentials"
type InputPaymentCredentialsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputPaymentCredentialsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputPaymentCredentials (buf *bin .Buffer ) (InputPaymentCredentialsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputPaymentCredentialsSavedTypeID :
v := InputPaymentCredentialsSaved {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputPaymentCredentialsClass: %w" , err )
}
return &v , nil
case InputPaymentCredentialsTypeID :
v := InputPaymentCredentials {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputPaymentCredentialsClass: %w" , err )
}
return &v , nil
case InputPaymentCredentialsApplePayTypeID :
v := InputPaymentCredentialsApplePay {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputPaymentCredentialsClass: %w" , err )
}
return &v , nil
case InputPaymentCredentialsGooglePayTypeID :
v := InputPaymentCredentialsGooglePay {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputPaymentCredentialsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputPaymentCredentialsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputPaymentCredentialsBox struct {
InputPaymentCredentials InputPaymentCredentialsClass
}
func (b *InputPaymentCredentialsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputPaymentCredentialsBox to nil" )
}
v , err := DecodeInputPaymentCredentials (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputPaymentCredentials = v
return nil
}
func (b *InputPaymentCredentialsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputPaymentCredentials == nil {
return fmt .Errorf ("unable to encode InputPaymentCredentialsClass as nil" )
}
return b .InputPaymentCredentials .Encode (buf )
}
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 .