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 PaymentRequestedInfo struct {
Flags bin .Fields
Name string
Phone string
Email string
ShippingAddress PostAddress
}
const PaymentRequestedInfoTypeID = 0x909c3f94
var (
_ bin .Encoder = &PaymentRequestedInfo {}
_ bin .Decoder = &PaymentRequestedInfo {}
_ bin .BareEncoder = &PaymentRequestedInfo {}
_ bin .BareDecoder = &PaymentRequestedInfo {}
)
func (p *PaymentRequestedInfo ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Name == "" ) {
return false
}
if !(p .Phone == "" ) {
return false
}
if !(p .Email == "" ) {
return false
}
if !(p .ShippingAddress .Zero ()) {
return false
}
return true
}
func (p *PaymentRequestedInfo ) String () string {
if p == nil {
return "PaymentRequestedInfo(nil)"
}
type Alias PaymentRequestedInfo
return fmt .Sprintf ("PaymentRequestedInfo%+v" , Alias (*p ))
}
func (p *PaymentRequestedInfo ) FillFrom (from interface {
GetName () (value string , ok bool )
GetPhone () (value string , ok bool )
GetEmail () (value string , ok bool )
GetShippingAddress () (value PostAddress , ok bool )
}) {
if val , ok := from .GetName (); ok {
p .Name = val
}
if val , ok := from .GetPhone (); ok {
p .Phone = val
}
if val , ok := from .GetEmail (); ok {
p .Email = val
}
if val , ok := from .GetShippingAddress (); ok {
p .ShippingAddress = val
}
}
func (*PaymentRequestedInfo ) TypeID () uint32 {
return PaymentRequestedInfoTypeID
}
func (*PaymentRequestedInfo ) TypeName () string {
return "paymentRequestedInfo"
}
func (p *PaymentRequestedInfo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "paymentRequestedInfo" ,
ID : PaymentRequestedInfoTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Name" ,
SchemaName : "name" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "Phone" ,
SchemaName : "phone" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "Email" ,
SchemaName : "email" ,
Null : !p .Flags .Has (2 ),
},
{
Name : "ShippingAddress" ,
SchemaName : "shipping_address" ,
Null : !p .Flags .Has (3 ),
},
}
return typ
}
func (p *PaymentRequestedInfo ) SetFlags () {
if !(p .Name == "" ) {
p .Flags .Set (0 )
}
if !(p .Phone == "" ) {
p .Flags .Set (1 )
}
if !(p .Email == "" ) {
p .Flags .Set (2 )
}
if !(p .ShippingAddress .Zero ()) {
p .Flags .Set (3 )
}
}
func (p *PaymentRequestedInfo ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode paymentRequestedInfo#909c3f94 as nil" )
}
b .PutID (PaymentRequestedInfoTypeID )
return p .EncodeBare (b )
}
func (p *PaymentRequestedInfo ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode paymentRequestedInfo#909c3f94 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode paymentRequestedInfo#909c3f94: field flags: %w" , err )
}
if p .Flags .Has (0 ) {
b .PutString (p .Name )
}
if p .Flags .Has (1 ) {
b .PutString (p .Phone )
}
if p .Flags .Has (2 ) {
b .PutString (p .Email )
}
if p .Flags .Has (3 ) {
if err := p .ShippingAddress .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode paymentRequestedInfo#909c3f94: field shipping_address: %w" , err )
}
}
return nil
}
func (p *PaymentRequestedInfo ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode paymentRequestedInfo#909c3f94 to nil" )
}
if err := b .ConsumeID (PaymentRequestedInfoTypeID ); err != nil {
return fmt .Errorf ("unable to decode paymentRequestedInfo#909c3f94: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PaymentRequestedInfo ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode paymentRequestedInfo#909c3f94 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode paymentRequestedInfo#909c3f94: field flags: %w" , err )
}
}
if p .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode paymentRequestedInfo#909c3f94: field name: %w" , err )
}
p .Name = value
}
if p .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode paymentRequestedInfo#909c3f94: field phone: %w" , err )
}
p .Phone = value
}
if p .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode paymentRequestedInfo#909c3f94: field email: %w" , err )
}
p .Email = value
}
if p .Flags .Has (3 ) {
if err := p .ShippingAddress .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode paymentRequestedInfo#909c3f94: field shipping_address: %w" , err )
}
}
return nil
}
func (p *PaymentRequestedInfo ) SetName (value string ) {
p .Flags .Set (0 )
p .Name = value
}
func (p *PaymentRequestedInfo ) GetName () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .Name , true
}
func (p *PaymentRequestedInfo ) SetPhone (value string ) {
p .Flags .Set (1 )
p .Phone = value
}
func (p *PaymentRequestedInfo ) GetPhone () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .Phone , true
}
func (p *PaymentRequestedInfo ) SetEmail (value string ) {
p .Flags .Set (2 )
p .Email = value
}
func (p *PaymentRequestedInfo ) GetEmail () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (2 ) {
return value , false
}
return p .Email , true
}
func (p *PaymentRequestedInfo ) SetShippingAddress (value PostAddress ) {
p .Flags .Set (3 )
p .ShippingAddress = value
}
func (p *PaymentRequestedInfo ) GetShippingAddress () (value PostAddress , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (3 ) {
return value , false
}
return p .ShippingAddress , 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 .