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 PhoneDiscardCallRequest struct {
Flags bin .Fields
Video bool
Peer InputPhoneCall
Duration int
Reason PhoneCallDiscardReasonClass
ConnectionID int64
}
const PhoneDiscardCallRequestTypeID = 0xb2cbc1c0
var (
_ bin .Encoder = &PhoneDiscardCallRequest {}
_ bin .Decoder = &PhoneDiscardCallRequest {}
_ bin .BareEncoder = &PhoneDiscardCallRequest {}
_ bin .BareDecoder = &PhoneDiscardCallRequest {}
)
func (d *PhoneDiscardCallRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Video == false ) {
return false
}
if !(d .Peer .Zero ()) {
return false
}
if !(d .Duration == 0 ) {
return false
}
if !(d .Reason == nil ) {
return false
}
if !(d .ConnectionID == 0 ) {
return false
}
return true
}
func (d *PhoneDiscardCallRequest ) String () string {
if d == nil {
return "PhoneDiscardCallRequest(nil)"
}
type Alias PhoneDiscardCallRequest
return fmt .Sprintf ("PhoneDiscardCallRequest%+v" , Alias (*d ))
}
func (d *PhoneDiscardCallRequest ) FillFrom (from interface {
GetVideo () (value bool )
GetPeer () (value InputPhoneCall )
GetDuration () (value int )
GetReason () (value PhoneCallDiscardReasonClass )
GetConnectionID () (value int64 )
}) {
d .Video = from .GetVideo ()
d .Peer = from .GetPeer ()
d .Duration = from .GetDuration ()
d .Reason = from .GetReason ()
d .ConnectionID = from .GetConnectionID ()
}
func (*PhoneDiscardCallRequest ) TypeID () uint32 {
return PhoneDiscardCallRequestTypeID
}
func (*PhoneDiscardCallRequest ) TypeName () string {
return "phone.discardCall"
}
func (d *PhoneDiscardCallRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phone.discardCall" ,
ID : PhoneDiscardCallRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Video" ,
SchemaName : "video" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Duration" ,
SchemaName : "duration" ,
},
{
Name : "Reason" ,
SchemaName : "reason" ,
},
{
Name : "ConnectionID" ,
SchemaName : "connection_id" ,
},
}
return typ
}
func (d *PhoneDiscardCallRequest ) SetFlags () {
if !(d .Video == false ) {
d .Flags .Set (0 )
}
}
func (d *PhoneDiscardCallRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode phone.discardCall#b2cbc1c0 as nil" )
}
b .PutID (PhoneDiscardCallRequestTypeID )
return d .EncodeBare (b )
}
func (d *PhoneDiscardCallRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode phone.discardCall#b2cbc1c0 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.discardCall#b2cbc1c0: field flags: %w" , err )
}
if err := d .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.discardCall#b2cbc1c0: field peer: %w" , err )
}
b .PutInt (d .Duration )
if d .Reason == nil {
return fmt .Errorf ("unable to encode phone.discardCall#b2cbc1c0: field reason is nil" )
}
if err := d .Reason .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.discardCall#b2cbc1c0: field reason: %w" , err )
}
b .PutLong (d .ConnectionID )
return nil
}
func (d *PhoneDiscardCallRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode phone.discardCall#b2cbc1c0 to nil" )
}
if err := b .ConsumeID (PhoneDiscardCallRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode phone.discardCall#b2cbc1c0: %w" , err )
}
return d .DecodeBare (b )
}
func (d *PhoneDiscardCallRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode phone.discardCall#b2cbc1c0 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phone.discardCall#b2cbc1c0: field flags: %w" , err )
}
}
d .Video = d .Flags .Has (0 )
{
if err := d .Peer .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phone.discardCall#b2cbc1c0: field peer: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phone.discardCall#b2cbc1c0: field duration: %w" , err )
}
d .Duration = value
}
{
value , err := DecodePhoneCallDiscardReason (b )
if err != nil {
return fmt .Errorf ("unable to decode phone.discardCall#b2cbc1c0: field reason: %w" , err )
}
d .Reason = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode phone.discardCall#b2cbc1c0: field connection_id: %w" , err )
}
d .ConnectionID = value
}
return nil
}
func (d *PhoneDiscardCallRequest ) SetVideo (value bool ) {
if value {
d .Flags .Set (0 )
d .Video = true
} else {
d .Flags .Unset (0 )
d .Video = false
}
}
func (d *PhoneDiscardCallRequest ) GetVideo () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *PhoneDiscardCallRequest ) GetPeer () (value InputPhoneCall ) {
if d == nil {
return
}
return d .Peer
}
func (d *PhoneDiscardCallRequest ) GetDuration () (value int ) {
if d == nil {
return
}
return d .Duration
}
func (d *PhoneDiscardCallRequest ) GetReason () (value PhoneCallDiscardReasonClass ) {
if d == nil {
return
}
return d .Reason
}
func (d *PhoneDiscardCallRequest ) GetConnectionID () (value int64 ) {
if d == nil {
return
}
return d .ConnectionID
}
func (c *Client ) PhoneDiscardCall (ctx context .Context , request *PhoneDiscardCallRequest ) (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 .