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 ContactsGetLocatedRequest struct {
Flags bin .Fields
Background bool
GeoPoint InputGeoPointClass
SelfExpires int
}
const ContactsGetLocatedRequestTypeID = 0xd348bc44
var (
_ bin .Encoder = &ContactsGetLocatedRequest {}
_ bin .Decoder = &ContactsGetLocatedRequest {}
_ bin .BareEncoder = &ContactsGetLocatedRequest {}
_ bin .BareDecoder = &ContactsGetLocatedRequest {}
)
func (g *ContactsGetLocatedRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Background == false ) {
return false
}
if !(g .GeoPoint == nil ) {
return false
}
if !(g .SelfExpires == 0 ) {
return false
}
return true
}
func (g *ContactsGetLocatedRequest ) String () string {
if g == nil {
return "ContactsGetLocatedRequest(nil)"
}
type Alias ContactsGetLocatedRequest
return fmt .Sprintf ("ContactsGetLocatedRequest%+v" , Alias (*g ))
}
func (g *ContactsGetLocatedRequest ) FillFrom (from interface {
GetBackground () (value bool )
GetGeoPoint () (value InputGeoPointClass )
GetSelfExpires () (value int , ok bool )
}) {
g .Background = from .GetBackground ()
g .GeoPoint = from .GetGeoPoint ()
if val , ok := from .GetSelfExpires (); ok {
g .SelfExpires = val
}
}
func (*ContactsGetLocatedRequest ) TypeID () uint32 {
return ContactsGetLocatedRequestTypeID
}
func (*ContactsGetLocatedRequest ) TypeName () string {
return "contacts.getLocated"
}
func (g *ContactsGetLocatedRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.getLocated" ,
ID : ContactsGetLocatedRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Background" ,
SchemaName : "background" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "GeoPoint" ,
SchemaName : "geo_point" ,
},
{
Name : "SelfExpires" ,
SchemaName : "self_expires" ,
Null : !g .Flags .Has (0 ),
},
}
return typ
}
func (g *ContactsGetLocatedRequest ) SetFlags () {
if !(g .Background == false ) {
g .Flags .Set (1 )
}
if !(g .SelfExpires == 0 ) {
g .Flags .Set (0 )
}
}
func (g *ContactsGetLocatedRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode contacts.getLocated#d348bc44 as nil" )
}
b .PutID (ContactsGetLocatedRequestTypeID )
return g .EncodeBare (b )
}
func (g *ContactsGetLocatedRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode contacts.getLocated#d348bc44 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.getLocated#d348bc44: field flags: %w" , err )
}
if g .GeoPoint == nil {
return fmt .Errorf ("unable to encode contacts.getLocated#d348bc44: field geo_point is nil" )
}
if err := g .GeoPoint .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.getLocated#d348bc44: field geo_point: %w" , err )
}
if g .Flags .Has (0 ) {
b .PutInt (g .SelfExpires )
}
return nil
}
func (g *ContactsGetLocatedRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode contacts.getLocated#d348bc44 to nil" )
}
if err := b .ConsumeID (ContactsGetLocatedRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.getLocated#d348bc44: %w" , err )
}
return g .DecodeBare (b )
}
func (g *ContactsGetLocatedRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode contacts.getLocated#d348bc44 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.getLocated#d348bc44: field flags: %w" , err )
}
}
g .Background = g .Flags .Has (1 )
{
value , err := DecodeInputGeoPoint (b )
if err != nil {
return fmt .Errorf ("unable to decode contacts.getLocated#d348bc44: field geo_point: %w" , err )
}
g .GeoPoint = value
}
if g .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.getLocated#d348bc44: field self_expires: %w" , err )
}
g .SelfExpires = value
}
return nil
}
func (g *ContactsGetLocatedRequest ) SetBackground (value bool ) {
if value {
g .Flags .Set (1 )
g .Background = true
} else {
g .Flags .Unset (1 )
g .Background = false
}
}
func (g *ContactsGetLocatedRequest ) GetBackground () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *ContactsGetLocatedRequest ) GetGeoPoint () (value InputGeoPointClass ) {
if g == nil {
return
}
return g .GeoPoint
}
func (g *ContactsGetLocatedRequest ) SetSelfExpires (value int ) {
g .Flags .Set (0 )
g .SelfExpires = value
}
func (g *ContactsGetLocatedRequest ) GetSelfExpires () (value int , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .SelfExpires , true
}
func (g *ContactsGetLocatedRequest ) GetGeoPointAsNotEmpty () (*InputGeoPoint , bool ) {
return g .GeoPoint .AsNotEmpty ()
}
func (c *Client ) ContactsGetLocated (ctx context .Context , request *ContactsGetLocatedRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .