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 PaymentsSendPaymentFormRequest struct {
Flags bin .Fields
FormID int64
Invoice InputInvoiceClass
RequestedInfoID string
ShippingOptionID string
Credentials InputPaymentCredentialsClass
TipAmount int64
}
const PaymentsSendPaymentFormRequestTypeID = 0x2d03522f
var (
_ bin .Encoder = &PaymentsSendPaymentFormRequest {}
_ bin .Decoder = &PaymentsSendPaymentFormRequest {}
_ bin .BareEncoder = &PaymentsSendPaymentFormRequest {}
_ bin .BareDecoder = &PaymentsSendPaymentFormRequest {}
)
func (s *PaymentsSendPaymentFormRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .FormID == 0 ) {
return false
}
if !(s .Invoice == nil ) {
return false
}
if !(s .RequestedInfoID == "" ) {
return false
}
if !(s .ShippingOptionID == "" ) {
return false
}
if !(s .Credentials == nil ) {
return false
}
if !(s .TipAmount == 0 ) {
return false
}
return true
}
func (s *PaymentsSendPaymentFormRequest ) String () string {
if s == nil {
return "PaymentsSendPaymentFormRequest(nil)"
}
type Alias PaymentsSendPaymentFormRequest
return fmt .Sprintf ("PaymentsSendPaymentFormRequest%+v" , Alias (*s ))
}
func (s *PaymentsSendPaymentFormRequest ) FillFrom (from interface {
GetFormID () (value int64 )
GetInvoice () (value InputInvoiceClass )
GetRequestedInfoID () (value string , ok bool )
GetShippingOptionID () (value string , ok bool )
GetCredentials () (value InputPaymentCredentialsClass )
GetTipAmount () (value int64 , ok bool )
}) {
s .FormID = from .GetFormID ()
s .Invoice = from .GetInvoice ()
if val , ok := from .GetRequestedInfoID (); ok {
s .RequestedInfoID = val
}
if val , ok := from .GetShippingOptionID (); ok {
s .ShippingOptionID = val
}
s .Credentials = from .GetCredentials ()
if val , ok := from .GetTipAmount (); ok {
s .TipAmount = val
}
}
func (*PaymentsSendPaymentFormRequest ) TypeID () uint32 {
return PaymentsSendPaymentFormRequestTypeID
}
func (*PaymentsSendPaymentFormRequest ) TypeName () string {
return "payments.sendPaymentForm"
}
func (s *PaymentsSendPaymentFormRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.sendPaymentForm" ,
ID : PaymentsSendPaymentFormRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "FormID" ,
SchemaName : "form_id" ,
},
{
Name : "Invoice" ,
SchemaName : "invoice" ,
},
{
Name : "RequestedInfoID" ,
SchemaName : "requested_info_id" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "ShippingOptionID" ,
SchemaName : "shipping_option_id" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Credentials" ,
SchemaName : "credentials" ,
},
{
Name : "TipAmount" ,
SchemaName : "tip_amount" ,
Null : !s .Flags .Has (2 ),
},
}
return typ
}
func (s *PaymentsSendPaymentFormRequest ) SetFlags () {
if !(s .RequestedInfoID == "" ) {
s .Flags .Set (0 )
}
if !(s .ShippingOptionID == "" ) {
s .Flags .Set (1 )
}
if !(s .TipAmount == 0 ) {
s .Flags .Set (2 )
}
}
func (s *PaymentsSendPaymentFormRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.sendPaymentForm#2d03522f as nil" )
}
b .PutID (PaymentsSendPaymentFormRequestTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsSendPaymentFormRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.sendPaymentForm#2d03522f as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.sendPaymentForm#2d03522f: field flags: %w" , err )
}
b .PutLong (s .FormID )
if s .Invoice == nil {
return fmt .Errorf ("unable to encode payments.sendPaymentForm#2d03522f: field invoice is nil" )
}
if err := s .Invoice .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.sendPaymentForm#2d03522f: field invoice: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutString (s .RequestedInfoID )
}
if s .Flags .Has (1 ) {
b .PutString (s .ShippingOptionID )
}
if s .Credentials == nil {
return fmt .Errorf ("unable to encode payments.sendPaymentForm#2d03522f: field credentials is nil" )
}
if err := s .Credentials .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.sendPaymentForm#2d03522f: field credentials: %w" , err )
}
if s .Flags .Has (2 ) {
b .PutLong (s .TipAmount )
}
return nil
}
func (s *PaymentsSendPaymentFormRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.sendPaymentForm#2d03522f to nil" )
}
if err := b .ConsumeID (PaymentsSendPaymentFormRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsSendPaymentFormRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.sendPaymentForm#2d03522f to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field form_id: %w" , err )
}
s .FormID = value
}
{
value , err := DecodeInputInvoice (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field invoice: %w" , err )
}
s .Invoice = value
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field requested_info_id: %w" , err )
}
s .RequestedInfoID = value
}
if s .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field shipping_option_id: %w" , err )
}
s .ShippingOptionID = value
}
{
value , err := DecodeInputPaymentCredentials (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field credentials: %w" , err )
}
s .Credentials = value
}
if s .Flags .Has (2 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.sendPaymentForm#2d03522f: field tip_amount: %w" , err )
}
s .TipAmount = value
}
return nil
}
func (s *PaymentsSendPaymentFormRequest ) GetFormID () (value int64 ) {
if s == nil {
return
}
return s .FormID
}
func (s *PaymentsSendPaymentFormRequest ) GetInvoice () (value InputInvoiceClass ) {
if s == nil {
return
}
return s .Invoice
}
func (s *PaymentsSendPaymentFormRequest ) SetRequestedInfoID (value string ) {
s .Flags .Set (0 )
s .RequestedInfoID = value
}
func (s *PaymentsSendPaymentFormRequest ) GetRequestedInfoID () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .RequestedInfoID , true
}
func (s *PaymentsSendPaymentFormRequest ) SetShippingOptionID (value string ) {
s .Flags .Set (1 )
s .ShippingOptionID = value
}
func (s *PaymentsSendPaymentFormRequest ) GetShippingOptionID () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .ShippingOptionID , true
}
func (s *PaymentsSendPaymentFormRequest ) GetCredentials () (value InputPaymentCredentialsClass ) {
if s == nil {
return
}
return s .Credentials
}
func (s *PaymentsSendPaymentFormRequest ) SetTipAmount (value int64 ) {
s .Flags .Set (2 )
s .TipAmount = value
}
func (s *PaymentsSendPaymentFormRequest ) GetTipAmount () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .TipAmount , true
}
func (c *Client ) PaymentsSendPaymentForm (ctx context .Context , request *PaymentsSendPaymentFormRequest ) (PaymentsPaymentResultClass , error ) {
var result PaymentsPaymentResultBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .PaymentResult , 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 .