Files
mautrix-telegram/pkg/gotd/tdapi/tl_get_internal_link_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{}
)
// GetInternalLinkRequest represents TL type `getInternalLink#3960f1b0`.
type GetInternalLinkRequest struct {
// Expected type of the link
Type InternalLinkTypeClass
// Pass true to create an HTTPS link (only available for some link types); pass false to
// create a tg: link
IsHTTP bool
}
// GetInternalLinkRequestTypeID is TL type id of GetInternalLinkRequest.
const GetInternalLinkRequestTypeID = 0x3960f1b0
// Ensuring interfaces in compile-time for GetInternalLinkRequest.
var (
_ bin.Encoder = &GetInternalLinkRequest{}
_ bin.Decoder = &GetInternalLinkRequest{}
_ bin.BareEncoder = &GetInternalLinkRequest{}
_ bin.BareDecoder = &GetInternalLinkRequest{}
)
func (g *GetInternalLinkRequest) Zero() bool {
if g == nil {
return true
}
if !(g.Type == nil) {
return false
}
if !(g.IsHTTP == false) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *GetInternalLinkRequest) String() string {
if g == nil {
return "GetInternalLinkRequest(nil)"
}
type Alias GetInternalLinkRequest
return fmt.Sprintf("GetInternalLinkRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GetInternalLinkRequest) TypeID() uint32 {
return GetInternalLinkRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*GetInternalLinkRequest) TypeName() string {
return "getInternalLink"
}
// TypeInfo returns info about TL type.
func (g *GetInternalLinkRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "getInternalLink",
ID: GetInternalLinkRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Type",
SchemaName: "type",
},
{
Name: "IsHTTP",
SchemaName: "is_http",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *GetInternalLinkRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getInternalLink#3960f1b0 as nil")
}
b.PutID(GetInternalLinkRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *GetInternalLinkRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getInternalLink#3960f1b0 as nil")
}
if g.Type == nil {
return fmt.Errorf("unable to encode getInternalLink#3960f1b0: field type is nil")
}
if err := g.Type.Encode(b); err != nil {
return fmt.Errorf("unable to encode getInternalLink#3960f1b0: field type: %w", err)
}
b.PutBool(g.IsHTTP)
return nil
}
// Decode implements bin.Decoder.
func (g *GetInternalLinkRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getInternalLink#3960f1b0 to nil")
}
if err := b.ConsumeID(GetInternalLinkRequestTypeID); err != nil {
return fmt.Errorf("unable to decode getInternalLink#3960f1b0: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *GetInternalLinkRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getInternalLink#3960f1b0 to nil")
}
{
value, err := DecodeInternalLinkType(b)
if err != nil {
return fmt.Errorf("unable to decode getInternalLink#3960f1b0: field type: %w", err)
}
g.Type = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode getInternalLink#3960f1b0: field is_http: %w", err)
}
g.IsHTTP = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetInternalLinkRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if g == nil {
return fmt.Errorf("can't encode getInternalLink#3960f1b0 as nil")
}
b.ObjStart()
b.PutID("getInternalLink")
b.Comma()
b.FieldStart("type")
if g.Type == nil {
return fmt.Errorf("unable to encode getInternalLink#3960f1b0: field type is nil")
}
if err := g.Type.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode getInternalLink#3960f1b0: field type: %w", err)
}
b.Comma()
b.FieldStart("is_http")
b.PutBool(g.IsHTTP)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetInternalLinkRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if g == nil {
return fmt.Errorf("can't decode getInternalLink#3960f1b0 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("getInternalLink"); err != nil {
return fmt.Errorf("unable to decode getInternalLink#3960f1b0: %w", err)
}
case "type":
value, err := DecodeTDLibJSONInternalLinkType(b)
if err != nil {
return fmt.Errorf("unable to decode getInternalLink#3960f1b0: field type: %w", err)
}
g.Type = value
case "is_http":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode getInternalLink#3960f1b0: field is_http: %w", err)
}
g.IsHTTP = value
default:
return b.Skip()
}
return nil
})
}
// GetType returns value of Type field.
func (g *GetInternalLinkRequest) GetType() (value InternalLinkTypeClass) {
if g == nil {
return
}
return g.Type
}
// GetIsHTTP returns value of IsHTTP field.
func (g *GetInternalLinkRequest) GetIsHTTP() (value bool) {
if g == nil {
return
}
return g.IsHTTP
}
// GetInternalLink invokes method getInternalLink#3960f1b0 returning error if any.
func (c *Client) GetInternalLink(ctx context.Context, request *GetInternalLinkRequest) (*HTTPURL, error) {
var result HTTPURL
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}