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 BotsUpdateStarRefProgramRequest struct {
Flags bin .Fields
Bot InputUserClass
CommissionPermille int
DurationMonths int
}
const BotsUpdateStarRefProgramRequestTypeID = 0x778b5ab3
var (
_ bin .Encoder = &BotsUpdateStarRefProgramRequest {}
_ bin .Decoder = &BotsUpdateStarRefProgramRequest {}
_ bin .BareEncoder = &BotsUpdateStarRefProgramRequest {}
_ bin .BareDecoder = &BotsUpdateStarRefProgramRequest {}
)
func (u *BotsUpdateStarRefProgramRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Bot == nil ) {
return false
}
if !(u .CommissionPermille == 0 ) {
return false
}
if !(u .DurationMonths == 0 ) {
return false
}
return true
}
func (u *BotsUpdateStarRefProgramRequest ) String () string {
if u == nil {
return "BotsUpdateStarRefProgramRequest(nil)"
}
type Alias BotsUpdateStarRefProgramRequest
return fmt .Sprintf ("BotsUpdateStarRefProgramRequest%+v" , Alias (*u ))
}
func (u *BotsUpdateStarRefProgramRequest ) FillFrom (from interface {
GetBot () (value InputUserClass )
GetCommissionPermille () (value int )
GetDurationMonths () (value int , ok bool )
}) {
u .Bot = from .GetBot ()
u .CommissionPermille = from .GetCommissionPermille ()
if val , ok := from .GetDurationMonths (); ok {
u .DurationMonths = val
}
}
func (*BotsUpdateStarRefProgramRequest ) TypeID () uint32 {
return BotsUpdateStarRefProgramRequestTypeID
}
func (*BotsUpdateStarRefProgramRequest ) TypeName () string {
return "bots.updateStarRefProgram"
}
func (u *BotsUpdateStarRefProgramRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.updateStarRefProgram" ,
ID : BotsUpdateStarRefProgramRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "CommissionPermille" ,
SchemaName : "commission_permille" ,
},
{
Name : "DurationMonths" ,
SchemaName : "duration_months" ,
Null : !u .Flags .Has (0 ),
},
}
return typ
}
func (u *BotsUpdateStarRefProgramRequest ) SetFlags () {
if !(u .DurationMonths == 0 ) {
u .Flags .Set (0 )
}
}
func (u *BotsUpdateStarRefProgramRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode bots.updateStarRefProgram#778b5ab3 as nil" )
}
b .PutID (BotsUpdateStarRefProgramRequestTypeID )
return u .EncodeBare (b )
}
func (u *BotsUpdateStarRefProgramRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode bots.updateStarRefProgram#778b5ab3 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.updateStarRefProgram#778b5ab3: field flags: %w" , err )
}
if u .Bot == nil {
return fmt .Errorf ("unable to encode bots.updateStarRefProgram#778b5ab3: field bot is nil" )
}
if err := u .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.updateStarRefProgram#778b5ab3: field bot: %w" , err )
}
b .PutInt (u .CommissionPermille )
if u .Flags .Has (0 ) {
b .PutInt (u .DurationMonths )
}
return nil
}
func (u *BotsUpdateStarRefProgramRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode bots.updateStarRefProgram#778b5ab3 to nil" )
}
if err := b .ConsumeID (BotsUpdateStarRefProgramRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.updateStarRefProgram#778b5ab3: %w" , err )
}
return u .DecodeBare (b )
}
func (u *BotsUpdateStarRefProgramRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode bots.updateStarRefProgram#778b5ab3 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode bots.updateStarRefProgram#778b5ab3: field flags: %w" , err )
}
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.updateStarRefProgram#778b5ab3: field bot: %w" , err )
}
u .Bot = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode bots.updateStarRefProgram#778b5ab3: field commission_permille: %w" , err )
}
u .CommissionPermille = value
}
if u .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode bots.updateStarRefProgram#778b5ab3: field duration_months: %w" , err )
}
u .DurationMonths = value
}
return nil
}
func (u *BotsUpdateStarRefProgramRequest ) GetBot () (value InputUserClass ) {
if u == nil {
return
}
return u .Bot
}
func (u *BotsUpdateStarRefProgramRequest ) GetCommissionPermille () (value int ) {
if u == nil {
return
}
return u .CommissionPermille
}
func (u *BotsUpdateStarRefProgramRequest ) SetDurationMonths (value int ) {
u .Flags .Set (0 )
u .DurationMonths = value
}
func (u *BotsUpdateStarRefProgramRequest ) GetDurationMonths () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .DurationMonths , true
}
func (c *Client ) BotsUpdateStarRefProgram (ctx context .Context , request *BotsUpdateStarRefProgramRequest ) (*StarRefProgram , error ) {
var result StarRefProgram
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .