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 SMSJobsStatus struct {
Flags bin .Fields
AllowInternational bool
RecentSent int
RecentSince int
RecentRemains int
TotalSent int
TotalSince int
LastGiftSlug string
TermsURL string
}
const SMSJobsStatusTypeID = 0x2aee9191
var (
_ bin .Encoder = &SMSJobsStatus {}
_ bin .Decoder = &SMSJobsStatus {}
_ bin .BareEncoder = &SMSJobsStatus {}
_ bin .BareDecoder = &SMSJobsStatus {}
)
func (s *SMSJobsStatus ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .AllowInternational == false ) {
return false
}
if !(s .RecentSent == 0 ) {
return false
}
if !(s .RecentSince == 0 ) {
return false
}
if !(s .RecentRemains == 0 ) {
return false
}
if !(s .TotalSent == 0 ) {
return false
}
if !(s .TotalSince == 0 ) {
return false
}
if !(s .LastGiftSlug == "" ) {
return false
}
if !(s .TermsURL == "" ) {
return false
}
return true
}
func (s *SMSJobsStatus ) String () string {
if s == nil {
return "SMSJobsStatus(nil)"
}
type Alias SMSJobsStatus
return fmt .Sprintf ("SMSJobsStatus%+v" , Alias (*s ))
}
func (s *SMSJobsStatus ) FillFrom (from interface {
GetAllowInternational () (value bool )
GetRecentSent () (value int )
GetRecentSince () (value int )
GetRecentRemains () (value int )
GetTotalSent () (value int )
GetTotalSince () (value int )
GetLastGiftSlug () (value string , ok bool )
GetTermsURL () (value string )
}) {
s .AllowInternational = from .GetAllowInternational ()
s .RecentSent = from .GetRecentSent ()
s .RecentSince = from .GetRecentSince ()
s .RecentRemains = from .GetRecentRemains ()
s .TotalSent = from .GetTotalSent ()
s .TotalSince = from .GetTotalSince ()
if val , ok := from .GetLastGiftSlug (); ok {
s .LastGiftSlug = val
}
s .TermsURL = from .GetTermsURL ()
}
func (*SMSJobsStatus ) TypeID () uint32 {
return SMSJobsStatusTypeID
}
func (*SMSJobsStatus ) TypeName () string {
return "smsjobs.status"
}
func (s *SMSJobsStatus ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "smsjobs.status" ,
ID : SMSJobsStatusTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "AllowInternational" ,
SchemaName : "allow_international" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "RecentSent" ,
SchemaName : "recent_sent" ,
},
{
Name : "RecentSince" ,
SchemaName : "recent_since" ,
},
{
Name : "RecentRemains" ,
SchemaName : "recent_remains" ,
},
{
Name : "TotalSent" ,
SchemaName : "total_sent" ,
},
{
Name : "TotalSince" ,
SchemaName : "total_since" ,
},
{
Name : "LastGiftSlug" ,
SchemaName : "last_gift_slug" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "TermsURL" ,
SchemaName : "terms_url" ,
},
}
return typ
}
func (s *SMSJobsStatus ) SetFlags () {
if !(s .AllowInternational == false ) {
s .Flags .Set (0 )
}
if !(s .LastGiftSlug == "" ) {
s .Flags .Set (1 )
}
}
func (s *SMSJobsStatus ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode smsjobs.status#2aee9191 as nil" )
}
b .PutID (SMSJobsStatusTypeID )
return s .EncodeBare (b )
}
func (s *SMSJobsStatus ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode smsjobs.status#2aee9191 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode smsjobs.status#2aee9191: field flags: %w" , err )
}
b .PutInt (s .RecentSent )
b .PutInt (s .RecentSince )
b .PutInt (s .RecentRemains )
b .PutInt (s .TotalSent )
b .PutInt (s .TotalSince )
if s .Flags .Has (1 ) {
b .PutString (s .LastGiftSlug )
}
b .PutString (s .TermsURL )
return nil
}
func (s *SMSJobsStatus ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode smsjobs.status#2aee9191 to nil" )
}
if err := b .ConsumeID (SMSJobsStatusTypeID ); err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SMSJobsStatus ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode smsjobs.status#2aee9191 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field flags: %w" , err )
}
}
s .AllowInternational = s .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field recent_sent: %w" , err )
}
s .RecentSent = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field recent_since: %w" , err )
}
s .RecentSince = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field recent_remains: %w" , err )
}
s .RecentRemains = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field total_sent: %w" , err )
}
s .TotalSent = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field total_since: %w" , err )
}
s .TotalSince = value
}
if s .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field last_gift_slug: %w" , err )
}
s .LastGiftSlug = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode smsjobs.status#2aee9191: field terms_url: %w" , err )
}
s .TermsURL = value
}
return nil
}
func (s *SMSJobsStatus ) SetAllowInternational (value bool ) {
if value {
s .Flags .Set (0 )
s .AllowInternational = true
} else {
s .Flags .Unset (0 )
s .AllowInternational = false
}
}
func (s *SMSJobsStatus ) GetAllowInternational () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *SMSJobsStatus ) GetRecentSent () (value int ) {
if s == nil {
return
}
return s .RecentSent
}
func (s *SMSJobsStatus ) GetRecentSince () (value int ) {
if s == nil {
return
}
return s .RecentSince
}
func (s *SMSJobsStatus ) GetRecentRemains () (value int ) {
if s == nil {
return
}
return s .RecentRemains
}
func (s *SMSJobsStatus ) GetTotalSent () (value int ) {
if s == nil {
return
}
return s .TotalSent
}
func (s *SMSJobsStatus ) GetTotalSince () (value int ) {
if s == nil {
return
}
return s .TotalSince
}
func (s *SMSJobsStatus ) SetLastGiftSlug (value string ) {
s .Flags .Set (1 )
s .LastGiftSlug = value
}
func (s *SMSJobsStatus ) GetLastGiftSlug () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .LastGiftSlug , true
}
func (s *SMSJobsStatus ) GetTermsURL () (value string ) {
if s == nil {
return
}
return s .TermsURL
}
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 .