move gotd fork into repo. (#111)
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tdapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/multierr"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
||||
)
|
||||
|
||||
// No-op definition for keeping imports.
|
||||
var (
|
||||
_ = bin.Buffer{}
|
||||
_ = context.Background()
|
||||
_ = fmt.Stringer(nil)
|
||||
_ = strings.Builder{}
|
||||
_ = errors.Is
|
||||
_ = multierr.AppendInto
|
||||
_ = sort.Ints
|
||||
_ = tdp.Format
|
||||
_ = tgerr.Error{}
|
||||
_ = tdjson.Encoder{}
|
||||
)
|
||||
|
||||
// GetPaymentFormRequest represents TL type `getPaymentForm#8d4f76d4`.
|
||||
type GetPaymentFormRequest struct {
|
||||
// The invoice
|
||||
InputInvoice InputInvoiceClass
|
||||
// Preferred payment form theme; pass null to use the default theme
|
||||
Theme ThemeParameters
|
||||
}
|
||||
|
||||
// GetPaymentFormRequestTypeID is TL type id of GetPaymentFormRequest.
|
||||
const GetPaymentFormRequestTypeID = 0x8d4f76d4
|
||||
|
||||
// Ensuring interfaces in compile-time for GetPaymentFormRequest.
|
||||
var (
|
||||
_ bin.Encoder = &GetPaymentFormRequest{}
|
||||
_ bin.Decoder = &GetPaymentFormRequest{}
|
||||
_ bin.BareEncoder = &GetPaymentFormRequest{}
|
||||
_ bin.BareDecoder = &GetPaymentFormRequest{}
|
||||
)
|
||||
|
||||
func (g *GetPaymentFormRequest) Zero() bool {
|
||||
if g == nil {
|
||||
return true
|
||||
}
|
||||
if !(g.InputInvoice == nil) {
|
||||
return false
|
||||
}
|
||||
if !(g.Theme.Zero()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (g *GetPaymentFormRequest) String() string {
|
||||
if g == nil {
|
||||
return "GetPaymentFormRequest(nil)"
|
||||
}
|
||||
type Alias GetPaymentFormRequest
|
||||
return fmt.Sprintf("GetPaymentFormRequest%+v", Alias(*g))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*GetPaymentFormRequest) TypeID() uint32 {
|
||||
return GetPaymentFormRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*GetPaymentFormRequest) TypeName() string {
|
||||
return "getPaymentForm"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (g *GetPaymentFormRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "getPaymentForm",
|
||||
ID: GetPaymentFormRequestTypeID,
|
||||
}
|
||||
if g == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "InputInvoice",
|
||||
SchemaName: "input_invoice",
|
||||
},
|
||||
{
|
||||
Name: "Theme",
|
||||
SchemaName: "theme",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (g *GetPaymentFormRequest) Encode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode getPaymentForm#8d4f76d4 as nil")
|
||||
}
|
||||
b.PutID(GetPaymentFormRequestTypeID)
|
||||
return g.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (g *GetPaymentFormRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode getPaymentForm#8d4f76d4 as nil")
|
||||
}
|
||||
if g.InputInvoice == nil {
|
||||
return fmt.Errorf("unable to encode getPaymentForm#8d4f76d4: field input_invoice is nil")
|
||||
}
|
||||
if err := g.InputInvoice.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode getPaymentForm#8d4f76d4: field input_invoice: %w", err)
|
||||
}
|
||||
if err := g.Theme.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode getPaymentForm#8d4f76d4: field theme: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (g *GetPaymentFormRequest) Decode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode getPaymentForm#8d4f76d4 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(GetPaymentFormRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode getPaymentForm#8d4f76d4: %w", err)
|
||||
}
|
||||
return g.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (g *GetPaymentFormRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode getPaymentForm#8d4f76d4 to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputInvoice(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode getPaymentForm#8d4f76d4: field input_invoice: %w", err)
|
||||
}
|
||||
g.InputInvoice = value
|
||||
}
|
||||
{
|
||||
if err := g.Theme.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode getPaymentForm#8d4f76d4: field theme: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (g *GetPaymentFormRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode getPaymentForm#8d4f76d4 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("getPaymentForm")
|
||||
b.Comma()
|
||||
b.FieldStart("input_invoice")
|
||||
if g.InputInvoice == nil {
|
||||
return fmt.Errorf("unable to encode getPaymentForm#8d4f76d4: field input_invoice is nil")
|
||||
}
|
||||
if err := g.InputInvoice.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode getPaymentForm#8d4f76d4: field input_invoice: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.FieldStart("theme")
|
||||
if err := g.Theme.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode getPaymentForm#8d4f76d4: field theme: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (g *GetPaymentFormRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode getPaymentForm#8d4f76d4 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("getPaymentForm"); err != nil {
|
||||
return fmt.Errorf("unable to decode getPaymentForm#8d4f76d4: %w", err)
|
||||
}
|
||||
case "input_invoice":
|
||||
value, err := DecodeTDLibJSONInputInvoice(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode getPaymentForm#8d4f76d4: field input_invoice: %w", err)
|
||||
}
|
||||
g.InputInvoice = value
|
||||
case "theme":
|
||||
if err := g.Theme.DecodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to decode getPaymentForm#8d4f76d4: field theme: %w", err)
|
||||
}
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetInputInvoice returns value of InputInvoice field.
|
||||
func (g *GetPaymentFormRequest) GetInputInvoice() (value InputInvoiceClass) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.InputInvoice
|
||||
}
|
||||
|
||||
// GetTheme returns value of Theme field.
|
||||
func (g *GetPaymentFormRequest) GetTheme() (value ThemeParameters) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.Theme
|
||||
}
|
||||
|
||||
// GetPaymentForm invokes method getPaymentForm#8d4f76d4 returning error if any.
|
||||
func (c *Client) GetPaymentForm(ctx context.Context, request *GetPaymentFormRequest) (*PaymentForm, error) {
|
||||
var result PaymentForm
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user