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

207 lines
5.2 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{}
)
// OpenSponsoredChatRequest represents TL type `openSponsoredChat#339de425`.
type OpenSponsoredChatRequest struct {
// Unique identifier of the sponsored chat
SponsoredChatUniqueID int64
}
// OpenSponsoredChatRequestTypeID is TL type id of OpenSponsoredChatRequest.
const OpenSponsoredChatRequestTypeID = 0x339de425
// Ensuring interfaces in compile-time for OpenSponsoredChatRequest.
var (
_ bin.Encoder = &OpenSponsoredChatRequest{}
_ bin.Decoder = &OpenSponsoredChatRequest{}
_ bin.BareEncoder = &OpenSponsoredChatRequest{}
_ bin.BareDecoder = &OpenSponsoredChatRequest{}
)
func (o *OpenSponsoredChatRequest) Zero() bool {
if o == nil {
return true
}
if !(o.SponsoredChatUniqueID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (o *OpenSponsoredChatRequest) String() string {
if o == nil {
return "OpenSponsoredChatRequest(nil)"
}
type Alias OpenSponsoredChatRequest
return fmt.Sprintf("OpenSponsoredChatRequest%+v", Alias(*o))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*OpenSponsoredChatRequest) TypeID() uint32 {
return OpenSponsoredChatRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*OpenSponsoredChatRequest) TypeName() string {
return "openSponsoredChat"
}
// TypeInfo returns info about TL type.
func (o *OpenSponsoredChatRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "openSponsoredChat",
ID: OpenSponsoredChatRequestTypeID,
}
if o == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "SponsoredChatUniqueID",
SchemaName: "sponsored_chat_unique_id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (o *OpenSponsoredChatRequest) Encode(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't encode openSponsoredChat#339de425 as nil")
}
b.PutID(OpenSponsoredChatRequestTypeID)
return o.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (o *OpenSponsoredChatRequest) EncodeBare(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't encode openSponsoredChat#339de425 as nil")
}
b.PutInt53(o.SponsoredChatUniqueID)
return nil
}
// Decode implements bin.Decoder.
func (o *OpenSponsoredChatRequest) Decode(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't decode openSponsoredChat#339de425 to nil")
}
if err := b.ConsumeID(OpenSponsoredChatRequestTypeID); err != nil {
return fmt.Errorf("unable to decode openSponsoredChat#339de425: %w", err)
}
return o.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (o *OpenSponsoredChatRequest) DecodeBare(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't decode openSponsoredChat#339de425 to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode openSponsoredChat#339de425: field sponsored_chat_unique_id: %w", err)
}
o.SponsoredChatUniqueID = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (o *OpenSponsoredChatRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if o == nil {
return fmt.Errorf("can't encode openSponsoredChat#339de425 as nil")
}
b.ObjStart()
b.PutID("openSponsoredChat")
b.Comma()
b.FieldStart("sponsored_chat_unique_id")
b.PutInt53(o.SponsoredChatUniqueID)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (o *OpenSponsoredChatRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if o == nil {
return fmt.Errorf("can't decode openSponsoredChat#339de425 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("openSponsoredChat"); err != nil {
return fmt.Errorf("unable to decode openSponsoredChat#339de425: %w", err)
}
case "sponsored_chat_unique_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode openSponsoredChat#339de425: field sponsored_chat_unique_id: %w", err)
}
o.SponsoredChatUniqueID = value
default:
return b.Skip()
}
return nil
})
}
// GetSponsoredChatUniqueID returns value of SponsoredChatUniqueID field.
func (o *OpenSponsoredChatRequest) GetSponsoredChatUniqueID() (value int64) {
if o == nil {
return
}
return o.SponsoredChatUniqueID
}
// OpenSponsoredChat invokes method openSponsoredChat#339de425 returning error if any.
func (c *Client) OpenSponsoredChat(ctx context.Context, sponsoredchatuniqueid int64) error {
var ok Ok
request := &OpenSponsoredChatRequest{
SponsoredChatUniqueID: sponsoredchatuniqueid,
}
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}