240 lines
7.2 KiB
Go
Generated
240 lines
7.2 KiB
Go
Generated
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
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{}
|
|
)
|
|
|
|
// PaymentsTransferStarGiftRequest represents TL type `payments.transferStarGift#7f18176a`.
|
|
// Transfer a collectible gift¹ to another user or channel: can only be used if transfer
|
|
// is free (i.e. messageActionStarGiftUnique².transfer_stars is not set); see here »³
|
|
// for more info on the full flow (including the different flow to use in case the
|
|
// transfer isn't free).
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/gifts#collectible-gifts
|
|
// 2. https://core.telegram.org/constructor/messageActionStarGiftUnique
|
|
// 3. https://core.telegram.org/api/gifts#transferring-collectible-gifts
|
|
//
|
|
// See https://core.telegram.org/method/payments.transferStarGift for reference.
|
|
type PaymentsTransferStarGiftRequest struct {
|
|
// The gift to transfer.
|
|
Stargift InputSavedStarGiftClass
|
|
// Destination peer.
|
|
ToID InputPeerClass
|
|
}
|
|
|
|
// PaymentsTransferStarGiftRequestTypeID is TL type id of PaymentsTransferStarGiftRequest.
|
|
const PaymentsTransferStarGiftRequestTypeID = 0x7f18176a
|
|
|
|
// Ensuring interfaces in compile-time for PaymentsTransferStarGiftRequest.
|
|
var (
|
|
_ bin.Encoder = &PaymentsTransferStarGiftRequest{}
|
|
_ bin.Decoder = &PaymentsTransferStarGiftRequest{}
|
|
_ bin.BareEncoder = &PaymentsTransferStarGiftRequest{}
|
|
_ bin.BareDecoder = &PaymentsTransferStarGiftRequest{}
|
|
)
|
|
|
|
func (t *PaymentsTransferStarGiftRequest) Zero() bool {
|
|
if t == nil {
|
|
return true
|
|
}
|
|
if !(t.Stargift == nil) {
|
|
return false
|
|
}
|
|
if !(t.ToID == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (t *PaymentsTransferStarGiftRequest) String() string {
|
|
if t == nil {
|
|
return "PaymentsTransferStarGiftRequest(nil)"
|
|
}
|
|
type Alias PaymentsTransferStarGiftRequest
|
|
return fmt.Sprintf("PaymentsTransferStarGiftRequest%+v", Alias(*t))
|
|
}
|
|
|
|
// FillFrom fills PaymentsTransferStarGiftRequest from given interface.
|
|
func (t *PaymentsTransferStarGiftRequest) FillFrom(from interface {
|
|
GetStargift() (value InputSavedStarGiftClass)
|
|
GetToID() (value InputPeerClass)
|
|
}) {
|
|
t.Stargift = from.GetStargift()
|
|
t.ToID = from.GetToID()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PaymentsTransferStarGiftRequest) TypeID() uint32 {
|
|
return PaymentsTransferStarGiftRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PaymentsTransferStarGiftRequest) TypeName() string {
|
|
return "payments.transferStarGift"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (t *PaymentsTransferStarGiftRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "payments.transferStarGift",
|
|
ID: PaymentsTransferStarGiftRequestTypeID,
|
|
}
|
|
if t == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Stargift",
|
|
SchemaName: "stargift",
|
|
},
|
|
{
|
|
Name: "ToID",
|
|
SchemaName: "to_id",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (t *PaymentsTransferStarGiftRequest) Encode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode payments.transferStarGift#7f18176a as nil")
|
|
}
|
|
b.PutID(PaymentsTransferStarGiftRequestTypeID)
|
|
return t.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (t *PaymentsTransferStarGiftRequest) EncodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode payments.transferStarGift#7f18176a as nil")
|
|
}
|
|
if t.Stargift == nil {
|
|
return fmt.Errorf("unable to encode payments.transferStarGift#7f18176a: field stargift is nil")
|
|
}
|
|
if err := t.Stargift.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode payments.transferStarGift#7f18176a: field stargift: %w", err)
|
|
}
|
|
if t.ToID == nil {
|
|
return fmt.Errorf("unable to encode payments.transferStarGift#7f18176a: field to_id is nil")
|
|
}
|
|
if err := t.ToID.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode payments.transferStarGift#7f18176a: field to_id: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (t *PaymentsTransferStarGiftRequest) Decode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode payments.transferStarGift#7f18176a to nil")
|
|
}
|
|
if err := b.ConsumeID(PaymentsTransferStarGiftRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode payments.transferStarGift#7f18176a: %w", err)
|
|
}
|
|
return t.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (t *PaymentsTransferStarGiftRequest) DecodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode payments.transferStarGift#7f18176a to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputSavedStarGift(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode payments.transferStarGift#7f18176a: field stargift: %w", err)
|
|
}
|
|
t.Stargift = value
|
|
}
|
|
{
|
|
value, err := DecodeInputPeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode payments.transferStarGift#7f18176a: field to_id: %w", err)
|
|
}
|
|
t.ToID = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetStargift returns value of Stargift field.
|
|
func (t *PaymentsTransferStarGiftRequest) GetStargift() (value InputSavedStarGiftClass) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Stargift
|
|
}
|
|
|
|
// GetToID returns value of ToID field.
|
|
func (t *PaymentsTransferStarGiftRequest) GetToID() (value InputPeerClass) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.ToID
|
|
}
|
|
|
|
// PaymentsTransferStarGift invokes method payments.transferStarGift#7f18176a returning error if any.
|
|
// Transfer a collectible gift¹ to another user or channel: can only be used if transfer
|
|
// is free (i.e. messageActionStarGiftUnique².transfer_stars is not set); see here »³
|
|
// for more info on the full flow (including the different flow to use in case the
|
|
// transfer isn't free).
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/gifts#collectible-gifts
|
|
// 2. https://core.telegram.org/constructor/messageActionStarGiftUnique
|
|
// 3. https://core.telegram.org/api/gifts#transferring-collectible-gifts
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 400 BUSINESS_CONNECTION_INVALID: The connection_id passed to the wrapping invokeWithBusinessConnection call is invalid.
|
|
// 400 MESSAGE_ID_INVALID: The provided message id is invalid.
|
|
// 400 PAYMENT_REQUIRED: Payment is required for this action, see here » for more info.
|
|
// 400 PEER_ID_INVALID: The provided peer id is invalid.
|
|
// 400 SAVED_ID_EMPTY: The passed inputSavedStarGiftChat.saved_id is empty.
|
|
// 400 STARGIFT_NOT_FOUND: The specified gift was not found.
|
|
// 400 STARGIFT_OWNER_INVALID: You cannot transfer or sell a gift owned by another user.
|
|
// 400 STARGIFT_PEER_INVALID: The specified inputSavedStarGiftChat.peer is invalid.
|
|
//
|
|
// See https://core.telegram.org/method/payments.transferStarGift for reference.
|
|
func (c *Client) PaymentsTransferStarGift(ctx context.Context, request *PaymentsTransferStarGiftRequest) (UpdatesClass, error) {
|
|
var result UpdatesBox
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result.Updates, nil
|
|
}
|