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 PaymentsCanPurchasePremiumRequest struct {
Purpose InputStorePaymentPurposeClass
}
const PaymentsCanPurchasePremiumRequestTypeID = 0x9fc19eb6
var (
_ bin .Encoder = &PaymentsCanPurchasePremiumRequest {}
_ bin .Decoder = &PaymentsCanPurchasePremiumRequest {}
_ bin .BareEncoder = &PaymentsCanPurchasePremiumRequest {}
_ bin .BareDecoder = &PaymentsCanPurchasePremiumRequest {}
)
func (c *PaymentsCanPurchasePremiumRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Purpose == nil ) {
return false
}
return true
}
func (c *PaymentsCanPurchasePremiumRequest ) String () string {
if c == nil {
return "PaymentsCanPurchasePremiumRequest(nil)"
}
type Alias PaymentsCanPurchasePremiumRequest
return fmt .Sprintf ("PaymentsCanPurchasePremiumRequest%+v" , Alias (*c ))
}
func (c *PaymentsCanPurchasePremiumRequest ) FillFrom (from interface {
GetPurpose () (value InputStorePaymentPurposeClass )
}) {
c .Purpose = from .GetPurpose ()
}
func (*PaymentsCanPurchasePremiumRequest ) TypeID () uint32 {
return PaymentsCanPurchasePremiumRequestTypeID
}
func (*PaymentsCanPurchasePremiumRequest ) TypeName () string {
return "payments.canPurchasePremium"
}
func (c *PaymentsCanPurchasePremiumRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.canPurchasePremium" ,
ID : PaymentsCanPurchasePremiumRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Purpose" ,
SchemaName : "purpose" ,
},
}
return typ
}
func (c *PaymentsCanPurchasePremiumRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode payments.canPurchasePremium#9fc19eb6 as nil" )
}
b .PutID (PaymentsCanPurchasePremiumRequestTypeID )
return c .EncodeBare (b )
}
func (c *PaymentsCanPurchasePremiumRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode payments.canPurchasePremium#9fc19eb6 as nil" )
}
if c .Purpose == nil {
return fmt .Errorf ("unable to encode payments.canPurchasePremium#9fc19eb6: field purpose is nil" )
}
if err := c .Purpose .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.canPurchasePremium#9fc19eb6: field purpose: %w" , err )
}
return nil
}
func (c *PaymentsCanPurchasePremiumRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode payments.canPurchasePremium#9fc19eb6 to nil" )
}
if err := b .ConsumeID (PaymentsCanPurchasePremiumRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.canPurchasePremium#9fc19eb6: %w" , err )
}
return c .DecodeBare (b )
}
func (c *PaymentsCanPurchasePremiumRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode payments.canPurchasePremium#9fc19eb6 to nil" )
}
{
value , err := DecodeInputStorePaymentPurpose (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.canPurchasePremium#9fc19eb6: field purpose: %w" , err )
}
c .Purpose = value
}
return nil
}
func (c *PaymentsCanPurchasePremiumRequest ) GetPurpose () (value InputStorePaymentPurposeClass ) {
if c == nil {
return
}
return c .Purpose
}
func (c *Client ) PaymentsCanPurchasePremium (ctx context .Context , purpose InputStorePaymentPurposeClass ) (bool , error ) {
var result BoolBox
request := &PaymentsCanPurchasePremiumRequest {
Purpose : purpose ,
}
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.6.7 . (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .