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 MessagesSetDefaultHistoryTTLRequest struct {
Period int
}
const MessagesSetDefaultHistoryTTLRequestTypeID = 0x9eb51445
var (
_ bin .Encoder = &MessagesSetDefaultHistoryTTLRequest {}
_ bin .Decoder = &MessagesSetDefaultHistoryTTLRequest {}
_ bin .BareEncoder = &MessagesSetDefaultHistoryTTLRequest {}
_ bin .BareDecoder = &MessagesSetDefaultHistoryTTLRequest {}
)
func (s *MessagesSetDefaultHistoryTTLRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Period == 0 ) {
return false
}
return true
}
func (s *MessagesSetDefaultHistoryTTLRequest ) String () string {
if s == nil {
return "MessagesSetDefaultHistoryTTLRequest(nil)"
}
type Alias MessagesSetDefaultHistoryTTLRequest
return fmt .Sprintf ("MessagesSetDefaultHistoryTTLRequest%+v" , Alias (*s ))
}
func (s *MessagesSetDefaultHistoryTTLRequest ) FillFrom (from interface {
GetPeriod () (value int )
}) {
s .Period = from .GetPeriod ()
}
func (*MessagesSetDefaultHistoryTTLRequest ) TypeID () uint32 {
return MessagesSetDefaultHistoryTTLRequestTypeID
}
func (*MessagesSetDefaultHistoryTTLRequest ) TypeName () string {
return "messages.setDefaultHistoryTTL"
}
func (s *MessagesSetDefaultHistoryTTLRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setDefaultHistoryTTL" ,
ID : MessagesSetDefaultHistoryTTLRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Period" ,
SchemaName : "period" ,
},
}
return typ
}
func (s *MessagesSetDefaultHistoryTTLRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setDefaultHistoryTTL#9eb51445 as nil" )
}
b .PutID (MessagesSetDefaultHistoryTTLRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetDefaultHistoryTTLRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setDefaultHistoryTTL#9eb51445 as nil" )
}
b .PutInt (s .Period )
return nil
}
func (s *MessagesSetDefaultHistoryTTLRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setDefaultHistoryTTL#9eb51445 to nil" )
}
if err := b .ConsumeID (MessagesSetDefaultHistoryTTLRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setDefaultHistoryTTL#9eb51445: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetDefaultHistoryTTLRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setDefaultHistoryTTL#9eb51445 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setDefaultHistoryTTL#9eb51445: field period: %w" , err )
}
s .Period = value
}
return nil
}
func (s *MessagesSetDefaultHistoryTTLRequest ) GetPeriod () (value int ) {
if s == nil {
return
}
return s .Period
}
func (c *Client ) MessagesSetDefaultHistoryTTL (ctx context .Context , period int ) (bool , error ) {
var result BoolBox
request := &MessagesSetDefaultHistoryTTLRequest {
Period : period ,
}
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 .