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 BusinessLocation struct {
Flags bin .Fields
GeoPoint GeoPointClass
Address string
}
const BusinessLocationTypeID = 0xac5c1af7
var (
_ bin .Encoder = &BusinessLocation {}
_ bin .Decoder = &BusinessLocation {}
_ bin .BareEncoder = &BusinessLocation {}
_ bin .BareDecoder = &BusinessLocation {}
)
func (b *BusinessLocation ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .GeoPoint == nil ) {
return false
}
if !(b .Address == "" ) {
return false
}
return true
}
func (b *BusinessLocation ) String () string {
if b == nil {
return "BusinessLocation(nil)"
}
type Alias BusinessLocation
return fmt .Sprintf ("BusinessLocation%+v" , Alias (*b ))
}
func (b *BusinessLocation ) FillFrom (from interface {
GetGeoPoint () (value GeoPointClass , ok bool )
GetAddress () (value string )
}) {
if val , ok := from .GetGeoPoint (); ok {
b .GeoPoint = val
}
b .Address = from .GetAddress ()
}
func (*BusinessLocation ) TypeID () uint32 {
return BusinessLocationTypeID
}
func (*BusinessLocation ) TypeName () string {
return "businessLocation"
}
func (b *BusinessLocation ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "businessLocation" ,
ID : BusinessLocationTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "GeoPoint" ,
SchemaName : "geo_point" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "Address" ,
SchemaName : "address" ,
},
}
return typ
}
func (b *BusinessLocation ) SetFlags () {
if !(b .GeoPoint == nil ) {
b .Flags .Set (0 )
}
}
func (b *BusinessLocation ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode businessLocation#ac5c1af7 as nil" )
}
buf .PutID (BusinessLocationTypeID )
return b .EncodeBare (buf )
}
func (b *BusinessLocation ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode businessLocation#ac5c1af7 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode businessLocation#ac5c1af7: field flags: %w" , err )
}
if b .Flags .Has (0 ) {
if b .GeoPoint == nil {
return fmt .Errorf ("unable to encode businessLocation#ac5c1af7: field geo_point is nil" )
}
if err := b .GeoPoint .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode businessLocation#ac5c1af7: field geo_point: %w" , err )
}
}
buf .PutString (b .Address )
return nil
}
func (b *BusinessLocation ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode businessLocation#ac5c1af7 to nil" )
}
if err := buf .ConsumeID (BusinessLocationTypeID ); err != nil {
return fmt .Errorf ("unable to decode businessLocation#ac5c1af7: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BusinessLocation ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode businessLocation#ac5c1af7 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode businessLocation#ac5c1af7: field flags: %w" , err )
}
}
if b .Flags .Has (0 ) {
value , err := DecodeGeoPoint (buf )
if err != nil {
return fmt .Errorf ("unable to decode businessLocation#ac5c1af7: field geo_point: %w" , err )
}
b .GeoPoint = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode businessLocation#ac5c1af7: field address: %w" , err )
}
b .Address = value
}
return nil
}
func (b *BusinessLocation ) SetGeoPoint (value GeoPointClass ) {
b .Flags .Set (0 )
b .GeoPoint = value
}
func (b *BusinessLocation ) GetGeoPoint () (value GeoPointClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .GeoPoint , true
}
func (b *BusinessLocation ) GetAddress () (value string ) {
if b == nil {
return
}
return b .Address
}
func (b *BusinessLocation ) GetGeoPointAsNotEmpty () (*GeoPoint , bool ) {
if value , ok := b .GetGeoPoint (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
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 .