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

155 lines
4.0 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{}
)
// ContactsGetSavedRequest represents TL type `contacts.getSaved#82f1e39f`.
// Get all contacts, requires a takeout session, see here » for more info¹.
//
// Links:
// 1. https://core.telegram.org/api/takeout
//
// See https://core.telegram.org/method/contacts.getSaved for reference.
type ContactsGetSavedRequest struct {
}
// ContactsGetSavedRequestTypeID is TL type id of ContactsGetSavedRequest.
const ContactsGetSavedRequestTypeID = 0x82f1e39f
// Ensuring interfaces in compile-time for ContactsGetSavedRequest.
var (
_ bin.Encoder = &ContactsGetSavedRequest{}
_ bin.Decoder = &ContactsGetSavedRequest{}
_ bin.BareEncoder = &ContactsGetSavedRequest{}
_ bin.BareDecoder = &ContactsGetSavedRequest{}
)
func (g *ContactsGetSavedRequest) Zero() bool {
if g == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (g *ContactsGetSavedRequest) String() string {
if g == nil {
return "ContactsGetSavedRequest(nil)"
}
type Alias ContactsGetSavedRequest
return fmt.Sprintf("ContactsGetSavedRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ContactsGetSavedRequest) TypeID() uint32 {
return ContactsGetSavedRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*ContactsGetSavedRequest) TypeName() string {
return "contacts.getSaved"
}
// TypeInfo returns info about TL type.
func (g *ContactsGetSavedRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "contacts.getSaved",
ID: ContactsGetSavedRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (g *ContactsGetSavedRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode contacts.getSaved#82f1e39f as nil")
}
b.PutID(ContactsGetSavedRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *ContactsGetSavedRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode contacts.getSaved#82f1e39f as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (g *ContactsGetSavedRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode contacts.getSaved#82f1e39f to nil")
}
if err := b.ConsumeID(ContactsGetSavedRequestTypeID); err != nil {
return fmt.Errorf("unable to decode contacts.getSaved#82f1e39f: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *ContactsGetSavedRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode contacts.getSaved#82f1e39f to nil")
}
return nil
}
// ContactsGetSaved invokes method contacts.getSaved#82f1e39f returning error if any.
// Get all contacts, requires a takeout session, see here » for more info¹.
//
// Links:
// 1. https://core.telegram.org/api/takeout
//
// Possible errors:
//
// 400 TAKEOUT_INVALID: The specified takeout ID is invalid.
// 403 TAKEOUT_REQUIRED: A takeout¹ session needs to be initialized first, see here » for more info².
//
// See https://core.telegram.org/method/contacts.getSaved for reference.
func (c *Client) ContactsGetSaved(ctx context.Context) ([]SavedPhoneContact, error) {
var result SavedPhoneContactVector
request := &ContactsGetSavedRequest{}
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return []SavedPhoneContact(result.Elems), nil
}