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

207 lines
5.1 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{}
)
// DeleteProfilePhotoRequest represents TL type `deleteProfilePhoto#4eaa77c1`.
type DeleteProfilePhotoRequest struct {
// Identifier of the profile photo to delete
ProfilePhotoID int64
}
// DeleteProfilePhotoRequestTypeID is TL type id of DeleteProfilePhotoRequest.
const DeleteProfilePhotoRequestTypeID = 0x4eaa77c1
// Ensuring interfaces in compile-time for DeleteProfilePhotoRequest.
var (
_ bin.Encoder = &DeleteProfilePhotoRequest{}
_ bin.Decoder = &DeleteProfilePhotoRequest{}
_ bin.BareEncoder = &DeleteProfilePhotoRequest{}
_ bin.BareDecoder = &DeleteProfilePhotoRequest{}
)
func (d *DeleteProfilePhotoRequest) Zero() bool {
if d == nil {
return true
}
if !(d.ProfilePhotoID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (d *DeleteProfilePhotoRequest) String() string {
if d == nil {
return "DeleteProfilePhotoRequest(nil)"
}
type Alias DeleteProfilePhotoRequest
return fmt.Sprintf("DeleteProfilePhotoRequest%+v", Alias(*d))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DeleteProfilePhotoRequest) TypeID() uint32 {
return DeleteProfilePhotoRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*DeleteProfilePhotoRequest) TypeName() string {
return "deleteProfilePhoto"
}
// TypeInfo returns info about TL type.
func (d *DeleteProfilePhotoRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "deleteProfilePhoto",
ID: DeleteProfilePhotoRequestTypeID,
}
if d == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ProfilePhotoID",
SchemaName: "profile_photo_id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (d *DeleteProfilePhotoRequest) Encode(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't encode deleteProfilePhoto#4eaa77c1 as nil")
}
b.PutID(DeleteProfilePhotoRequestTypeID)
return d.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (d *DeleteProfilePhotoRequest) EncodeBare(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't encode deleteProfilePhoto#4eaa77c1 as nil")
}
b.PutLong(d.ProfilePhotoID)
return nil
}
// Decode implements bin.Decoder.
func (d *DeleteProfilePhotoRequest) Decode(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't decode deleteProfilePhoto#4eaa77c1 to nil")
}
if err := b.ConsumeID(DeleteProfilePhotoRequestTypeID); err != nil {
return fmt.Errorf("unable to decode deleteProfilePhoto#4eaa77c1: %w", err)
}
return d.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (d *DeleteProfilePhotoRequest) DecodeBare(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't decode deleteProfilePhoto#4eaa77c1 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode deleteProfilePhoto#4eaa77c1: field profile_photo_id: %w", err)
}
d.ProfilePhotoID = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (d *DeleteProfilePhotoRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if d == nil {
return fmt.Errorf("can't encode deleteProfilePhoto#4eaa77c1 as nil")
}
b.ObjStart()
b.PutID("deleteProfilePhoto")
b.Comma()
b.FieldStart("profile_photo_id")
b.PutLong(d.ProfilePhotoID)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (d *DeleteProfilePhotoRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if d == nil {
return fmt.Errorf("can't decode deleteProfilePhoto#4eaa77c1 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("deleteProfilePhoto"); err != nil {
return fmt.Errorf("unable to decode deleteProfilePhoto#4eaa77c1: %w", err)
}
case "profile_photo_id":
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode deleteProfilePhoto#4eaa77c1: field profile_photo_id: %w", err)
}
d.ProfilePhotoID = value
default:
return b.Skip()
}
return nil
})
}
// GetProfilePhotoID returns value of ProfilePhotoID field.
func (d *DeleteProfilePhotoRequest) GetProfilePhotoID() (value int64) {
if d == nil {
return
}
return d.ProfilePhotoID
}
// DeleteProfilePhoto invokes method deleteProfilePhoto#4eaa77c1 returning error if any.
func (c *Client) DeleteProfilePhoto(ctx context.Context, profilephotoid int64) error {
var ok Ok
request := &DeleteProfilePhotoRequest{
ProfilePhotoID: profilephotoid,
}
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}