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

207 lines
4.9 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{}
)
// GetPushReceiverIDRequest represents TL type `getPushReceiverId#eeec46b2`.
type GetPushReceiverIDRequest struct {
// JSON-encoded push notification payload
Payload string
}
// GetPushReceiverIDRequestTypeID is TL type id of GetPushReceiverIDRequest.
const GetPushReceiverIDRequestTypeID = 0xeeec46b2
// Ensuring interfaces in compile-time for GetPushReceiverIDRequest.
var (
_ bin.Encoder = &GetPushReceiverIDRequest{}
_ bin.Decoder = &GetPushReceiverIDRequest{}
_ bin.BareEncoder = &GetPushReceiverIDRequest{}
_ bin.BareDecoder = &GetPushReceiverIDRequest{}
)
func (g *GetPushReceiverIDRequest) Zero() bool {
if g == nil {
return true
}
if !(g.Payload == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *GetPushReceiverIDRequest) String() string {
if g == nil {
return "GetPushReceiverIDRequest(nil)"
}
type Alias GetPushReceiverIDRequest
return fmt.Sprintf("GetPushReceiverIDRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GetPushReceiverIDRequest) TypeID() uint32 {
return GetPushReceiverIDRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*GetPushReceiverIDRequest) TypeName() string {
return "getPushReceiverId"
}
// TypeInfo returns info about TL type.
func (g *GetPushReceiverIDRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "getPushReceiverId",
ID: GetPushReceiverIDRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Payload",
SchemaName: "payload",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *GetPushReceiverIDRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getPushReceiverId#eeec46b2 as nil")
}
b.PutID(GetPushReceiverIDRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *GetPushReceiverIDRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getPushReceiverId#eeec46b2 as nil")
}
b.PutString(g.Payload)
return nil
}
// Decode implements bin.Decoder.
func (g *GetPushReceiverIDRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getPushReceiverId#eeec46b2 to nil")
}
if err := b.ConsumeID(GetPushReceiverIDRequestTypeID); err != nil {
return fmt.Errorf("unable to decode getPushReceiverId#eeec46b2: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *GetPushReceiverIDRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getPushReceiverId#eeec46b2 to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getPushReceiverId#eeec46b2: field payload: %w", err)
}
g.Payload = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetPushReceiverIDRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if g == nil {
return fmt.Errorf("can't encode getPushReceiverId#eeec46b2 as nil")
}
b.ObjStart()
b.PutID("getPushReceiverId")
b.Comma()
b.FieldStart("payload")
b.PutString(g.Payload)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetPushReceiverIDRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if g == nil {
return fmt.Errorf("can't decode getPushReceiverId#eeec46b2 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("getPushReceiverId"); err != nil {
return fmt.Errorf("unable to decode getPushReceiverId#eeec46b2: %w", err)
}
case "payload":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getPushReceiverId#eeec46b2: field payload: %w", err)
}
g.Payload = value
default:
return b.Skip()
}
return nil
})
}
// GetPayload returns value of Payload field.
func (g *GetPushReceiverIDRequest) GetPayload() (value string) {
if g == nil {
return
}
return g.Payload
}
// GetPushReceiverID invokes method getPushReceiverId#eeec46b2 returning error if any.
func (c *Client) GetPushReceiverID(ctx context.Context, payload string) (*PushReceiverID, error) {
var result PushReceiverID
request := &GetPushReceiverIDRequest{
Payload: payload,
}
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}