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

249 lines
6.0 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{}
)
// SetProfilePhotoRequest represents TL type `setProfilePhoto#85ea05ed`.
type SetProfilePhotoRequest struct {
// Profile photo to set
Photo InputChatPhotoClass
// Pass true to set the public photo, which will be visible even the main photo is hidden
// by privacy settings
IsPublic bool
}
// SetProfilePhotoRequestTypeID is TL type id of SetProfilePhotoRequest.
const SetProfilePhotoRequestTypeID = 0x85ea05ed
// Ensuring interfaces in compile-time for SetProfilePhotoRequest.
var (
_ bin.Encoder = &SetProfilePhotoRequest{}
_ bin.Decoder = &SetProfilePhotoRequest{}
_ bin.BareEncoder = &SetProfilePhotoRequest{}
_ bin.BareDecoder = &SetProfilePhotoRequest{}
)
func (s *SetProfilePhotoRequest) Zero() bool {
if s == nil {
return true
}
if !(s.Photo == nil) {
return false
}
if !(s.IsPublic == false) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *SetProfilePhotoRequest) String() string {
if s == nil {
return "SetProfilePhotoRequest(nil)"
}
type Alias SetProfilePhotoRequest
return fmt.Sprintf("SetProfilePhotoRequest%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*SetProfilePhotoRequest) TypeID() uint32 {
return SetProfilePhotoRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*SetProfilePhotoRequest) TypeName() string {
return "setProfilePhoto"
}
// TypeInfo returns info about TL type.
func (s *SetProfilePhotoRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "setProfilePhoto",
ID: SetProfilePhotoRequestTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Photo",
SchemaName: "photo",
},
{
Name: "IsPublic",
SchemaName: "is_public",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *SetProfilePhotoRequest) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode setProfilePhoto#85ea05ed as nil")
}
b.PutID(SetProfilePhotoRequestTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *SetProfilePhotoRequest) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode setProfilePhoto#85ea05ed as nil")
}
if s.Photo == nil {
return fmt.Errorf("unable to encode setProfilePhoto#85ea05ed: field photo is nil")
}
if err := s.Photo.Encode(b); err != nil {
return fmt.Errorf("unable to encode setProfilePhoto#85ea05ed: field photo: %w", err)
}
b.PutBool(s.IsPublic)
return nil
}
// Decode implements bin.Decoder.
func (s *SetProfilePhotoRequest) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode setProfilePhoto#85ea05ed to nil")
}
if err := b.ConsumeID(SetProfilePhotoRequestTypeID); err != nil {
return fmt.Errorf("unable to decode setProfilePhoto#85ea05ed: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *SetProfilePhotoRequest) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode setProfilePhoto#85ea05ed to nil")
}
{
value, err := DecodeInputChatPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode setProfilePhoto#85ea05ed: field photo: %w", err)
}
s.Photo = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode setProfilePhoto#85ea05ed: field is_public: %w", err)
}
s.IsPublic = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SetProfilePhotoRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode setProfilePhoto#85ea05ed as nil")
}
b.ObjStart()
b.PutID("setProfilePhoto")
b.Comma()
b.FieldStart("photo")
if s.Photo == nil {
return fmt.Errorf("unable to encode setProfilePhoto#85ea05ed: field photo is nil")
}
if err := s.Photo.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode setProfilePhoto#85ea05ed: field photo: %w", err)
}
b.Comma()
b.FieldStart("is_public")
b.PutBool(s.IsPublic)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SetProfilePhotoRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode setProfilePhoto#85ea05ed to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("setProfilePhoto"); err != nil {
return fmt.Errorf("unable to decode setProfilePhoto#85ea05ed: %w", err)
}
case "photo":
value, err := DecodeTDLibJSONInputChatPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode setProfilePhoto#85ea05ed: field photo: %w", err)
}
s.Photo = value
case "is_public":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode setProfilePhoto#85ea05ed: field is_public: %w", err)
}
s.IsPublic = value
default:
return b.Skip()
}
return nil
})
}
// GetPhoto returns value of Photo field.
func (s *SetProfilePhotoRequest) GetPhoto() (value InputChatPhotoClass) {
if s == nil {
return
}
return s.Photo
}
// GetIsPublic returns value of IsPublic field.
func (s *SetProfilePhotoRequest) GetIsPublic() (value bool) {
if s == nil {
return
}
return s.IsPublic
}
// SetProfilePhoto invokes method setProfilePhoto#85ea05ed returning error if any.
func (c *Client) SetProfilePhoto(ctx context.Context, request *SetProfilePhotoRequest) error {
var ok Ok
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}