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