// 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{} ) // ContactsEditCloseFriendsRequest represents TL type `contacts.editCloseFriends#ba6705f0`. // Edit the close friends list, see here »¹ for more info. // // Links: // 1. https://core.telegram.org/api/privacy // // See https://core.telegram.org/method/contacts.editCloseFriends for reference. type ContactsEditCloseFriendsRequest struct { // Full list of user IDs of close friends, see here¹ for more info. // // Links: // 1) https://core.telegram.org/api/privacy ID []int64 } // ContactsEditCloseFriendsRequestTypeID is TL type id of ContactsEditCloseFriendsRequest. const ContactsEditCloseFriendsRequestTypeID = 0xba6705f0 // Ensuring interfaces in compile-time for ContactsEditCloseFriendsRequest. var ( _ bin.Encoder = &ContactsEditCloseFriendsRequest{} _ bin.Decoder = &ContactsEditCloseFriendsRequest{} _ bin.BareEncoder = &ContactsEditCloseFriendsRequest{} _ bin.BareDecoder = &ContactsEditCloseFriendsRequest{} ) func (e *ContactsEditCloseFriendsRequest) Zero() bool { if e == nil { return true } if !(e.ID == nil) { return false } return true } // String implements fmt.Stringer. func (e *ContactsEditCloseFriendsRequest) String() string { if e == nil { return "ContactsEditCloseFriendsRequest(nil)" } type Alias ContactsEditCloseFriendsRequest return fmt.Sprintf("ContactsEditCloseFriendsRequest%+v", Alias(*e)) } // FillFrom fills ContactsEditCloseFriendsRequest from given interface. func (e *ContactsEditCloseFriendsRequest) FillFrom(from interface { GetID() (value []int64) }) { e.ID = from.GetID() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ContactsEditCloseFriendsRequest) TypeID() uint32 { return ContactsEditCloseFriendsRequestTypeID } // TypeName returns name of type in TL schema. func (*ContactsEditCloseFriendsRequest) TypeName() string { return "contacts.editCloseFriends" } // TypeInfo returns info about TL type. func (e *ContactsEditCloseFriendsRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "contacts.editCloseFriends", ID: ContactsEditCloseFriendsRequestTypeID, } if e == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ID", SchemaName: "id", }, } return typ } // Encode implements bin.Encoder. func (e *ContactsEditCloseFriendsRequest) Encode(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't encode contacts.editCloseFriends#ba6705f0 as nil") } b.PutID(ContactsEditCloseFriendsRequestTypeID) return e.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (e *ContactsEditCloseFriendsRequest) EncodeBare(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't encode contacts.editCloseFriends#ba6705f0 as nil") } b.PutVectorHeader(len(e.ID)) for _, v := range e.ID { b.PutLong(v) } return nil } // Decode implements bin.Decoder. func (e *ContactsEditCloseFriendsRequest) Decode(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't decode contacts.editCloseFriends#ba6705f0 to nil") } if err := b.ConsumeID(ContactsEditCloseFriendsRequestTypeID); err != nil { return fmt.Errorf("unable to decode contacts.editCloseFriends#ba6705f0: %w", err) } return e.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (e *ContactsEditCloseFriendsRequest) DecodeBare(b *bin.Buffer) error { if e == nil { return fmt.Errorf("can't decode contacts.editCloseFriends#ba6705f0 to nil") } { headerLen, err := b.VectorHeader() if err != nil { return fmt.Errorf("unable to decode contacts.editCloseFriends#ba6705f0: field id: %w", err) } if headerLen > 0 { e.ID = make([]int64, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode contacts.editCloseFriends#ba6705f0: field id: %w", err) } e.ID = append(e.ID, value) } } return nil } // GetID returns value of ID field. func (e *ContactsEditCloseFriendsRequest) GetID() (value []int64) { if e == nil { return } return e.ID } // ContactsEditCloseFriends invokes method contacts.editCloseFriends#ba6705f0 returning error if any. // Edit the close friends list, see here »¹ for more info. // // Links: // 1. https://core.telegram.org/api/privacy // // See https://core.telegram.org/method/contacts.editCloseFriends for reference. func (c *Client) ContactsEditCloseFriends(ctx context.Context, id []int64) (bool, error) { var result BoolBox request := &ContactsEditCloseFriendsRequest{ ID: id, } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return false, err } _, ok := result.Bool.(*BoolTrue) return ok, nil }