395 lines
12 KiB
Go
Generated
395 lines
12 KiB
Go
Generated
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
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{}
|
|
)
|
|
|
|
// PaymentsStarGiftCollectionsNotModified represents TL type `payments.starGiftCollectionsNotModified#a0ba4f17`.
|
|
// The list of star gift collections »¹ hasn't changed.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/gifts#gift-collections
|
|
//
|
|
// See https://core.telegram.org/constructor/payments.starGiftCollectionsNotModified for reference.
|
|
type PaymentsStarGiftCollectionsNotModified struct {
|
|
}
|
|
|
|
// PaymentsStarGiftCollectionsNotModifiedTypeID is TL type id of PaymentsStarGiftCollectionsNotModified.
|
|
const PaymentsStarGiftCollectionsNotModifiedTypeID = 0xa0ba4f17
|
|
|
|
// construct implements constructor of PaymentsStarGiftCollectionsClass.
|
|
func (s PaymentsStarGiftCollectionsNotModified) construct() PaymentsStarGiftCollectionsClass {
|
|
return &s
|
|
}
|
|
|
|
// Ensuring interfaces in compile-time for PaymentsStarGiftCollectionsNotModified.
|
|
var (
|
|
_ bin.Encoder = &PaymentsStarGiftCollectionsNotModified{}
|
|
_ bin.Decoder = &PaymentsStarGiftCollectionsNotModified{}
|
|
_ bin.BareEncoder = &PaymentsStarGiftCollectionsNotModified{}
|
|
_ bin.BareDecoder = &PaymentsStarGiftCollectionsNotModified{}
|
|
|
|
_ PaymentsStarGiftCollectionsClass = &PaymentsStarGiftCollectionsNotModified{}
|
|
)
|
|
|
|
func (s *PaymentsStarGiftCollectionsNotModified) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) String() string {
|
|
if s == nil {
|
|
return "PaymentsStarGiftCollectionsNotModified(nil)"
|
|
}
|
|
type Alias PaymentsStarGiftCollectionsNotModified
|
|
return fmt.Sprintf("PaymentsStarGiftCollectionsNotModified%+v", Alias(*s))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PaymentsStarGiftCollectionsNotModified) TypeID() uint32 {
|
|
return PaymentsStarGiftCollectionsNotModifiedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PaymentsStarGiftCollectionsNotModified) TypeName() string {
|
|
return "payments.starGiftCollectionsNotModified"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "payments.starGiftCollectionsNotModified",
|
|
ID: PaymentsStarGiftCollectionsNotModifiedTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode payments.starGiftCollectionsNotModified#a0ba4f17 as nil")
|
|
}
|
|
b.PutID(PaymentsStarGiftCollectionsNotModifiedTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode payments.starGiftCollectionsNotModified#a0ba4f17 as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode payments.starGiftCollectionsNotModified#a0ba4f17 to nil")
|
|
}
|
|
if err := b.ConsumeID(PaymentsStarGiftCollectionsNotModifiedTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode payments.starGiftCollectionsNotModified#a0ba4f17: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode payments.starGiftCollectionsNotModified#a0ba4f17 to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// PaymentsStarGiftCollections represents TL type `payments.starGiftCollections#8a2932f3`.
|
|
// Represents a list of star gift collections »¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/gifts#gift-collections
|
|
//
|
|
// See https://core.telegram.org/constructor/payments.starGiftCollections for reference.
|
|
type PaymentsStarGiftCollections struct {
|
|
// Star gift collections.
|
|
Collections []StarGiftCollection
|
|
}
|
|
|
|
// PaymentsStarGiftCollectionsTypeID is TL type id of PaymentsStarGiftCollections.
|
|
const PaymentsStarGiftCollectionsTypeID = 0x8a2932f3
|
|
|
|
// construct implements constructor of PaymentsStarGiftCollectionsClass.
|
|
func (s PaymentsStarGiftCollections) construct() PaymentsStarGiftCollectionsClass { return &s }
|
|
|
|
// Ensuring interfaces in compile-time for PaymentsStarGiftCollections.
|
|
var (
|
|
_ bin.Encoder = &PaymentsStarGiftCollections{}
|
|
_ bin.Decoder = &PaymentsStarGiftCollections{}
|
|
_ bin.BareEncoder = &PaymentsStarGiftCollections{}
|
|
_ bin.BareDecoder = &PaymentsStarGiftCollections{}
|
|
|
|
_ PaymentsStarGiftCollectionsClass = &PaymentsStarGiftCollections{}
|
|
)
|
|
|
|
func (s *PaymentsStarGiftCollections) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.Collections == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *PaymentsStarGiftCollections) String() string {
|
|
if s == nil {
|
|
return "PaymentsStarGiftCollections(nil)"
|
|
}
|
|
type Alias PaymentsStarGiftCollections
|
|
return fmt.Sprintf("PaymentsStarGiftCollections%+v", Alias(*s))
|
|
}
|
|
|
|
// FillFrom fills PaymentsStarGiftCollections from given interface.
|
|
func (s *PaymentsStarGiftCollections) FillFrom(from interface {
|
|
GetCollections() (value []StarGiftCollection)
|
|
}) {
|
|
s.Collections = from.GetCollections()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PaymentsStarGiftCollections) TypeID() uint32 {
|
|
return PaymentsStarGiftCollectionsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PaymentsStarGiftCollections) TypeName() string {
|
|
return "payments.starGiftCollections"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *PaymentsStarGiftCollections) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "payments.starGiftCollections",
|
|
ID: PaymentsStarGiftCollectionsTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Collections",
|
|
SchemaName: "collections",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *PaymentsStarGiftCollections) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode payments.starGiftCollections#8a2932f3 as nil")
|
|
}
|
|
b.PutID(PaymentsStarGiftCollectionsTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *PaymentsStarGiftCollections) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode payments.starGiftCollections#8a2932f3 as nil")
|
|
}
|
|
b.PutVectorHeader(len(s.Collections))
|
|
for idx, v := range s.Collections {
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode payments.starGiftCollections#8a2932f3: field collections element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *PaymentsStarGiftCollections) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode payments.starGiftCollections#8a2932f3 to nil")
|
|
}
|
|
if err := b.ConsumeID(PaymentsStarGiftCollectionsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode payments.starGiftCollections#8a2932f3: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *PaymentsStarGiftCollections) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode payments.starGiftCollections#8a2932f3 to nil")
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode payments.starGiftCollections#8a2932f3: field collections: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
s.Collections = make([]StarGiftCollection, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value StarGiftCollection
|
|
if err := value.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode payments.starGiftCollections#8a2932f3: field collections: %w", err)
|
|
}
|
|
s.Collections = append(s.Collections, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetCollections returns value of Collections field.
|
|
func (s *PaymentsStarGiftCollections) GetCollections() (value []StarGiftCollection) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Collections
|
|
}
|
|
|
|
// PaymentsStarGiftCollectionsClassName is schema name of PaymentsStarGiftCollectionsClass.
|
|
const PaymentsStarGiftCollectionsClassName = "payments.StarGiftCollections"
|
|
|
|
// PaymentsStarGiftCollectionsClass represents payments.StarGiftCollections generic type.
|
|
//
|
|
// See https://core.telegram.org/type/payments.StarGiftCollections for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodePaymentsStarGiftCollections(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.PaymentsStarGiftCollectionsNotModified: // payments.starGiftCollectionsNotModified#a0ba4f17
|
|
// case *tg.PaymentsStarGiftCollections: // payments.starGiftCollections#8a2932f3
|
|
// default: panic(v)
|
|
// }
|
|
type PaymentsStarGiftCollectionsClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() PaymentsStarGiftCollectionsClass
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
TypeID() uint32
|
|
// TypeName returns name of type in TL schema.
|
|
TypeName() string
|
|
// String implements fmt.Stringer.
|
|
String() string
|
|
// Zero returns true if current object has a zero value.
|
|
Zero() bool
|
|
|
|
// AsModified tries to map PaymentsStarGiftCollectionsClass to PaymentsStarGiftCollections.
|
|
AsModified() (*PaymentsStarGiftCollections, bool)
|
|
}
|
|
|
|
// AsModified tries to map PaymentsStarGiftCollectionsNotModified to PaymentsStarGiftCollections.
|
|
func (s *PaymentsStarGiftCollectionsNotModified) AsModified() (*PaymentsStarGiftCollections, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AsModified tries to map PaymentsStarGiftCollections to PaymentsStarGiftCollections.
|
|
func (s *PaymentsStarGiftCollections) AsModified() (*PaymentsStarGiftCollections, bool) {
|
|
return s, true
|
|
}
|
|
|
|
// DecodePaymentsStarGiftCollections implements binary de-serialization for PaymentsStarGiftCollectionsClass.
|
|
func DecodePaymentsStarGiftCollections(buf *bin.Buffer) (PaymentsStarGiftCollectionsClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case PaymentsStarGiftCollectionsNotModifiedTypeID:
|
|
// Decoding payments.starGiftCollectionsNotModified#a0ba4f17.
|
|
v := PaymentsStarGiftCollectionsNotModified{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PaymentsStarGiftCollectionsClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PaymentsStarGiftCollectionsTypeID:
|
|
// Decoding payments.starGiftCollections#8a2932f3.
|
|
v := PaymentsStarGiftCollections{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PaymentsStarGiftCollectionsClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode PaymentsStarGiftCollectionsClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// PaymentsStarGiftCollections boxes the PaymentsStarGiftCollectionsClass providing a helper.
|
|
type PaymentsStarGiftCollectionsBox struct {
|
|
StarGiftCollections PaymentsStarGiftCollectionsClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for PaymentsStarGiftCollectionsBox.
|
|
func (b *PaymentsStarGiftCollectionsBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode PaymentsStarGiftCollectionsBox to nil")
|
|
}
|
|
v, err := DecodePaymentsStarGiftCollections(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.StarGiftCollections = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for PaymentsStarGiftCollectionsBox.
|
|
func (b *PaymentsStarGiftCollectionsBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.StarGiftCollections == nil {
|
|
return fmt.Errorf("unable to encode PaymentsStarGiftCollectionsClass as nil")
|
|
}
|
|
return b.StarGiftCollections.Encode(buf)
|
|
}
|