7a04f298d2
- 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
330 lines
7.6 KiB
Go
330 lines
7.6 KiB
Go
// 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{}
|
|
)
|
|
|
|
// StarPaymentOption represents TL type `starPaymentOption#aeb22811`.
|
|
type StarPaymentOption struct {
|
|
// ISO 4217 currency code for the payment
|
|
Currency string
|
|
// The amount to pay, in the smallest units of the currency
|
|
Amount int64
|
|
// Number of Telegram Stars that will be purchased
|
|
StarCount int64
|
|
// Identifier of the store product associated with the option; may be empty if none
|
|
StoreProductID string
|
|
// True, if the option must be shown only in the full list of payment options
|
|
IsAdditional bool
|
|
}
|
|
|
|
// StarPaymentOptionTypeID is TL type id of StarPaymentOption.
|
|
const StarPaymentOptionTypeID = 0xaeb22811
|
|
|
|
// Ensuring interfaces in compile-time for StarPaymentOption.
|
|
var (
|
|
_ bin.Encoder = &StarPaymentOption{}
|
|
_ bin.Decoder = &StarPaymentOption{}
|
|
_ bin.BareEncoder = &StarPaymentOption{}
|
|
_ bin.BareDecoder = &StarPaymentOption{}
|
|
)
|
|
|
|
func (s *StarPaymentOption) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.Currency == "") {
|
|
return false
|
|
}
|
|
if !(s.Amount == 0) {
|
|
return false
|
|
}
|
|
if !(s.StarCount == 0) {
|
|
return false
|
|
}
|
|
if !(s.StoreProductID == "") {
|
|
return false
|
|
}
|
|
if !(s.IsAdditional == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *StarPaymentOption) String() string {
|
|
if s == nil {
|
|
return "StarPaymentOption(nil)"
|
|
}
|
|
type Alias StarPaymentOption
|
|
return fmt.Sprintf("StarPaymentOption%+v", Alias(*s))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StarPaymentOption) TypeID() uint32 {
|
|
return StarPaymentOptionTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StarPaymentOption) TypeName() string {
|
|
return "starPaymentOption"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *StarPaymentOption) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "starPaymentOption",
|
|
ID: StarPaymentOptionTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Currency",
|
|
SchemaName: "currency",
|
|
},
|
|
{
|
|
Name: "Amount",
|
|
SchemaName: "amount",
|
|
},
|
|
{
|
|
Name: "StarCount",
|
|
SchemaName: "star_count",
|
|
},
|
|
{
|
|
Name: "StoreProductID",
|
|
SchemaName: "store_product_id",
|
|
},
|
|
{
|
|
Name: "IsAdditional",
|
|
SchemaName: "is_additional",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *StarPaymentOption) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starPaymentOption#aeb22811 as nil")
|
|
}
|
|
b.PutID(StarPaymentOptionTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *StarPaymentOption) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starPaymentOption#aeb22811 as nil")
|
|
}
|
|
b.PutString(s.Currency)
|
|
b.PutInt53(s.Amount)
|
|
b.PutInt53(s.StarCount)
|
|
b.PutString(s.StoreProductID)
|
|
b.PutBool(s.IsAdditional)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *StarPaymentOption) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starPaymentOption#aeb22811 to nil")
|
|
}
|
|
if err := b.ConsumeID(StarPaymentOptionTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *StarPaymentOption) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starPaymentOption#aeb22811 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field currency: %w", err)
|
|
}
|
|
s.Currency = value
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field amount: %w", err)
|
|
}
|
|
s.Amount = value
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field star_count: %w", err)
|
|
}
|
|
s.StarCount = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field store_product_id: %w", err)
|
|
}
|
|
s.StoreProductID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field is_additional: %w", err)
|
|
}
|
|
s.IsAdditional = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (s *StarPaymentOption) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starPaymentOption#aeb22811 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("starPaymentOption")
|
|
b.Comma()
|
|
b.FieldStart("currency")
|
|
b.PutString(s.Currency)
|
|
b.Comma()
|
|
b.FieldStart("amount")
|
|
b.PutInt53(s.Amount)
|
|
b.Comma()
|
|
b.FieldStart("star_count")
|
|
b.PutInt53(s.StarCount)
|
|
b.Comma()
|
|
b.FieldStart("store_product_id")
|
|
b.PutString(s.StoreProductID)
|
|
b.Comma()
|
|
b.FieldStart("is_additional")
|
|
b.PutBool(s.IsAdditional)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (s *StarPaymentOption) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starPaymentOption#aeb22811 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("starPaymentOption"); err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: %w", err)
|
|
}
|
|
case "currency":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field currency: %w", err)
|
|
}
|
|
s.Currency = value
|
|
case "amount":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field amount: %w", err)
|
|
}
|
|
s.Amount = value
|
|
case "star_count":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field star_count: %w", err)
|
|
}
|
|
s.StarCount = value
|
|
case "store_product_id":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field store_product_id: %w", err)
|
|
}
|
|
s.StoreProductID = value
|
|
case "is_additional":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starPaymentOption#aeb22811: field is_additional: %w", err)
|
|
}
|
|
s.IsAdditional = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetCurrency returns value of Currency field.
|
|
func (s *StarPaymentOption) GetCurrency() (value string) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Currency
|
|
}
|
|
|
|
// GetAmount returns value of Amount field.
|
|
func (s *StarPaymentOption) GetAmount() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Amount
|
|
}
|
|
|
|
// GetStarCount returns value of StarCount field.
|
|
func (s *StarPaymentOption) GetStarCount() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.StarCount
|
|
}
|
|
|
|
// GetStoreProductID returns value of StoreProductID field.
|
|
func (s *StarPaymentOption) GetStoreProductID() (value string) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.StoreProductID
|
|
}
|
|
|
|
// GetIsAdditional returns value of IsAdditional field.
|
|
func (s *StarPaymentOption) GetIsAdditional() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.IsAdditional
|
|
}
|