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 PaymentsValidatedRequestedInfo struct {
Flags bin .Fields
ID string
ShippingOptions []ShippingOption
}
const PaymentsValidatedRequestedInfoTypeID = 0xd1451883
var (
_ bin .Encoder = &PaymentsValidatedRequestedInfo {}
_ bin .Decoder = &PaymentsValidatedRequestedInfo {}
_ bin .BareEncoder = &PaymentsValidatedRequestedInfo {}
_ bin .BareDecoder = &PaymentsValidatedRequestedInfo {}
)
func (v *PaymentsValidatedRequestedInfo ) Zero () bool {
if v == nil {
return true
}
if !(v .Flags .Zero ()) {
return false
}
if !(v .ID == "" ) {
return false
}
if !(v .ShippingOptions == nil ) {
return false
}
return true
}
func (v *PaymentsValidatedRequestedInfo ) String () string {
if v == nil {
return "PaymentsValidatedRequestedInfo(nil)"
}
type Alias PaymentsValidatedRequestedInfo
return fmt .Sprintf ("PaymentsValidatedRequestedInfo%+v" , Alias (*v ))
}
func (v *PaymentsValidatedRequestedInfo ) FillFrom (from interface {
GetID () (value string , ok bool )
GetShippingOptions () (value []ShippingOption , ok bool )
}) {
if val , ok := from .GetID (); ok {
v .ID = val
}
if val , ok := from .GetShippingOptions (); ok {
v .ShippingOptions = val
}
}
func (*PaymentsValidatedRequestedInfo ) TypeID () uint32 {
return PaymentsValidatedRequestedInfoTypeID
}
func (*PaymentsValidatedRequestedInfo ) TypeName () string {
return "payments.validatedRequestedInfo"
}
func (v *PaymentsValidatedRequestedInfo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.validatedRequestedInfo" ,
ID : PaymentsValidatedRequestedInfoTypeID ,
}
if v == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
Null : !v .Flags .Has (0 ),
},
{
Name : "ShippingOptions" ,
SchemaName : "shipping_options" ,
Null : !v .Flags .Has (1 ),
},
}
return typ
}
func (v *PaymentsValidatedRequestedInfo ) SetFlags () {
if !(v .ID == "" ) {
v .Flags .Set (0 )
}
if !(v .ShippingOptions == nil ) {
v .Flags .Set (1 )
}
}
func (v *PaymentsValidatedRequestedInfo ) Encode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode payments.validatedRequestedInfo#d1451883 as nil" )
}
b .PutID (PaymentsValidatedRequestedInfoTypeID )
return v .EncodeBare (b )
}
func (v *PaymentsValidatedRequestedInfo ) EncodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode payments.validatedRequestedInfo#d1451883 as nil" )
}
v .SetFlags ()
if err := v .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.validatedRequestedInfo#d1451883: field flags: %w" , err )
}
if v .Flags .Has (0 ) {
b .PutString (v .ID )
}
if v .Flags .Has (1 ) {
b .PutVectorHeader (len (v .ShippingOptions ))
for idx , v := range v .ShippingOptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.validatedRequestedInfo#d1451883: field shipping_options element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (v *PaymentsValidatedRequestedInfo ) Decode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode payments.validatedRequestedInfo#d1451883 to nil" )
}
if err := b .ConsumeID (PaymentsValidatedRequestedInfoTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.validatedRequestedInfo#d1451883: %w" , err )
}
return v .DecodeBare (b )
}
func (v *PaymentsValidatedRequestedInfo ) DecodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode payments.validatedRequestedInfo#d1451883 to nil" )
}
{
if err := v .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.validatedRequestedInfo#d1451883: field flags: %w" , err )
}
}
if v .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.validatedRequestedInfo#d1451883: field id: %w" , err )
}
v .ID = value
}
if v .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.validatedRequestedInfo#d1451883: field shipping_options: %w" , err )
}
if headerLen > 0 {
v .ShippingOptions = make ([]ShippingOption , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value ShippingOption
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.validatedRequestedInfo#d1451883: field shipping_options: %w" , err )
}
v .ShippingOptions = append (v .ShippingOptions , value )
}
}
return nil
}
func (v *PaymentsValidatedRequestedInfo ) SetID (value string ) {
v .Flags .Set (0 )
v .ID = value
}
func (v *PaymentsValidatedRequestedInfo ) GetID () (value string , ok bool ) {
if v == nil {
return
}
if !v .Flags .Has (0 ) {
return value , false
}
return v .ID , true
}
func (v *PaymentsValidatedRequestedInfo ) SetShippingOptions (value []ShippingOption ) {
v .Flags .Set (1 )
v .ShippingOptions = value
}
func (v *PaymentsValidatedRequestedInfo ) GetShippingOptions () (value []ShippingOption , ok bool ) {
if v == nil {
return
}
if !v .Flags .Has (1 ) {
return value , false
}
return v .ShippingOptions , true
}
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 .