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 PaymentsPaymentForm struct {
Flags bin .Fields
CanSaveCredentials bool
PasswordMissing bool
FormID int64
BotID int64
Title string
Description string
Photo WebDocumentClass
Invoice Invoice
ProviderID int64
URL string
NativeProvider string
NativeParams DataJSON
AdditionalMethods []PaymentFormMethod
SavedInfo PaymentRequestedInfo
SavedCredentials []PaymentSavedCredentialsCard
Users []UserClass
}
const PaymentsPaymentFormTypeID = 0xa0058751
var (
_ bin .Encoder = &PaymentsPaymentForm {}
_ bin .Decoder = &PaymentsPaymentForm {}
_ bin .BareEncoder = &PaymentsPaymentForm {}
_ bin .BareDecoder = &PaymentsPaymentForm {}
)
func (p *PaymentsPaymentForm ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .CanSaveCredentials == false ) {
return false
}
if !(p .PasswordMissing == false ) {
return false
}
if !(p .FormID == 0 ) {
return false
}
if !(p .BotID == 0 ) {
return false
}
if !(p .Title == "" ) {
return false
}
if !(p .Description == "" ) {
return false
}
if !(p .Photo == nil ) {
return false
}
if !(p .Invoice .Zero ()) {
return false
}
if !(p .ProviderID == 0 ) {
return false
}
if !(p .URL == "" ) {
return false
}
if !(p .NativeProvider == "" ) {
return false
}
if !(p .NativeParams .Zero ()) {
return false
}
if !(p .AdditionalMethods == nil ) {
return false
}
if !(p .SavedInfo .Zero ()) {
return false
}
if !(p .SavedCredentials == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *PaymentsPaymentForm ) String () string {
if p == nil {
return "PaymentsPaymentForm(nil)"
}
type Alias PaymentsPaymentForm
return fmt .Sprintf ("PaymentsPaymentForm%+v" , Alias (*p ))
}
func (p *PaymentsPaymentForm ) FillFrom (from interface {
GetCanSaveCredentials () (value bool )
GetPasswordMissing () (value bool )
GetFormID () (value int64 )
GetBotID () (value int64 )
GetTitle () (value string )
GetDescription () (value string )
GetPhoto () (value WebDocumentClass , ok bool )
GetInvoice () (value Invoice )
GetProviderID () (value int64 )
GetURL () (value string )
GetNativeProvider () (value string , ok bool )
GetNativeParams () (value DataJSON , ok bool )
GetAdditionalMethods () (value []PaymentFormMethod , ok bool )
GetSavedInfo () (value PaymentRequestedInfo , ok bool )
GetSavedCredentials () (value []PaymentSavedCredentialsCard , ok bool )
GetUsers () (value []UserClass )
}) {
p .CanSaveCredentials = from .GetCanSaveCredentials ()
p .PasswordMissing = from .GetPasswordMissing ()
p .FormID = from .GetFormID ()
p .BotID = from .GetBotID ()
p .Title = from .GetTitle ()
p .Description = from .GetDescription ()
if val , ok := from .GetPhoto (); ok {
p .Photo = val
}
p .Invoice = from .GetInvoice ()
p .ProviderID = from .GetProviderID ()
p .URL = from .GetURL ()
if val , ok := from .GetNativeProvider (); ok {
p .NativeProvider = val
}
if val , ok := from .GetNativeParams (); ok {
p .NativeParams = val
}
if val , ok := from .GetAdditionalMethods (); ok {
p .AdditionalMethods = val
}
if val , ok := from .GetSavedInfo (); ok {
p .SavedInfo = val
}
if val , ok := from .GetSavedCredentials (); ok {
p .SavedCredentials = val
}
p .Users = from .GetUsers ()
}
func (*PaymentsPaymentForm ) TypeID () uint32 {
return PaymentsPaymentFormTypeID
}
func (*PaymentsPaymentForm ) TypeName () string {
return "payments.paymentForm"
}
func (p *PaymentsPaymentForm ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.paymentForm" ,
ID : PaymentsPaymentFormTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CanSaveCredentials" ,
SchemaName : "can_save_credentials" ,
Null : !p .Flags .Has (2 ),
},
{
Name : "PasswordMissing" ,
SchemaName : "password_missing" ,
Null : !p .Flags .Has (3 ),
},
{
Name : "FormID" ,
SchemaName : "form_id" ,
},
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Description" ,
SchemaName : "description" ,
},
{
Name : "Photo" ,
SchemaName : "photo" ,
Null : !p .Flags .Has (5 ),
},
{
Name : "Invoice" ,
SchemaName : "invoice" ,
},
{
Name : "ProviderID" ,
SchemaName : "provider_id" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "NativeProvider" ,
SchemaName : "native_provider" ,
Null : !p .Flags .Has (4 ),
},
{
Name : "NativeParams" ,
SchemaName : "native_params" ,
Null : !p .Flags .Has (4 ),
},
{
Name : "AdditionalMethods" ,
SchemaName : "additional_methods" ,
Null : !p .Flags .Has (6 ),
},
{
Name : "SavedInfo" ,
SchemaName : "saved_info" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "SavedCredentials" ,
SchemaName : "saved_credentials" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *PaymentsPaymentForm ) SetFlags () {
if !(p .CanSaveCredentials == false ) {
p .Flags .Set (2 )
}
if !(p .PasswordMissing == false ) {
p .Flags .Set (3 )
}
if !(p .Photo == nil ) {
p .Flags .Set (5 )
}
if !(p .NativeProvider == "" ) {
p .Flags .Set (4 )
}
if !(p .NativeParams .Zero ()) {
p .Flags .Set (4 )
}
if !(p .AdditionalMethods == nil ) {
p .Flags .Set (6 )
}
if !(p .SavedInfo .Zero ()) {
p .Flags .Set (0 )
}
if !(p .SavedCredentials == nil ) {
p .Flags .Set (1 )
}
}
func (p *PaymentsPaymentForm ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode payments.paymentForm#a0058751 as nil" )
}
b .PutID (PaymentsPaymentFormTypeID )
return p .EncodeBare (b )
}
func (p *PaymentsPaymentForm ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode payments.paymentForm#a0058751 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field flags: %w" , err )
}
b .PutLong (p .FormID )
b .PutLong (p .BotID )
b .PutString (p .Title )
b .PutString (p .Description )
if p .Flags .Has (5 ) {
if p .Photo == nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field photo is nil" )
}
if err := p .Photo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field photo: %w" , err )
}
}
if err := p .Invoice .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field invoice: %w" , err )
}
b .PutLong (p .ProviderID )
b .PutString (p .URL )
if p .Flags .Has (4 ) {
b .PutString (p .NativeProvider )
}
if p .Flags .Has (4 ) {
if err := p .NativeParams .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field native_params: %w" , err )
}
}
if p .Flags .Has (6 ) {
b .PutVectorHeader (len (p .AdditionalMethods ))
for idx , v := range p .AdditionalMethods {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field additional_methods element with index %d: %w" , idx , err )
}
}
}
if p .Flags .Has (0 ) {
if err := p .SavedInfo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field saved_info: %w" , err )
}
}
if p .Flags .Has (1 ) {
b .PutVectorHeader (len (p .SavedCredentials ))
for idx , v := range p .SavedCredentials {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field saved_credentials element with index %d: %w" , idx , err )
}
}
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.paymentForm#a0058751: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *PaymentsPaymentForm ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode payments.paymentForm#a0058751 to nil" )
}
if err := b .ConsumeID (PaymentsPaymentFormTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PaymentsPaymentForm ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode payments.paymentForm#a0058751 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field flags: %w" , err )
}
}
p .CanSaveCredentials = p .Flags .Has (2 )
p .PasswordMissing = p .Flags .Has (3 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field form_id: %w" , err )
}
p .FormID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field bot_id: %w" , err )
}
p .BotID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field title: %w" , err )
}
p .Title = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field description: %w" , err )
}
p .Description = value
}
if p .Flags .Has (5 ) {
value , err := DecodeWebDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field photo: %w" , err )
}
p .Photo = value
}
{
if err := p .Invoice .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field invoice: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field provider_id: %w" , err )
}
p .ProviderID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field url: %w" , err )
}
p .URL = value
}
if p .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field native_provider: %w" , err )
}
p .NativeProvider = value
}
if p .Flags .Has (4 ) {
if err := p .NativeParams .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field native_params: %w" , err )
}
}
if p .Flags .Has (6 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field additional_methods: %w" , err )
}
if headerLen > 0 {
p .AdditionalMethods = make ([]PaymentFormMethod , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PaymentFormMethod
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field additional_methods: %w" , err )
}
p .AdditionalMethods = append (p .AdditionalMethods , value )
}
}
if p .Flags .Has (0 ) {
if err := p .SavedInfo .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field saved_info: %w" , err )
}
}
if p .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field saved_credentials: %w" , err )
}
if headerLen > 0 {
p .SavedCredentials = make ([]PaymentSavedCredentialsCard , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PaymentSavedCredentialsCard
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field saved_credentials: %w" , err )
}
p .SavedCredentials = append (p .SavedCredentials , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field users: %w" , err )
}
if headerLen > 0 {
p .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.paymentForm#a0058751: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *PaymentsPaymentForm ) SetCanSaveCredentials (value bool ) {
if value {
p .Flags .Set (2 )
p .CanSaveCredentials = true
} else {
p .Flags .Unset (2 )
p .CanSaveCredentials = false
}
}
func (p *PaymentsPaymentForm ) GetCanSaveCredentials () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (2 )
}
func (p *PaymentsPaymentForm ) SetPasswordMissing (value bool ) {
if value {
p .Flags .Set (3 )
p .PasswordMissing = true
} else {
p .Flags .Unset (3 )
p .PasswordMissing = false
}
}
func (p *PaymentsPaymentForm ) GetPasswordMissing () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (3 )
}
func (p *PaymentsPaymentForm ) GetFormID () (value int64 ) {
if p == nil {
return
}
return p .FormID
}
func (p *PaymentsPaymentForm ) GetBotID () (value int64 ) {
if p == nil {
return
}
return p .BotID
}
func (p *PaymentsPaymentForm ) GetTitle () (value string ) {
if p == nil {
return
}
return p .Title
}
func (p *PaymentsPaymentForm ) GetDescription () (value string ) {
if p == nil {
return
}
return p .Description
}
func (p *PaymentsPaymentForm ) SetPhoto (value WebDocumentClass ) {
p .Flags .Set (5 )
p .Photo = value
}
func (p *PaymentsPaymentForm ) GetPhoto () (value WebDocumentClass , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (5 ) {
return value , false
}
return p .Photo , true
}
func (p *PaymentsPaymentForm ) GetInvoice () (value Invoice ) {
if p == nil {
return
}
return p .Invoice
}
func (p *PaymentsPaymentForm ) GetProviderID () (value int64 ) {
if p == nil {
return
}
return p .ProviderID
}
func (p *PaymentsPaymentForm ) GetURL () (value string ) {
if p == nil {
return
}
return p .URL
}
func (p *PaymentsPaymentForm ) SetNativeProvider (value string ) {
p .Flags .Set (4 )
p .NativeProvider = value
}
func (p *PaymentsPaymentForm ) GetNativeProvider () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (4 ) {
return value , false
}
return p .NativeProvider , true
}
func (p *PaymentsPaymentForm ) SetNativeParams (value DataJSON ) {
p .Flags .Set (4 )
p .NativeParams = value
}
func (p *PaymentsPaymentForm ) GetNativeParams () (value DataJSON , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (4 ) {
return value , false
}
return p .NativeParams , true
}
func (p *PaymentsPaymentForm ) SetAdditionalMethods (value []PaymentFormMethod ) {
p .Flags .Set (6 )
p .AdditionalMethods = value
}
func (p *PaymentsPaymentForm ) GetAdditionalMethods () (value []PaymentFormMethod , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (6 ) {
return value , false
}
return p .AdditionalMethods , true
}
func (p *PaymentsPaymentForm ) SetSavedInfo (value PaymentRequestedInfo ) {
p .Flags .Set (0 )
p .SavedInfo = value
}
func (p *PaymentsPaymentForm ) GetSavedInfo () (value PaymentRequestedInfo , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .SavedInfo , true
}
func (p *PaymentsPaymentForm ) SetSavedCredentials (value []PaymentSavedCredentialsCard ) {
p .Flags .Set (1 )
p .SavedCredentials = value
}
func (p *PaymentsPaymentForm ) GetSavedCredentials () (value []PaymentSavedCredentialsCard , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .SavedCredentials , true
}
func (p *PaymentsPaymentForm ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *PaymentsPaymentForm ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .Users )
}
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 .