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 MessagesSaveDefaultSendAsRequest struct {
Peer InputPeerClass
SendAs InputPeerClass
}
const MessagesSaveDefaultSendAsRequestTypeID = 0xccfddf96
var (
_ bin .Encoder = &MessagesSaveDefaultSendAsRequest {}
_ bin .Decoder = &MessagesSaveDefaultSendAsRequest {}
_ bin .BareEncoder = &MessagesSaveDefaultSendAsRequest {}
_ bin .BareDecoder = &MessagesSaveDefaultSendAsRequest {}
)
func (s *MessagesSaveDefaultSendAsRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Peer == nil ) {
return false
}
if !(s .SendAs == nil ) {
return false
}
return true
}
func (s *MessagesSaveDefaultSendAsRequest ) String () string {
if s == nil {
return "MessagesSaveDefaultSendAsRequest(nil)"
}
type Alias MessagesSaveDefaultSendAsRequest
return fmt .Sprintf ("MessagesSaveDefaultSendAsRequest%+v" , Alias (*s ))
}
func (s *MessagesSaveDefaultSendAsRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetSendAs () (value InputPeerClass )
}) {
s .Peer = from .GetPeer ()
s .SendAs = from .GetSendAs ()
}
func (*MessagesSaveDefaultSendAsRequest ) TypeID () uint32 {
return MessagesSaveDefaultSendAsRequestTypeID
}
func (*MessagesSaveDefaultSendAsRequest ) TypeName () string {
return "messages.saveDefaultSendAs"
}
func (s *MessagesSaveDefaultSendAsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.saveDefaultSendAs" ,
ID : MessagesSaveDefaultSendAsRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "SendAs" ,
SchemaName : "send_as" ,
},
}
return typ
}
func (s *MessagesSaveDefaultSendAsRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.saveDefaultSendAs#ccfddf96 as nil" )
}
b .PutID (MessagesSaveDefaultSendAsRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSaveDefaultSendAsRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.saveDefaultSendAs#ccfddf96 as nil" )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.saveDefaultSendAs#ccfddf96: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.saveDefaultSendAs#ccfddf96: field peer: %w" , err )
}
if s .SendAs == nil {
return fmt .Errorf ("unable to encode messages.saveDefaultSendAs#ccfddf96: field send_as is nil" )
}
if err := s .SendAs .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.saveDefaultSendAs#ccfddf96: field send_as: %w" , err )
}
return nil
}
func (s *MessagesSaveDefaultSendAsRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.saveDefaultSendAs#ccfddf96 to nil" )
}
if err := b .ConsumeID (MessagesSaveDefaultSendAsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.saveDefaultSendAs#ccfddf96: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSaveDefaultSendAsRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.saveDefaultSendAs#ccfddf96 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.saveDefaultSendAs#ccfddf96: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.saveDefaultSendAs#ccfddf96: field send_as: %w" , err )
}
s .SendAs = value
}
return nil
}
func (s *MessagesSaveDefaultSendAsRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSaveDefaultSendAsRequest ) GetSendAs () (value InputPeerClass ) {
if s == nil {
return
}
return s .SendAs
}
func (c *Client ) MessagesSaveDefaultSendAs (ctx context .Context , request *MessagesSaveDefaultSendAsRequest ) (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 .