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

284 lines
7.3 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{}
)
// GetStarWithdrawalURLRequest represents TL type `getStarWithdrawalUrl#a9d23712`.
type GetStarWithdrawalURLRequest struct {
// Identifier of the owner of the Telegram Stars; can be identifier of the current user,
// an owned bot, or an owned supergroup or channel chat
OwnerID MessageSenderClass
// The number of Telegram Stars to withdraw. Must be at least
// getOption("star_withdrawal_count_min")
StarCount int64
// The 2-step verification password of the current user
Password string
}
// GetStarWithdrawalURLRequestTypeID is TL type id of GetStarWithdrawalURLRequest.
const GetStarWithdrawalURLRequestTypeID = 0xa9d23712
// Ensuring interfaces in compile-time for GetStarWithdrawalURLRequest.
var (
_ bin.Encoder = &GetStarWithdrawalURLRequest{}
_ bin.Decoder = &GetStarWithdrawalURLRequest{}
_ bin.BareEncoder = &GetStarWithdrawalURLRequest{}
_ bin.BareDecoder = &GetStarWithdrawalURLRequest{}
)
func (g *GetStarWithdrawalURLRequest) Zero() bool {
if g == nil {
return true
}
if !(g.OwnerID == nil) {
return false
}
if !(g.StarCount == 0) {
return false
}
if !(g.Password == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *GetStarWithdrawalURLRequest) String() string {
if g == nil {
return "GetStarWithdrawalURLRequest(nil)"
}
type Alias GetStarWithdrawalURLRequest
return fmt.Sprintf("GetStarWithdrawalURLRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GetStarWithdrawalURLRequest) TypeID() uint32 {
return GetStarWithdrawalURLRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*GetStarWithdrawalURLRequest) TypeName() string {
return "getStarWithdrawalUrl"
}
// TypeInfo returns info about TL type.
func (g *GetStarWithdrawalURLRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "getStarWithdrawalUrl",
ID: GetStarWithdrawalURLRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "OwnerID",
SchemaName: "owner_id",
},
{
Name: "StarCount",
SchemaName: "star_count",
},
{
Name: "Password",
SchemaName: "password",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *GetStarWithdrawalURLRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getStarWithdrawalUrl#a9d23712 as nil")
}
b.PutID(GetStarWithdrawalURLRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *GetStarWithdrawalURLRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getStarWithdrawalUrl#a9d23712 as nil")
}
if g.OwnerID == nil {
return fmt.Errorf("unable to encode getStarWithdrawalUrl#a9d23712: field owner_id is nil")
}
if err := g.OwnerID.Encode(b); err != nil {
return fmt.Errorf("unable to encode getStarWithdrawalUrl#a9d23712: field owner_id: %w", err)
}
b.PutInt53(g.StarCount)
b.PutString(g.Password)
return nil
}
// Decode implements bin.Decoder.
func (g *GetStarWithdrawalURLRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getStarWithdrawalUrl#a9d23712 to nil")
}
if err := b.ConsumeID(GetStarWithdrawalURLRequestTypeID); err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *GetStarWithdrawalURLRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getStarWithdrawalUrl#a9d23712 to nil")
}
{
value, err := DecodeMessageSender(b)
if err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: field owner_id: %w", err)
}
g.OwnerID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: field star_count: %w", err)
}
g.StarCount = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: field password: %w", err)
}
g.Password = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetStarWithdrawalURLRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if g == nil {
return fmt.Errorf("can't encode getStarWithdrawalUrl#a9d23712 as nil")
}
b.ObjStart()
b.PutID("getStarWithdrawalUrl")
b.Comma()
b.FieldStart("owner_id")
if g.OwnerID == nil {
return fmt.Errorf("unable to encode getStarWithdrawalUrl#a9d23712: field owner_id is nil")
}
if err := g.OwnerID.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode getStarWithdrawalUrl#a9d23712: field owner_id: %w", err)
}
b.Comma()
b.FieldStart("star_count")
b.PutInt53(g.StarCount)
b.Comma()
b.FieldStart("password")
b.PutString(g.Password)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetStarWithdrawalURLRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if g == nil {
return fmt.Errorf("can't decode getStarWithdrawalUrl#a9d23712 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("getStarWithdrawalUrl"); err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: %w", err)
}
case "owner_id":
value, err := DecodeTDLibJSONMessageSender(b)
if err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: field owner_id: %w", err)
}
g.OwnerID = value
case "star_count":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: field star_count: %w", err)
}
g.StarCount = value
case "password":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getStarWithdrawalUrl#a9d23712: field password: %w", err)
}
g.Password = value
default:
return b.Skip()
}
return nil
})
}
// GetOwnerID returns value of OwnerID field.
func (g *GetStarWithdrawalURLRequest) GetOwnerID() (value MessageSenderClass) {
if g == nil {
return
}
return g.OwnerID
}
// GetStarCount returns value of StarCount field.
func (g *GetStarWithdrawalURLRequest) GetStarCount() (value int64) {
if g == nil {
return
}
return g.StarCount
}
// GetPassword returns value of Password field.
func (g *GetStarWithdrawalURLRequest) GetPassword() (value string) {
if g == nil {
return
}
return g.Password
}
// GetStarWithdrawalURL invokes method getStarWithdrawalUrl#a9d23712 returning error if any.
func (c *Client) GetStarWithdrawalURL(ctx context.Context, request *GetStarWithdrawalURLRequest) (*HTTPURL, error) {
var result HTTPURL
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}