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 MessagesSetBotShippingResultsRequest struct {
Flags bin .Fields
QueryID int64
Error string
ShippingOptions []ShippingOption
}
const MessagesSetBotShippingResultsRequestTypeID = 0xe5f672fa
var (
_ bin .Encoder = &MessagesSetBotShippingResultsRequest {}
_ bin .Decoder = &MessagesSetBotShippingResultsRequest {}
_ bin .BareEncoder = &MessagesSetBotShippingResultsRequest {}
_ bin .BareDecoder = &MessagesSetBotShippingResultsRequest {}
)
func (s *MessagesSetBotShippingResultsRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .QueryID == 0 ) {
return false
}
if !(s .Error == "" ) {
return false
}
if !(s .ShippingOptions == nil ) {
return false
}
return true
}
func (s *MessagesSetBotShippingResultsRequest ) String () string {
if s == nil {
return "MessagesSetBotShippingResultsRequest(nil)"
}
type Alias MessagesSetBotShippingResultsRequest
return fmt .Sprintf ("MessagesSetBotShippingResultsRequest%+v" , Alias (*s ))
}
func (s *MessagesSetBotShippingResultsRequest ) FillFrom (from interface {
GetQueryID () (value int64 )
GetError () (value string , ok bool )
GetShippingOptions () (value []ShippingOption , ok bool )
}) {
s .QueryID = from .GetQueryID ()
if val , ok := from .GetError (); ok {
s .Error = val
}
if val , ok := from .GetShippingOptions (); ok {
s .ShippingOptions = val
}
}
func (*MessagesSetBotShippingResultsRequest ) TypeID () uint32 {
return MessagesSetBotShippingResultsRequestTypeID
}
func (*MessagesSetBotShippingResultsRequest ) TypeName () string {
return "messages.setBotShippingResults"
}
func (s *MessagesSetBotShippingResultsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setBotShippingResults" ,
ID : MessagesSetBotShippingResultsRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "QueryID" ,
SchemaName : "query_id" ,
},
{
Name : "Error" ,
SchemaName : "error" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "ShippingOptions" ,
SchemaName : "shipping_options" ,
Null : !s .Flags .Has (1 ),
},
}
return typ
}
func (s *MessagesSetBotShippingResultsRequest ) SetFlags () {
if !(s .Error == "" ) {
s .Flags .Set (0 )
}
if !(s .ShippingOptions == nil ) {
s .Flags .Set (1 )
}
}
func (s *MessagesSetBotShippingResultsRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setBotShippingResults#e5f672fa as nil" )
}
b .PutID (MessagesSetBotShippingResultsRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetBotShippingResultsRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setBotShippingResults#e5f672fa as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setBotShippingResults#e5f672fa: field flags: %w" , err )
}
b .PutLong (s .QueryID )
if s .Flags .Has (0 ) {
b .PutString (s .Error )
}
if s .Flags .Has (1 ) {
b .PutVectorHeader (len (s .ShippingOptions ))
for idx , v := range s .ShippingOptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setBotShippingResults#e5f672fa: field shipping_options element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (s *MessagesSetBotShippingResultsRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setBotShippingResults#e5f672fa to nil" )
}
if err := b .ConsumeID (MessagesSetBotShippingResultsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setBotShippingResults#e5f672fa: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetBotShippingResultsRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setBotShippingResults#e5f672fa to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setBotShippingResults#e5f672fa: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotShippingResults#e5f672fa: field query_id: %w" , err )
}
s .QueryID = value
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotShippingResults#e5f672fa: field error: %w" , err )
}
s .Error = value
}
if s .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotShippingResults#e5f672fa: field shipping_options: %w" , err )
}
if headerLen > 0 {
s .ShippingOptions = make ([]ShippingOption , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value ShippingOption
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setBotShippingResults#e5f672fa: field shipping_options: %w" , err )
}
s .ShippingOptions = append (s .ShippingOptions , value )
}
}
return nil
}
func (s *MessagesSetBotShippingResultsRequest ) GetQueryID () (value int64 ) {
if s == nil {
return
}
return s .QueryID
}
func (s *MessagesSetBotShippingResultsRequest ) SetError (value string ) {
s .Flags .Set (0 )
s .Error = value
}
func (s *MessagesSetBotShippingResultsRequest ) GetError () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Error , true
}
func (s *MessagesSetBotShippingResultsRequest ) SetShippingOptions (value []ShippingOption ) {
s .Flags .Set (1 )
s .ShippingOptions = value
}
func (s *MessagesSetBotShippingResultsRequest ) GetShippingOptions () (value []ShippingOption , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .ShippingOptions , true
}
func (c *Client ) MessagesSetBotShippingResults (ctx context .Context , request *MessagesSetBotShippingResultsRequest ) (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 .