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
313 lines
7.4 KiB
Go
313 lines
7.4 KiB
Go
// 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{}
|
|
)
|
|
|
|
// FragmentCollectibleInfo represents TL type `fragment.collectibleInfo#6ebdff91`.
|
|
// Info about a fragment collectible¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/fragment
|
|
//
|
|
// See https://core.telegram.org/constructor/fragment.collectibleInfo for reference.
|
|
type FragmentCollectibleInfo struct {
|
|
// Purchase date (unixtime)
|
|
PurchaseDate int
|
|
// Three-letter ISO 4217 currency¹ code for amount
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/bots/payments#supported-currencies
|
|
Currency string
|
|
// Total price in the smallest units of the currency (integer, not float/double). For
|
|
// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
|
|
// currencies.json¹, it shows the number of digits past the decimal point for each
|
|
// currency (2 for the majority of currencies).
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/bots/payments/currencies.json
|
|
Amount int64
|
|
// Cryptocurrency name.
|
|
CryptoCurrency string
|
|
// Price, in the smallest units of the cryptocurrency.
|
|
CryptoAmount int64
|
|
// Fragment¹ URL with more info about the collectible
|
|
//
|
|
// Links:
|
|
// 1) https://fragment.com
|
|
URL string
|
|
}
|
|
|
|
// FragmentCollectibleInfoTypeID is TL type id of FragmentCollectibleInfo.
|
|
const FragmentCollectibleInfoTypeID = 0x6ebdff91
|
|
|
|
// Ensuring interfaces in compile-time for FragmentCollectibleInfo.
|
|
var (
|
|
_ bin.Encoder = &FragmentCollectibleInfo{}
|
|
_ bin.Decoder = &FragmentCollectibleInfo{}
|
|
_ bin.BareEncoder = &FragmentCollectibleInfo{}
|
|
_ bin.BareDecoder = &FragmentCollectibleInfo{}
|
|
)
|
|
|
|
func (c *FragmentCollectibleInfo) 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.CryptoAmount == 0) {
|
|
return false
|
|
}
|
|
if !(c.URL == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *FragmentCollectibleInfo) String() string {
|
|
if c == nil {
|
|
return "FragmentCollectibleInfo(nil)"
|
|
}
|
|
type Alias FragmentCollectibleInfo
|
|
return fmt.Sprintf("FragmentCollectibleInfo%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills FragmentCollectibleInfo from given interface.
|
|
func (c *FragmentCollectibleInfo) FillFrom(from interface {
|
|
GetPurchaseDate() (value int)
|
|
GetCurrency() (value string)
|
|
GetAmount() (value int64)
|
|
GetCryptoCurrency() (value string)
|
|
GetCryptoAmount() (value int64)
|
|
GetURL() (value string)
|
|
}) {
|
|
c.PurchaseDate = from.GetPurchaseDate()
|
|
c.Currency = from.GetCurrency()
|
|
c.Amount = from.GetAmount()
|
|
c.CryptoCurrency = from.GetCryptoCurrency()
|
|
c.CryptoAmount = from.GetCryptoAmount()
|
|
c.URL = from.GetURL()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*FragmentCollectibleInfo) TypeID() uint32 {
|
|
return FragmentCollectibleInfoTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*FragmentCollectibleInfo) TypeName() string {
|
|
return "fragment.collectibleInfo"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *FragmentCollectibleInfo) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "fragment.collectibleInfo",
|
|
ID: FragmentCollectibleInfoTypeID,
|
|
}
|
|
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: "crypto_currency",
|
|
},
|
|
{
|
|
Name: "CryptoAmount",
|
|
SchemaName: "crypto_amount",
|
|
},
|
|
{
|
|
Name: "URL",
|
|
SchemaName: "url",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *FragmentCollectibleInfo) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode fragment.collectibleInfo#6ebdff91 as nil")
|
|
}
|
|
b.PutID(FragmentCollectibleInfoTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *FragmentCollectibleInfo) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode fragment.collectibleInfo#6ebdff91 as nil")
|
|
}
|
|
b.PutInt(c.PurchaseDate)
|
|
b.PutString(c.Currency)
|
|
b.PutLong(c.Amount)
|
|
b.PutString(c.CryptoCurrency)
|
|
b.PutLong(c.CryptoAmount)
|
|
b.PutString(c.URL)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *FragmentCollectibleInfo) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode fragment.collectibleInfo#6ebdff91 to nil")
|
|
}
|
|
if err := b.ConsumeID(FragmentCollectibleInfoTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *FragmentCollectibleInfo) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode fragment.collectibleInfo#6ebdff91 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: field purchase_date: %w", err)
|
|
}
|
|
c.PurchaseDate = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: field currency: %w", err)
|
|
}
|
|
c.Currency = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: field amount: %w", err)
|
|
}
|
|
c.Amount = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: field crypto_currency: %w", err)
|
|
}
|
|
c.CryptoCurrency = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: field crypto_amount: %w", err)
|
|
}
|
|
c.CryptoAmount = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode fragment.collectibleInfo#6ebdff91: field url: %w", err)
|
|
}
|
|
c.URL = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPurchaseDate returns value of PurchaseDate field.
|
|
func (c *FragmentCollectibleInfo) GetPurchaseDate() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.PurchaseDate
|
|
}
|
|
|
|
// GetCurrency returns value of Currency field.
|
|
func (c *FragmentCollectibleInfo) GetCurrency() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Currency
|
|
}
|
|
|
|
// GetAmount returns value of Amount field.
|
|
func (c *FragmentCollectibleInfo) GetAmount() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Amount
|
|
}
|
|
|
|
// GetCryptoCurrency returns value of CryptoCurrency field.
|
|
func (c *FragmentCollectibleInfo) GetCryptoCurrency() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.CryptoCurrency
|
|
}
|
|
|
|
// GetCryptoAmount returns value of CryptoAmount field.
|
|
func (c *FragmentCollectibleInfo) GetCryptoAmount() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.CryptoAmount
|
|
}
|
|
|
|
// GetURL returns value of URL field.
|
|
func (c *FragmentCollectibleInfo) GetURL() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.URL
|
|
}
|