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

364 lines
8.5 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{}
)
// CollectibleItemInfo represents TL type `collectibleItemInfo#570f9bcd`.
type CollectibleItemInfo struct {
// Point in time (Unix timestamp) when the item was purchased
PurchaseDate int32
// Currency for the paid amount
Currency string
// The paid amount, in the smallest units of the currency
Amount int64
// Cryptocurrency used to pay for the item
Cryptocurrency string
// The paid amount, in the smallest units of the cryptocurrency
CryptocurrencyAmount int64
// Individual URL for the item on https://fragment.com
URL string
}
// CollectibleItemInfoTypeID is TL type id of CollectibleItemInfo.
const CollectibleItemInfoTypeID = 0x570f9bcd
// Ensuring interfaces in compile-time for CollectibleItemInfo.
var (
_ bin.Encoder = &CollectibleItemInfo{}
_ bin.Decoder = &CollectibleItemInfo{}
_ bin.BareEncoder = &CollectibleItemInfo{}
_ bin.BareDecoder = &CollectibleItemInfo{}
)
func (c *CollectibleItemInfo) Zero() bool {
if c == nil {
return true
}
if !(c.PurchaseDate == 0) {
return false
}
if !(c.Currency == "") {
return false
}
if !(c.Amount == 0) {
return false
}
if !(c.Cryptocurrency == "") {
return false
}
if !(c.CryptocurrencyAmount == 0) {
return false
}
if !(c.URL == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *CollectibleItemInfo) String() string {
if c == nil {
return "CollectibleItemInfo(nil)"
}
type Alias CollectibleItemInfo
return fmt.Sprintf("CollectibleItemInfo%+v", Alias(*c))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*CollectibleItemInfo) TypeID() uint32 {
return CollectibleItemInfoTypeID
}
// TypeName returns name of type in TL schema.
func (*CollectibleItemInfo) TypeName() string {
return "collectibleItemInfo"
}
// TypeInfo returns info about TL type.
func (c *CollectibleItemInfo) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "collectibleItemInfo",
ID: CollectibleItemInfoTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "PurchaseDate",
SchemaName: "purchase_date",
},
{
Name: "Currency",
SchemaName: "currency",
},
{
Name: "Amount",
SchemaName: "amount",
},
{
Name: "Cryptocurrency",
SchemaName: "cryptocurrency",
},
{
Name: "CryptocurrencyAmount",
SchemaName: "cryptocurrency_amount",
},
{
Name: "URL",
SchemaName: "url",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *CollectibleItemInfo) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode collectibleItemInfo#570f9bcd as nil")
}
b.PutID(CollectibleItemInfoTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *CollectibleItemInfo) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode collectibleItemInfo#570f9bcd as nil")
}
b.PutInt32(c.PurchaseDate)
b.PutString(c.Currency)
b.PutInt53(c.Amount)
b.PutString(c.Cryptocurrency)
b.PutLong(c.CryptocurrencyAmount)
b.PutString(c.URL)
return nil
}
// Decode implements bin.Decoder.
func (c *CollectibleItemInfo) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode collectibleItemInfo#570f9bcd to nil")
}
if err := b.ConsumeID(CollectibleItemInfoTypeID); err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *CollectibleItemInfo) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode collectibleItemInfo#570f9bcd to nil")
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field purchase_date: %w", err)
}
c.PurchaseDate = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field currency: %w", err)
}
c.Currency = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field amount: %w", err)
}
c.Amount = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field cryptocurrency: %w", err)
}
c.Cryptocurrency = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field cryptocurrency_amount: %w", err)
}
c.CryptocurrencyAmount = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field url: %w", err)
}
c.URL = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CollectibleItemInfo) EncodeTDLibJSON(b tdjson.Encoder) error {
if c == nil {
return fmt.Errorf("can't encode collectibleItemInfo#570f9bcd as nil")
}
b.ObjStart()
b.PutID("collectibleItemInfo")
b.Comma()
b.FieldStart("purchase_date")
b.PutInt32(c.PurchaseDate)
b.Comma()
b.FieldStart("currency")
b.PutString(c.Currency)
b.Comma()
b.FieldStart("amount")
b.PutInt53(c.Amount)
b.Comma()
b.FieldStart("cryptocurrency")
b.PutString(c.Cryptocurrency)
b.Comma()
b.FieldStart("cryptocurrency_amount")
b.PutLong(c.CryptocurrencyAmount)
b.Comma()
b.FieldStart("url")
b.PutString(c.URL)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CollectibleItemInfo) DecodeTDLibJSON(b tdjson.Decoder) error {
if c == nil {
return fmt.Errorf("can't decode collectibleItemInfo#570f9bcd to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("collectibleItemInfo"); err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: %w", err)
}
case "purchase_date":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field purchase_date: %w", err)
}
c.PurchaseDate = value
case "currency":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field currency: %w", err)
}
c.Currency = value
case "amount":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field amount: %w", err)
}
c.Amount = value
case "cryptocurrency":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field cryptocurrency: %w", err)
}
c.Cryptocurrency = value
case "cryptocurrency_amount":
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field cryptocurrency_amount: %w", err)
}
c.CryptocurrencyAmount = value
case "url":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode collectibleItemInfo#570f9bcd: field url: %w", err)
}
c.URL = value
default:
return b.Skip()
}
return nil
})
}
// GetPurchaseDate returns value of PurchaseDate field.
func (c *CollectibleItemInfo) GetPurchaseDate() (value int32) {
if c == nil {
return
}
return c.PurchaseDate
}
// GetCurrency returns value of Currency field.
func (c *CollectibleItemInfo) GetCurrency() (value string) {
if c == nil {
return
}
return c.Currency
}
// GetAmount returns value of Amount field.
func (c *CollectibleItemInfo) GetAmount() (value int64) {
if c == nil {
return
}
return c.Amount
}
// GetCryptocurrency returns value of Cryptocurrency field.
func (c *CollectibleItemInfo) GetCryptocurrency() (value string) {
if c == nil {
return
}
return c.Cryptocurrency
}
// GetCryptocurrencyAmount returns value of CryptocurrencyAmount field.
func (c *CollectibleItemInfo) GetCryptocurrencyAmount() (value int64) {
if c == nil {
return
}
return c.CryptocurrencyAmount
}
// GetURL returns value of URL field.
func (c *CollectibleItemInfo) GetURL() (value string) {
if c == nil {
return
}
return c.URL
}