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 ContactsUnblockRequest struct {
Flags bin .Fields
MyStoriesFrom bool
ID InputPeerClass
}
const ContactsUnblockRequestTypeID = 0xb550d328
var (
_ bin .Encoder = &ContactsUnblockRequest {}
_ bin .Decoder = &ContactsUnblockRequest {}
_ bin .BareEncoder = &ContactsUnblockRequest {}
_ bin .BareDecoder = &ContactsUnblockRequest {}
)
func (u *ContactsUnblockRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .MyStoriesFrom == false ) {
return false
}
if !(u .ID == nil ) {
return false
}
return true
}
func (u *ContactsUnblockRequest ) String () string {
if u == nil {
return "ContactsUnblockRequest(nil)"
}
type Alias ContactsUnblockRequest
return fmt .Sprintf ("ContactsUnblockRequest%+v" , Alias (*u ))
}
func (u *ContactsUnblockRequest ) FillFrom (from interface {
GetMyStoriesFrom () (value bool )
GetID () (value InputPeerClass )
}) {
u .MyStoriesFrom = from .GetMyStoriesFrom ()
u .ID = from .GetID ()
}
func (*ContactsUnblockRequest ) TypeID () uint32 {
return ContactsUnblockRequestTypeID
}
func (*ContactsUnblockRequest ) TypeName () string {
return "contacts.unblock"
}
func (u *ContactsUnblockRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.unblock" ,
ID : ContactsUnblockRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "MyStoriesFrom" ,
SchemaName : "my_stories_from" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (u *ContactsUnblockRequest ) SetFlags () {
if !(u .MyStoriesFrom == false ) {
u .Flags .Set (0 )
}
}
func (u *ContactsUnblockRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode contacts.unblock#b550d328 as nil" )
}
b .PutID (ContactsUnblockRequestTypeID )
return u .EncodeBare (b )
}
func (u *ContactsUnblockRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode contacts.unblock#b550d328 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.unblock#b550d328: field flags: %w" , err )
}
if u .ID == nil {
return fmt .Errorf ("unable to encode contacts.unblock#b550d328: field id is nil" )
}
if err := u .ID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.unblock#b550d328: field id: %w" , err )
}
return nil
}
func (u *ContactsUnblockRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode contacts.unblock#b550d328 to nil" )
}
if err := b .ConsumeID (ContactsUnblockRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.unblock#b550d328: %w" , err )
}
return u .DecodeBare (b )
}
func (u *ContactsUnblockRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode contacts.unblock#b550d328 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.unblock#b550d328: field flags: %w" , err )
}
}
u .MyStoriesFrom = u .Flags .Has (0 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode contacts.unblock#b550d328: field id: %w" , err )
}
u .ID = value
}
return nil
}
func (u *ContactsUnblockRequest ) SetMyStoriesFrom (value bool ) {
if value {
u .Flags .Set (0 )
u .MyStoriesFrom = true
} else {
u .Flags .Unset (0 )
u .MyStoriesFrom = false
}
}
func (u *ContactsUnblockRequest ) GetMyStoriesFrom () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (0 )
}
func (u *ContactsUnblockRequest ) GetID () (value InputPeerClass ) {
if u == nil {
return
}
return u .ID
}
func (c *Client ) ContactsUnblock (ctx context .Context , request *ContactsUnblockRequest ) (bool , error ) {
var result BoolBox
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 .