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
239 lines
5.8 KiB
Go
239 lines
5.8 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{}
|
|
)
|
|
|
|
// ToggleGiftIsSavedRequest represents TL type `toggleGiftIsSaved#29515cf1`.
|
|
type ToggleGiftIsSavedRequest struct {
|
|
// Identifier of the gift
|
|
ReceivedGiftID string
|
|
// Pass true to display the gift on the user's or the channel's profile page; pass false
|
|
// to remove it from the profile page
|
|
IsSaved bool
|
|
}
|
|
|
|
// ToggleGiftIsSavedRequestTypeID is TL type id of ToggleGiftIsSavedRequest.
|
|
const ToggleGiftIsSavedRequestTypeID = 0x29515cf1
|
|
|
|
// Ensuring interfaces in compile-time for ToggleGiftIsSavedRequest.
|
|
var (
|
|
_ bin.Encoder = &ToggleGiftIsSavedRequest{}
|
|
_ bin.Decoder = &ToggleGiftIsSavedRequest{}
|
|
_ bin.BareEncoder = &ToggleGiftIsSavedRequest{}
|
|
_ bin.BareDecoder = &ToggleGiftIsSavedRequest{}
|
|
)
|
|
|
|
func (t *ToggleGiftIsSavedRequest) Zero() bool {
|
|
if t == nil {
|
|
return true
|
|
}
|
|
if !(t.ReceivedGiftID == "") {
|
|
return false
|
|
}
|
|
if !(t.IsSaved == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (t *ToggleGiftIsSavedRequest) String() string {
|
|
if t == nil {
|
|
return "ToggleGiftIsSavedRequest(nil)"
|
|
}
|
|
type Alias ToggleGiftIsSavedRequest
|
|
return fmt.Sprintf("ToggleGiftIsSavedRequest%+v", Alias(*t))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ToggleGiftIsSavedRequest) TypeID() uint32 {
|
|
return ToggleGiftIsSavedRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ToggleGiftIsSavedRequest) TypeName() string {
|
|
return "toggleGiftIsSaved"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (t *ToggleGiftIsSavedRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "toggleGiftIsSaved",
|
|
ID: ToggleGiftIsSavedRequestTypeID,
|
|
}
|
|
if t == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ReceivedGiftID",
|
|
SchemaName: "received_gift_id",
|
|
},
|
|
{
|
|
Name: "IsSaved",
|
|
SchemaName: "is_saved",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (t *ToggleGiftIsSavedRequest) Encode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode toggleGiftIsSaved#29515cf1 as nil")
|
|
}
|
|
b.PutID(ToggleGiftIsSavedRequestTypeID)
|
|
return t.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (t *ToggleGiftIsSavedRequest) EncodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode toggleGiftIsSaved#29515cf1 as nil")
|
|
}
|
|
b.PutString(t.ReceivedGiftID)
|
|
b.PutBool(t.IsSaved)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (t *ToggleGiftIsSavedRequest) Decode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode toggleGiftIsSaved#29515cf1 to nil")
|
|
}
|
|
if err := b.ConsumeID(ToggleGiftIsSavedRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode toggleGiftIsSaved#29515cf1: %w", err)
|
|
}
|
|
return t.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (t *ToggleGiftIsSavedRequest) DecodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode toggleGiftIsSaved#29515cf1 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleGiftIsSaved#29515cf1: field received_gift_id: %w", err)
|
|
}
|
|
t.ReceivedGiftID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleGiftIsSaved#29515cf1: field is_saved: %w", err)
|
|
}
|
|
t.IsSaved = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (t *ToggleGiftIsSavedRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode toggleGiftIsSaved#29515cf1 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("toggleGiftIsSaved")
|
|
b.Comma()
|
|
b.FieldStart("received_gift_id")
|
|
b.PutString(t.ReceivedGiftID)
|
|
b.Comma()
|
|
b.FieldStart("is_saved")
|
|
b.PutBool(t.IsSaved)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (t *ToggleGiftIsSavedRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode toggleGiftIsSaved#29515cf1 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("toggleGiftIsSaved"); err != nil {
|
|
return fmt.Errorf("unable to decode toggleGiftIsSaved#29515cf1: %w", err)
|
|
}
|
|
case "received_gift_id":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleGiftIsSaved#29515cf1: field received_gift_id: %w", err)
|
|
}
|
|
t.ReceivedGiftID = value
|
|
case "is_saved":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleGiftIsSaved#29515cf1: field is_saved: %w", err)
|
|
}
|
|
t.IsSaved = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetReceivedGiftID returns value of ReceivedGiftID field.
|
|
func (t *ToggleGiftIsSavedRequest) GetReceivedGiftID() (value string) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.ReceivedGiftID
|
|
}
|
|
|
|
// GetIsSaved returns value of IsSaved field.
|
|
func (t *ToggleGiftIsSavedRequest) GetIsSaved() (value bool) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.IsSaved
|
|
}
|
|
|
|
// ToggleGiftIsSaved invokes method toggleGiftIsSaved#29515cf1 returning error if any.
|
|
func (c *Client) ToggleGiftIsSaved(ctx context.Context, request *ToggleGiftIsSavedRequest) error {
|
|
var ok Ok
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|