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
211 lines
5.9 KiB
Go
Generated
211 lines
5.9 KiB
Go
Generated
// 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{}
|
|
)
|
|
|
|
// AccountDeleteSecureValueRequest represents TL type `account.deleteSecureValue#b880bc4b`.
|
|
// Delete stored Telegram Passport¹ documents, for more info see the passport docs »²
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/passport
|
|
// 2. https://core.telegram.org/passport/encryption#encryption
|
|
//
|
|
// See https://core.telegram.org/method/account.deleteSecureValue for reference.
|
|
type AccountDeleteSecureValueRequest struct {
|
|
// Document types to delete
|
|
Types []SecureValueTypeClass
|
|
}
|
|
|
|
// AccountDeleteSecureValueRequestTypeID is TL type id of AccountDeleteSecureValueRequest.
|
|
const AccountDeleteSecureValueRequestTypeID = 0xb880bc4b
|
|
|
|
// Ensuring interfaces in compile-time for AccountDeleteSecureValueRequest.
|
|
var (
|
|
_ bin.Encoder = &AccountDeleteSecureValueRequest{}
|
|
_ bin.Decoder = &AccountDeleteSecureValueRequest{}
|
|
_ bin.BareEncoder = &AccountDeleteSecureValueRequest{}
|
|
_ bin.BareDecoder = &AccountDeleteSecureValueRequest{}
|
|
)
|
|
|
|
func (d *AccountDeleteSecureValueRequest) Zero() bool {
|
|
if d == nil {
|
|
return true
|
|
}
|
|
if !(d.Types == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (d *AccountDeleteSecureValueRequest) String() string {
|
|
if d == nil {
|
|
return "AccountDeleteSecureValueRequest(nil)"
|
|
}
|
|
type Alias AccountDeleteSecureValueRequest
|
|
return fmt.Sprintf("AccountDeleteSecureValueRequest%+v", Alias(*d))
|
|
}
|
|
|
|
// FillFrom fills AccountDeleteSecureValueRequest from given interface.
|
|
func (d *AccountDeleteSecureValueRequest) FillFrom(from interface {
|
|
GetTypes() (value []SecureValueTypeClass)
|
|
}) {
|
|
d.Types = from.GetTypes()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*AccountDeleteSecureValueRequest) TypeID() uint32 {
|
|
return AccountDeleteSecureValueRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*AccountDeleteSecureValueRequest) TypeName() string {
|
|
return "account.deleteSecureValue"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (d *AccountDeleteSecureValueRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "account.deleteSecureValue",
|
|
ID: AccountDeleteSecureValueRequestTypeID,
|
|
}
|
|
if d == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Types",
|
|
SchemaName: "types",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (d *AccountDeleteSecureValueRequest) Encode(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't encode account.deleteSecureValue#b880bc4b as nil")
|
|
}
|
|
b.PutID(AccountDeleteSecureValueRequestTypeID)
|
|
return d.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (d *AccountDeleteSecureValueRequest) EncodeBare(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't encode account.deleteSecureValue#b880bc4b as nil")
|
|
}
|
|
b.PutVectorHeader(len(d.Types))
|
|
for idx, v := range d.Types {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode account.deleteSecureValue#b880bc4b: field types element with index %d is nil", idx)
|
|
}
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode account.deleteSecureValue#b880bc4b: field types element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (d *AccountDeleteSecureValueRequest) Decode(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't decode account.deleteSecureValue#b880bc4b to nil")
|
|
}
|
|
if err := b.ConsumeID(AccountDeleteSecureValueRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode account.deleteSecureValue#b880bc4b: %w", err)
|
|
}
|
|
return d.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (d *AccountDeleteSecureValueRequest) DecodeBare(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't decode account.deleteSecureValue#b880bc4b to nil")
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode account.deleteSecureValue#b880bc4b: field types: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
d.Types = make([]SecureValueTypeClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodeSecureValueType(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode account.deleteSecureValue#b880bc4b: field types: %w", err)
|
|
}
|
|
d.Types = append(d.Types, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetTypes returns value of Types field.
|
|
func (d *AccountDeleteSecureValueRequest) GetTypes() (value []SecureValueTypeClass) {
|
|
if d == nil {
|
|
return
|
|
}
|
|
return d.Types
|
|
}
|
|
|
|
// MapTypes returns field Types wrapped in SecureValueTypeClassArray helper.
|
|
func (d *AccountDeleteSecureValueRequest) MapTypes() (value SecureValueTypeClassArray) {
|
|
return SecureValueTypeClassArray(d.Types)
|
|
}
|
|
|
|
// AccountDeleteSecureValue invokes method account.deleteSecureValue#b880bc4b returning error if any.
|
|
// Delete stored Telegram Passport¹ documents, for more info see the passport docs »²
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/passport
|
|
// 2. https://core.telegram.org/passport/encryption#encryption
|
|
//
|
|
// See https://core.telegram.org/method/account.deleteSecureValue for reference.
|
|
func (c *Client) AccountDeleteSecureValue(ctx context.Context, types []SecureValueTypeClass) (bool, error) {
|
|
var result BoolBox
|
|
|
|
request := &AccountDeleteSecureValueRequest{
|
|
Types: types,
|
|
}
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return false, err
|
|
}
|
|
_, ok := result.Bool.(*BoolTrue)
|
|
return ok, nil
|
|
}
|