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

228 lines
5.4 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{}
)
// StarSubscriptionPricing represents TL type `starSubscriptionPricing#96a28856`.
type StarSubscriptionPricing struct {
// The number of seconds between consecutive Telegram Star debiting
Period int32
// The amount of Telegram Stars that must be paid for each period
StarCount int64
}
// StarSubscriptionPricingTypeID is TL type id of StarSubscriptionPricing.
const StarSubscriptionPricingTypeID = 0x96a28856
// Ensuring interfaces in compile-time for StarSubscriptionPricing.
var (
_ bin.Encoder = &StarSubscriptionPricing{}
_ bin.Decoder = &StarSubscriptionPricing{}
_ bin.BareEncoder = &StarSubscriptionPricing{}
_ bin.BareDecoder = &StarSubscriptionPricing{}
)
func (s *StarSubscriptionPricing) Zero() bool {
if s == nil {
return true
}
if !(s.Period == 0) {
return false
}
if !(s.StarCount == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StarSubscriptionPricing) String() string {
if s == nil {
return "StarSubscriptionPricing(nil)"
}
type Alias StarSubscriptionPricing
return fmt.Sprintf("StarSubscriptionPricing%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StarSubscriptionPricing) TypeID() uint32 {
return StarSubscriptionPricingTypeID
}
// TypeName returns name of type in TL schema.
func (*StarSubscriptionPricing) TypeName() string {
return "starSubscriptionPricing"
}
// TypeInfo returns info about TL type.
func (s *StarSubscriptionPricing) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "starSubscriptionPricing",
ID: StarSubscriptionPricingTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Period",
SchemaName: "period",
},
{
Name: "StarCount",
SchemaName: "star_count",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StarSubscriptionPricing) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode starSubscriptionPricing#96a28856 as nil")
}
b.PutID(StarSubscriptionPricingTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StarSubscriptionPricing) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode starSubscriptionPricing#96a28856 as nil")
}
b.PutInt32(s.Period)
b.PutInt53(s.StarCount)
return nil
}
// Decode implements bin.Decoder.
func (s *StarSubscriptionPricing) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode starSubscriptionPricing#96a28856 to nil")
}
if err := b.ConsumeID(StarSubscriptionPricingTypeID); err != nil {
return fmt.Errorf("unable to decode starSubscriptionPricing#96a28856: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StarSubscriptionPricing) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode starSubscriptionPricing#96a28856 to nil")
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode starSubscriptionPricing#96a28856: field period: %w", err)
}
s.Period = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode starSubscriptionPricing#96a28856: field star_count: %w", err)
}
s.StarCount = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarSubscriptionPricing) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode starSubscriptionPricing#96a28856 as nil")
}
b.ObjStart()
b.PutID("starSubscriptionPricing")
b.Comma()
b.FieldStart("period")
b.PutInt32(s.Period)
b.Comma()
b.FieldStart("star_count")
b.PutInt53(s.StarCount)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarSubscriptionPricing) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode starSubscriptionPricing#96a28856 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("starSubscriptionPricing"); err != nil {
return fmt.Errorf("unable to decode starSubscriptionPricing#96a28856: %w", err)
}
case "period":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode starSubscriptionPricing#96a28856: field period: %w", err)
}
s.Period = value
case "star_count":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode starSubscriptionPricing#96a28856: field star_count: %w", err)
}
s.StarCount = value
default:
return b.Skip()
}
return nil
})
}
// GetPeriod returns value of Period field.
func (s *StarSubscriptionPricing) GetPeriod() (value int32) {
if s == nil {
return
}
return s.Period
}
// GetStarCount returns value of StarCount field.
func (s *StarSubscriptionPricing) GetStarCount() (value int64) {
if s == nil {
return
}
return s.StarCount
}