Files
mautrix-telegram/pkg/gotd/tdapi/tl_paid_media_gen.go
T
2025-06-27 20:03:37 -07:00

999 lines
25 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{}
)
// PaidMediaPreview represents TL type `paidMediaPreview#bcc1c474`.
type PaidMediaPreview struct {
// Media width; 0 if unknown
Width int32
// Media height; 0 if unknown
Height int32
// Media duration, in seconds; 0 if unknown
Duration int32
// Media minithumbnail; may be null
Minithumbnail Minithumbnail
}
// PaidMediaPreviewTypeID is TL type id of PaidMediaPreview.
const PaidMediaPreviewTypeID = 0xbcc1c474
// construct implements constructor of PaidMediaClass.
func (p PaidMediaPreview) construct() PaidMediaClass { return &p }
// Ensuring interfaces in compile-time for PaidMediaPreview.
var (
_ bin.Encoder = &PaidMediaPreview{}
_ bin.Decoder = &PaidMediaPreview{}
_ bin.BareEncoder = &PaidMediaPreview{}
_ bin.BareDecoder = &PaidMediaPreview{}
_ PaidMediaClass = &PaidMediaPreview{}
)
func (p *PaidMediaPreview) Zero() bool {
if p == nil {
return true
}
if !(p.Width == 0) {
return false
}
if !(p.Height == 0) {
return false
}
if !(p.Duration == 0) {
return false
}
if !(p.Minithumbnail.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PaidMediaPreview) String() string {
if p == nil {
return "PaidMediaPreview(nil)"
}
type Alias PaidMediaPreview
return fmt.Sprintf("PaidMediaPreview%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PaidMediaPreview) TypeID() uint32 {
return PaidMediaPreviewTypeID
}
// TypeName returns name of type in TL schema.
func (*PaidMediaPreview) TypeName() string {
return "paidMediaPreview"
}
// TypeInfo returns info about TL type.
func (p *PaidMediaPreview) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "paidMediaPreview",
ID: PaidMediaPreviewTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Width",
SchemaName: "width",
},
{
Name: "Height",
SchemaName: "height",
},
{
Name: "Duration",
SchemaName: "duration",
},
{
Name: "Minithumbnail",
SchemaName: "minithumbnail",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PaidMediaPreview) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaPreview#bcc1c474 as nil")
}
b.PutID(PaidMediaPreviewTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PaidMediaPreview) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaPreview#bcc1c474 as nil")
}
b.PutInt32(p.Width)
b.PutInt32(p.Height)
b.PutInt32(p.Duration)
if err := p.Minithumbnail.Encode(b); err != nil {
return fmt.Errorf("unable to encode paidMediaPreview#bcc1c474: field minithumbnail: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (p *PaidMediaPreview) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaPreview#bcc1c474 to nil")
}
if err := b.ConsumeID(PaidMediaPreviewTypeID); err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PaidMediaPreview) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaPreview#bcc1c474 to nil")
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field width: %w", err)
}
p.Width = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field height: %w", err)
}
p.Height = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field duration: %w", err)
}
p.Duration = value
}
{
if err := p.Minithumbnail.Decode(b); err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field minithumbnail: %w", err)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PaidMediaPreview) EncodeTDLibJSON(b tdjson.Encoder) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaPreview#bcc1c474 as nil")
}
b.ObjStart()
b.PutID("paidMediaPreview")
b.Comma()
b.FieldStart("width")
b.PutInt32(p.Width)
b.Comma()
b.FieldStart("height")
b.PutInt32(p.Height)
b.Comma()
b.FieldStart("duration")
b.PutInt32(p.Duration)
b.Comma()
b.FieldStart("minithumbnail")
if err := p.Minithumbnail.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode paidMediaPreview#bcc1c474: field minithumbnail: %w", err)
}
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PaidMediaPreview) DecodeTDLibJSON(b tdjson.Decoder) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaPreview#bcc1c474 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("paidMediaPreview"); err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: %w", err)
}
case "width":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field width: %w", err)
}
p.Width = value
case "height":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field height: %w", err)
}
p.Height = value
case "duration":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field duration: %w", err)
}
p.Duration = value
case "minithumbnail":
if err := p.Minithumbnail.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode paidMediaPreview#bcc1c474: field minithumbnail: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetWidth returns value of Width field.
func (p *PaidMediaPreview) GetWidth() (value int32) {
if p == nil {
return
}
return p.Width
}
// GetHeight returns value of Height field.
func (p *PaidMediaPreview) GetHeight() (value int32) {
if p == nil {
return
}
return p.Height
}
// GetDuration returns value of Duration field.
func (p *PaidMediaPreview) GetDuration() (value int32) {
if p == nil {
return
}
return p.Duration
}
// GetMinithumbnail returns value of Minithumbnail field.
func (p *PaidMediaPreview) GetMinithumbnail() (value Minithumbnail) {
if p == nil {
return
}
return p.Minithumbnail
}
// PaidMediaPhoto represents TL type `paidMediaPhoto#ba82551a`.
type PaidMediaPhoto struct {
// The photo
Photo Photo
}
// PaidMediaPhotoTypeID is TL type id of PaidMediaPhoto.
const PaidMediaPhotoTypeID = 0xba82551a
// construct implements constructor of PaidMediaClass.
func (p PaidMediaPhoto) construct() PaidMediaClass { return &p }
// Ensuring interfaces in compile-time for PaidMediaPhoto.
var (
_ bin.Encoder = &PaidMediaPhoto{}
_ bin.Decoder = &PaidMediaPhoto{}
_ bin.BareEncoder = &PaidMediaPhoto{}
_ bin.BareDecoder = &PaidMediaPhoto{}
_ PaidMediaClass = &PaidMediaPhoto{}
)
func (p *PaidMediaPhoto) Zero() bool {
if p == nil {
return true
}
if !(p.Photo.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PaidMediaPhoto) String() string {
if p == nil {
return "PaidMediaPhoto(nil)"
}
type Alias PaidMediaPhoto
return fmt.Sprintf("PaidMediaPhoto%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PaidMediaPhoto) TypeID() uint32 {
return PaidMediaPhotoTypeID
}
// TypeName returns name of type in TL schema.
func (*PaidMediaPhoto) TypeName() string {
return "paidMediaPhoto"
}
// TypeInfo returns info about TL type.
func (p *PaidMediaPhoto) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "paidMediaPhoto",
ID: PaidMediaPhotoTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Photo",
SchemaName: "photo",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PaidMediaPhoto) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaPhoto#ba82551a as nil")
}
b.PutID(PaidMediaPhotoTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PaidMediaPhoto) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaPhoto#ba82551a as nil")
}
if err := p.Photo.Encode(b); err != nil {
return fmt.Errorf("unable to encode paidMediaPhoto#ba82551a: field photo: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (p *PaidMediaPhoto) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaPhoto#ba82551a to nil")
}
if err := b.ConsumeID(PaidMediaPhotoTypeID); err != nil {
return fmt.Errorf("unable to decode paidMediaPhoto#ba82551a: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PaidMediaPhoto) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaPhoto#ba82551a to nil")
}
{
if err := p.Photo.Decode(b); err != nil {
return fmt.Errorf("unable to decode paidMediaPhoto#ba82551a: field photo: %w", err)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PaidMediaPhoto) EncodeTDLibJSON(b tdjson.Encoder) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaPhoto#ba82551a as nil")
}
b.ObjStart()
b.PutID("paidMediaPhoto")
b.Comma()
b.FieldStart("photo")
if err := p.Photo.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode paidMediaPhoto#ba82551a: field photo: %w", err)
}
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PaidMediaPhoto) DecodeTDLibJSON(b tdjson.Decoder) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaPhoto#ba82551a to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("paidMediaPhoto"); err != nil {
return fmt.Errorf("unable to decode paidMediaPhoto#ba82551a: %w", err)
}
case "photo":
if err := p.Photo.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode paidMediaPhoto#ba82551a: field photo: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetPhoto returns value of Photo field.
func (p *PaidMediaPhoto) GetPhoto() (value Photo) {
if p == nil {
return
}
return p.Photo
}
// PaidMediaVideo represents TL type `paidMediaVideo#33e7f02e`.
type PaidMediaVideo struct {
// The video
Video Video
// Cover of the video; may be null if none
Cover Photo
// Timestamp from which the video playing must start, in seconds
StartTimestamp int32
}
// PaidMediaVideoTypeID is TL type id of PaidMediaVideo.
const PaidMediaVideoTypeID = 0x33e7f02e
// construct implements constructor of PaidMediaClass.
func (p PaidMediaVideo) construct() PaidMediaClass { return &p }
// Ensuring interfaces in compile-time for PaidMediaVideo.
var (
_ bin.Encoder = &PaidMediaVideo{}
_ bin.Decoder = &PaidMediaVideo{}
_ bin.BareEncoder = &PaidMediaVideo{}
_ bin.BareDecoder = &PaidMediaVideo{}
_ PaidMediaClass = &PaidMediaVideo{}
)
func (p *PaidMediaVideo) Zero() bool {
if p == nil {
return true
}
if !(p.Video.Zero()) {
return false
}
if !(p.Cover.Zero()) {
return false
}
if !(p.StartTimestamp == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PaidMediaVideo) String() string {
if p == nil {
return "PaidMediaVideo(nil)"
}
type Alias PaidMediaVideo
return fmt.Sprintf("PaidMediaVideo%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PaidMediaVideo) TypeID() uint32 {
return PaidMediaVideoTypeID
}
// TypeName returns name of type in TL schema.
func (*PaidMediaVideo) TypeName() string {
return "paidMediaVideo"
}
// TypeInfo returns info about TL type.
func (p *PaidMediaVideo) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "paidMediaVideo",
ID: PaidMediaVideoTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Video",
SchemaName: "video",
},
{
Name: "Cover",
SchemaName: "cover",
},
{
Name: "StartTimestamp",
SchemaName: "start_timestamp",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PaidMediaVideo) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaVideo#33e7f02e as nil")
}
b.PutID(PaidMediaVideoTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PaidMediaVideo) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaVideo#33e7f02e as nil")
}
if err := p.Video.Encode(b); err != nil {
return fmt.Errorf("unable to encode paidMediaVideo#33e7f02e: field video: %w", err)
}
if err := p.Cover.Encode(b); err != nil {
return fmt.Errorf("unable to encode paidMediaVideo#33e7f02e: field cover: %w", err)
}
b.PutInt32(p.StartTimestamp)
return nil
}
// Decode implements bin.Decoder.
func (p *PaidMediaVideo) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaVideo#33e7f02e to nil")
}
if err := b.ConsumeID(PaidMediaVideoTypeID); err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PaidMediaVideo) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaVideo#33e7f02e to nil")
}
{
if err := p.Video.Decode(b); err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: field video: %w", err)
}
}
{
if err := p.Cover.Decode(b); err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: field cover: %w", err)
}
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: field start_timestamp: %w", err)
}
p.StartTimestamp = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PaidMediaVideo) EncodeTDLibJSON(b tdjson.Encoder) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaVideo#33e7f02e as nil")
}
b.ObjStart()
b.PutID("paidMediaVideo")
b.Comma()
b.FieldStart("video")
if err := p.Video.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode paidMediaVideo#33e7f02e: field video: %w", err)
}
b.Comma()
b.FieldStart("cover")
if err := p.Cover.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode paidMediaVideo#33e7f02e: field cover: %w", err)
}
b.Comma()
b.FieldStart("start_timestamp")
b.PutInt32(p.StartTimestamp)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PaidMediaVideo) DecodeTDLibJSON(b tdjson.Decoder) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaVideo#33e7f02e to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("paidMediaVideo"); err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: %w", err)
}
case "video":
if err := p.Video.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: field video: %w", err)
}
case "cover":
if err := p.Cover.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: field cover: %w", err)
}
case "start_timestamp":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode paidMediaVideo#33e7f02e: field start_timestamp: %w", err)
}
p.StartTimestamp = value
default:
return b.Skip()
}
return nil
})
}
// GetVideo returns value of Video field.
func (p *PaidMediaVideo) GetVideo() (value Video) {
if p == nil {
return
}
return p.Video
}
// GetCover returns value of Cover field.
func (p *PaidMediaVideo) GetCover() (value Photo) {
if p == nil {
return
}
return p.Cover
}
// GetStartTimestamp returns value of StartTimestamp field.
func (p *PaidMediaVideo) GetStartTimestamp() (value int32) {
if p == nil {
return
}
return p.StartTimestamp
}
// PaidMediaUnsupported represents TL type `paidMediaUnsupported#6bc3e26`.
type PaidMediaUnsupported struct {
}
// PaidMediaUnsupportedTypeID is TL type id of PaidMediaUnsupported.
const PaidMediaUnsupportedTypeID = 0x6bc3e26
// construct implements constructor of PaidMediaClass.
func (p PaidMediaUnsupported) construct() PaidMediaClass { return &p }
// Ensuring interfaces in compile-time for PaidMediaUnsupported.
var (
_ bin.Encoder = &PaidMediaUnsupported{}
_ bin.Decoder = &PaidMediaUnsupported{}
_ bin.BareEncoder = &PaidMediaUnsupported{}
_ bin.BareDecoder = &PaidMediaUnsupported{}
_ PaidMediaClass = &PaidMediaUnsupported{}
)
func (p *PaidMediaUnsupported) Zero() bool {
if p == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (p *PaidMediaUnsupported) String() string {
if p == nil {
return "PaidMediaUnsupported(nil)"
}
type Alias PaidMediaUnsupported
return fmt.Sprintf("PaidMediaUnsupported%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PaidMediaUnsupported) TypeID() uint32 {
return PaidMediaUnsupportedTypeID
}
// TypeName returns name of type in TL schema.
func (*PaidMediaUnsupported) TypeName() string {
return "paidMediaUnsupported"
}
// TypeInfo returns info about TL type.
func (p *PaidMediaUnsupported) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "paidMediaUnsupported",
ID: PaidMediaUnsupportedTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (p *PaidMediaUnsupported) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaUnsupported#6bc3e26 as nil")
}
b.PutID(PaidMediaUnsupportedTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PaidMediaUnsupported) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaUnsupported#6bc3e26 as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (p *PaidMediaUnsupported) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaUnsupported#6bc3e26 to nil")
}
if err := b.ConsumeID(PaidMediaUnsupportedTypeID); err != nil {
return fmt.Errorf("unable to decode paidMediaUnsupported#6bc3e26: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PaidMediaUnsupported) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaUnsupported#6bc3e26 to nil")
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PaidMediaUnsupported) EncodeTDLibJSON(b tdjson.Encoder) error {
if p == nil {
return fmt.Errorf("can't encode paidMediaUnsupported#6bc3e26 as nil")
}
b.ObjStart()
b.PutID("paidMediaUnsupported")
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PaidMediaUnsupported) DecodeTDLibJSON(b tdjson.Decoder) error {
if p == nil {
return fmt.Errorf("can't decode paidMediaUnsupported#6bc3e26 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("paidMediaUnsupported"); err != nil {
return fmt.Errorf("unable to decode paidMediaUnsupported#6bc3e26: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// PaidMediaClassName is schema name of PaidMediaClass.
const PaidMediaClassName = "PaidMedia"
// PaidMediaClass represents PaidMedia generic type.
//
// Example:
//
// g, err := tdapi.DecodePaidMedia(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tdapi.PaidMediaPreview: // paidMediaPreview#bcc1c474
// case *tdapi.PaidMediaPhoto: // paidMediaPhoto#ba82551a
// case *tdapi.PaidMediaVideo: // paidMediaVideo#33e7f02e
// case *tdapi.PaidMediaUnsupported: // paidMediaUnsupported#6bc3e26
// default: panic(v)
// }
type PaidMediaClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() PaidMediaClass
// 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
EncodeTDLibJSON(b tdjson.Encoder) error
DecodeTDLibJSON(b tdjson.Decoder) error
}
// DecodePaidMedia implements binary de-serialization for PaidMediaClass.
func DecodePaidMedia(buf *bin.Buffer) (PaidMediaClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case PaidMediaPreviewTypeID:
// Decoding paidMediaPreview#bcc1c474.
v := PaidMediaPreview{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
case PaidMediaPhotoTypeID:
// Decoding paidMediaPhoto#ba82551a.
v := PaidMediaPhoto{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
case PaidMediaVideoTypeID:
// Decoding paidMediaVideo#33e7f02e.
v := PaidMediaVideo{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
case PaidMediaUnsupportedTypeID:
// Decoding paidMediaUnsupported#6bc3e26.
v := PaidMediaUnsupported{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", bin.NewUnexpectedID(id))
}
}
// DecodeTDLibJSONPaidMedia implements binary de-serialization for PaidMediaClass.
func DecodeTDLibJSONPaidMedia(buf tdjson.Decoder) (PaidMediaClass, error) {
id, err := buf.FindTypeID()
if err != nil {
return nil, err
}
switch id {
case "paidMediaPreview":
// Decoding paidMediaPreview#bcc1c474.
v := PaidMediaPreview{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
case "paidMediaPhoto":
// Decoding paidMediaPhoto#ba82551a.
v := PaidMediaPhoto{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
case "paidMediaVideo":
// Decoding paidMediaVideo#33e7f02e.
v := PaidMediaVideo{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
case "paidMediaUnsupported":
// Decoding paidMediaUnsupported#6bc3e26.
v := PaidMediaUnsupported{}
if err := v.DecodeTDLibJSON(buf); err != nil {
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode PaidMediaClass: %w", tdjson.NewUnexpectedID(id))
}
}
// PaidMedia boxes the PaidMediaClass providing a helper.
type PaidMediaBox struct {
PaidMedia PaidMediaClass
}
// Decode implements bin.Decoder for PaidMediaBox.
func (b *PaidMediaBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode PaidMediaBox to nil")
}
v, err := DecodePaidMedia(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.PaidMedia = v
return nil
}
// Encode implements bin.Encode for PaidMediaBox.
func (b *PaidMediaBox) Encode(buf *bin.Buffer) error {
if b == nil || b.PaidMedia == nil {
return fmt.Errorf("unable to encode PaidMediaClass as nil")
}
return b.PaidMedia.Encode(buf)
}
// DecodeTDLibJSON implements bin.Decoder for PaidMediaBox.
func (b *PaidMediaBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("unable to decode PaidMediaBox to nil")
}
v, err := DecodeTDLibJSONPaidMedia(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.PaidMedia = v
return nil
}
// EncodeTDLibJSON implements bin.Encode for PaidMediaBox.
func (b *PaidMediaBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil || b.PaidMedia == nil {
return fmt.Errorf("unable to encode PaidMediaClass as nil")
}
return b.PaidMedia.EncodeTDLibJSON(buf)
}