package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type PaymentsBotCancelStarsSubscriptionRequest struct {
Flags bin .Fields
Restore bool
UserID InputUserClass
ChargeID string
}
const PaymentsBotCancelStarsSubscriptionRequestTypeID = 0x6dfa0622
var (
_ bin .Encoder = &PaymentsBotCancelStarsSubscriptionRequest {}
_ bin .Decoder = &PaymentsBotCancelStarsSubscriptionRequest {}
_ bin .BareEncoder = &PaymentsBotCancelStarsSubscriptionRequest {}
_ bin .BareDecoder = &PaymentsBotCancelStarsSubscriptionRequest {}
)
func (b *PaymentsBotCancelStarsSubscriptionRequest ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .Restore == false ) {
return false
}
if !(b .UserID == nil ) {
return false
}
if !(b .ChargeID == "" ) {
return false
}
return true
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) String () string {
if b == nil {
return "PaymentsBotCancelStarsSubscriptionRequest(nil)"
}
type Alias PaymentsBotCancelStarsSubscriptionRequest
return fmt .Sprintf ("PaymentsBotCancelStarsSubscriptionRequest%+v" , Alias (*b ))
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) FillFrom (from interface {
GetRestore () (value bool )
GetUserID () (value InputUserClass )
GetChargeID () (value string )
}) {
b .Restore = from .GetRestore ()
b .UserID = from .GetUserID ()
b .ChargeID = from .GetChargeID ()
}
func (*PaymentsBotCancelStarsSubscriptionRequest ) TypeID () uint32 {
return PaymentsBotCancelStarsSubscriptionRequestTypeID
}
func (*PaymentsBotCancelStarsSubscriptionRequest ) TypeName () string {
return "payments.botCancelStarsSubscription"
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.botCancelStarsSubscription" ,
ID : PaymentsBotCancelStarsSubscriptionRequestTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Restore" ,
SchemaName : "restore" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "ChargeID" ,
SchemaName : "charge_id" ,
},
}
return typ
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) SetFlags () {
if !(b .Restore == false ) {
b .Flags .Set (0 )
}
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode payments.botCancelStarsSubscription#6dfa0622 as nil" )
}
buf .PutID (PaymentsBotCancelStarsSubscriptionRequestTypeID )
return b .EncodeBare (buf )
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode payments.botCancelStarsSubscription#6dfa0622 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode payments.botCancelStarsSubscription#6dfa0622: field flags: %w" , err )
}
if b .UserID == nil {
return fmt .Errorf ("unable to encode payments.botCancelStarsSubscription#6dfa0622: field user_id is nil" )
}
if err := b .UserID .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode payments.botCancelStarsSubscription#6dfa0622: field user_id: %w" , err )
}
buf .PutString (b .ChargeID )
return nil
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode payments.botCancelStarsSubscription#6dfa0622 to nil" )
}
if err := buf .ConsumeID (PaymentsBotCancelStarsSubscriptionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.botCancelStarsSubscription#6dfa0622: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode payments.botCancelStarsSubscription#6dfa0622 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode payments.botCancelStarsSubscription#6dfa0622: field flags: %w" , err )
}
}
b .Restore = b .Flags .Has (0 )
{
value , err := DecodeInputUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode payments.botCancelStarsSubscription#6dfa0622: field user_id: %w" , err )
}
b .UserID = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.botCancelStarsSubscription#6dfa0622: field charge_id: %w" , err )
}
b .ChargeID = value
}
return nil
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) SetRestore (value bool ) {
if value {
b .Flags .Set (0 )
b .Restore = true
} else {
b .Flags .Unset (0 )
b .Restore = false
}
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) GetRestore () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (0 )
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) GetUserID () (value InputUserClass ) {
if b == nil {
return
}
return b .UserID
}
func (b *PaymentsBotCancelStarsSubscriptionRequest ) GetChargeID () (value string ) {
if b == nil {
return
}
return b .ChargeID
}
func (c *Client ) PaymentsBotCancelStarsSubscription (ctx context .Context , request *PaymentsBotCancelStarsSubscriptionRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .