// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PhoneCallEmpty represents TL type `phoneCallEmpty#5366c915`.
// Empty constructor
//
// See https://core.telegram.org/constructor/phoneCallEmpty for reference.
type PhoneCallEmpty struct {
	// Call ID
	ID int64
}

// PhoneCallEmptyTypeID is TL type id of PhoneCallEmpty.
const PhoneCallEmptyTypeID = 0x5366c915

// construct implements constructor of PhoneCallClass.
func ( PhoneCallEmpty) () PhoneCallClass { return & }

// Ensuring interfaces in compile-time for PhoneCallEmpty.
var (
	_ bin.Encoder     = &PhoneCallEmpty{}
	_ bin.Decoder     = &PhoneCallEmpty{}
	_ bin.BareEncoder = &PhoneCallEmpty{}
	_ bin.BareDecoder = &PhoneCallEmpty{}

	_ PhoneCallClass = &PhoneCallEmpty{}
)

func ( *PhoneCallEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneCallEmpty) () string {
	if  == nil {
		return "PhoneCallEmpty(nil)"
	}
	type  PhoneCallEmpty
	return fmt.Sprintf("PhoneCallEmpty%+v", (*))
}

// FillFrom fills PhoneCallEmpty from given interface.
func ( *PhoneCallEmpty) ( interface {
	() ( int64)
}) {
	.ID = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallEmpty) () uint32 {
	return PhoneCallEmptyTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneCallEmpty) () string {
	return "phoneCallEmpty"
}

// TypeInfo returns info about TL type.
func ( *PhoneCallEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallEmpty",
		ID:   PhoneCallEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneCallEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallEmpty#5366c915 as nil")
	}
	.PutID(PhoneCallEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallEmpty#5366c915 as nil")
	}
	.PutLong(.ID)
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallEmpty#5366c915 to nil")
	}
	if  := .ConsumeID(PhoneCallEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallEmpty#5366c915: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallEmpty#5366c915 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallEmpty#5366c915: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *PhoneCallEmpty) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// PhoneCallWaiting represents TL type `phoneCallWaiting#c5226f17`.
// Incoming phone call
//
// See https://core.telegram.org/constructor/phoneCallWaiting for reference.
type PhoneCallWaiting struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is this a video call
	Video bool
	// Call ID
	ID int64
	// Access hash
	AccessHash int64
	// Date
	Date int
	// Admin ID
	AdminID int64
	// Participant ID
	ParticipantID int64
	// Phone call protocol info
	Protocol PhoneCallProtocol
	// When was the phone call received
	//
	// Use SetReceiveDate and GetReceiveDate helpers.
	ReceiveDate int
}

// PhoneCallWaitingTypeID is TL type id of PhoneCallWaiting.
const PhoneCallWaitingTypeID = 0xc5226f17

// construct implements constructor of PhoneCallClass.
func ( PhoneCallWaiting) () PhoneCallClass { return & }

// Ensuring interfaces in compile-time for PhoneCallWaiting.
var (
	_ bin.Encoder     = &PhoneCallWaiting{}
	_ bin.Decoder     = &PhoneCallWaiting{}
	_ bin.BareEncoder = &PhoneCallWaiting{}
	_ bin.BareDecoder = &PhoneCallWaiting{}

	_ PhoneCallClass = &PhoneCallWaiting{}
)

func ( *PhoneCallWaiting) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Video == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}
	if !(.Protocol.Zero()) {
		return false
	}
	if !(.ReceiveDate == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneCallWaiting) () string {
	if  == nil {
		return "PhoneCallWaiting(nil)"
	}
	type  PhoneCallWaiting
	return fmt.Sprintf("PhoneCallWaiting%+v", (*))
}

// FillFrom fills PhoneCallWaiting from given interface.
func ( *PhoneCallWaiting) ( interface {
	() ( bool)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
	() ( PhoneCallProtocol)
	() ( int,  bool)
}) {
	.Video = .()
	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
	.Protocol = .()
	if ,  := .();  {
		.ReceiveDate = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallWaiting) () uint32 {
	return PhoneCallWaitingTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneCallWaiting) () string {
	return "phoneCallWaiting"
}

// TypeInfo returns info about TL type.
func ( *PhoneCallWaiting) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallWaiting",
		ID:   PhoneCallWaitingTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
		{
			Name:       "Protocol",
			SchemaName: "protocol",
		},
		{
			Name:       "ReceiveDate",
			SchemaName: "receive_date",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneCallWaiting) () {
	if !(.Video == false) {
		.Flags.Set(6)
	}
	if !(.ReceiveDate == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneCallWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallWaiting#c5226f17 as nil")
	}
	.PutID(PhoneCallWaitingTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallWaiting#c5226f17 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallWaiting#c5226f17: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	if  := .Protocol.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallWaiting#c5226f17: field protocol: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.ReceiveDate)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallWaiting#c5226f17 to nil")
	}
	if  := .ConsumeID(PhoneCallWaitingTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallWaiting#c5226f17 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field flags: %w", )
		}
	}
	.Video = .Flags.Has(6)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	{
		if  := .Protocol.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field protocol: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field receive_date: %w", )
		}
		.ReceiveDate = 
	}
	return nil
}

// SetVideo sets value of Video conditional field.
func ( *PhoneCallWaiting) ( bool) {
	if  {
		.Flags.Set(6)
		.Video = true
	} else {
		.Flags.Unset(6)
		.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func ( *PhoneCallWaiting) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// GetID returns value of ID field.
func ( *PhoneCallWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *PhoneCallWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *PhoneCallWaiting) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *PhoneCallWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *PhoneCallWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

// GetProtocol returns value of Protocol field.
func ( *PhoneCallWaiting) () ( PhoneCallProtocol) {
	if  == nil {
		return
	}
	return .Protocol
}

// SetReceiveDate sets value of ReceiveDate conditional field.
func ( *PhoneCallWaiting) ( int) {
	.Flags.Set(0)
	.ReceiveDate = 
}

// GetReceiveDate returns value of ReceiveDate conditional field and
// boolean which is true if field was set.
func ( *PhoneCallWaiting) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ReceiveDate, true
}

// PhoneCallRequested represents TL type `phoneCallRequested#14b0ed0c`.
// Requested phone call
//
// See https://core.telegram.org/constructor/phoneCallRequested for reference.
type PhoneCallRequested struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a video call
	Video bool
	// Phone call ID
	ID int64
	// Access hash
	AccessHash int64
	// When was the phone call created
	Date int
	// ID of the creator of the phone call
	AdminID int64
	// ID of the other participant of the phone call
	ParticipantID int64
	// Parameter for key exchange¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end/voice-calls
	GAHash []byte
	// Call protocol info to be passed to libtgvoip
	Protocol PhoneCallProtocol
}

// PhoneCallRequestedTypeID is TL type id of PhoneCallRequested.
const PhoneCallRequestedTypeID = 0x14b0ed0c

// construct implements constructor of PhoneCallClass.
func ( PhoneCallRequested) () PhoneCallClass { return & }

// Ensuring interfaces in compile-time for PhoneCallRequested.
var (
	_ bin.Encoder     = &PhoneCallRequested{}
	_ bin.Decoder     = &PhoneCallRequested{}
	_ bin.BareEncoder = &PhoneCallRequested{}
	_ bin.BareDecoder = &PhoneCallRequested{}

	_ PhoneCallClass = &PhoneCallRequested{}
)

func ( *PhoneCallRequested) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Video == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}
	if !(.GAHash == nil) {
		return false
	}
	if !(.Protocol.Zero()) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneCallRequested) () string {
	if  == nil {
		return "PhoneCallRequested(nil)"
	}
	type  PhoneCallRequested
	return fmt.Sprintf("PhoneCallRequested%+v", (*))
}

// FillFrom fills PhoneCallRequested from given interface.
func ( *PhoneCallRequested) ( interface {
	() ( bool)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
	() ( []byte)
	() ( PhoneCallProtocol)
}) {
	.Video = .()
	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
	.GAHash = .()
	.Protocol = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallRequested) () uint32 {
	return PhoneCallRequestedTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneCallRequested) () string {
	return "phoneCallRequested"
}

// TypeInfo returns info about TL type.
func ( *PhoneCallRequested) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallRequested",
		ID:   PhoneCallRequestedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
		{
			Name:       "GAHash",
			SchemaName: "g_a_hash",
		},
		{
			Name:       "Protocol",
			SchemaName: "protocol",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneCallRequested) () {
	if !(.Video == false) {
		.Flags.Set(6)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneCallRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallRequested#14b0ed0c as nil")
	}
	.PutID(PhoneCallRequestedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallRequested#14b0ed0c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallRequested#14b0ed0c: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	.PutBytes(.GAHash)
	if  := .Protocol.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallRequested#14b0ed0c: field protocol: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallRequested#14b0ed0c to nil")
	}
	if  := .ConsumeID(PhoneCallRequestedTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallRequested#14b0ed0c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field flags: %w", )
		}
	}
	.Video = .Flags.Has(6)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field g_a_hash: %w", )
		}
		.GAHash = 
	}
	{
		if  := .Protocol.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field protocol: %w", )
		}
	}
	return nil
}

// SetVideo sets value of Video conditional field.
func ( *PhoneCallRequested) ( bool) {
	if  {
		.Flags.Set(6)
		.Video = true
	} else {
		.Flags.Unset(6)
		.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func ( *PhoneCallRequested) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// GetID returns value of ID field.
func ( *PhoneCallRequested) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *PhoneCallRequested) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *PhoneCallRequested) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *PhoneCallRequested) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *PhoneCallRequested) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

// GetGAHash returns value of GAHash field.
func ( *PhoneCallRequested) () ( []byte) {
	if  == nil {
		return
	}
	return .GAHash
}

// GetProtocol returns value of Protocol field.
func ( *PhoneCallRequested) () ( PhoneCallProtocol) {
	if  == nil {
		return
	}
	return .Protocol
}

// PhoneCallAccepted represents TL type `phoneCallAccepted#3660c311`.
// An accepted phone call
//
// See https://core.telegram.org/constructor/phoneCallAccepted for reference.
type PhoneCallAccepted struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a video call
	Video bool
	// ID of accepted phone call
	ID int64
	// Access hash of phone call
	AccessHash int64
	// When was the call accepted
	Date int
	// ID of the call creator
	AdminID int64
	// ID of the other user in the call
	ParticipantID int64
	// B parameter for secure E2E phone call key exchange¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end/voice-calls
	GB []byte
	// Protocol to use for phone call
	Protocol PhoneCallProtocol
}

// PhoneCallAcceptedTypeID is TL type id of PhoneCallAccepted.
const PhoneCallAcceptedTypeID = 0x3660c311

// construct implements constructor of PhoneCallClass.
func ( PhoneCallAccepted) () PhoneCallClass { return & }

// Ensuring interfaces in compile-time for PhoneCallAccepted.
var (
	_ bin.Encoder     = &PhoneCallAccepted{}
	_ bin.Decoder     = &PhoneCallAccepted{}
	_ bin.BareEncoder = &PhoneCallAccepted{}
	_ bin.BareDecoder = &PhoneCallAccepted{}

	_ PhoneCallClass = &PhoneCallAccepted{}
)

func ( *PhoneCallAccepted) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Video == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}
	if !(.GB == nil) {
		return false
	}
	if !(.Protocol.Zero()) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneCallAccepted) () string {
	if  == nil {
		return "PhoneCallAccepted(nil)"
	}
	type  PhoneCallAccepted
	return fmt.Sprintf("PhoneCallAccepted%+v", (*))
}

// FillFrom fills PhoneCallAccepted from given interface.
func ( *PhoneCallAccepted) ( interface {
	() ( bool)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
	() ( []byte)
	() ( PhoneCallProtocol)
}) {
	.Video = .()
	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
	.GB = .()
	.Protocol = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallAccepted) () uint32 {
	return PhoneCallAcceptedTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneCallAccepted) () string {
	return "phoneCallAccepted"
}

// TypeInfo returns info about TL type.
func ( *PhoneCallAccepted) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallAccepted",
		ID:   PhoneCallAcceptedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
		{
			Name:       "GB",
			SchemaName: "g_b",
		},
		{
			Name:       "Protocol",
			SchemaName: "protocol",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneCallAccepted) () {
	if !(.Video == false) {
		.Flags.Set(6)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneCallAccepted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallAccepted#3660c311 as nil")
	}
	.PutID(PhoneCallAcceptedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallAccepted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallAccepted#3660c311 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallAccepted#3660c311: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	.PutBytes(.GB)
	if  := .Protocol.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallAccepted#3660c311: field protocol: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallAccepted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallAccepted#3660c311 to nil")
	}
	if  := .ConsumeID(PhoneCallAcceptedTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallAccepted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallAccepted#3660c311 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field flags: %w", )
		}
	}
	.Video = .Flags.Has(6)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field g_b: %w", )
		}
		.GB = 
	}
	{
		if  := .Protocol.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field protocol: %w", )
		}
	}
	return nil
}

// SetVideo sets value of Video conditional field.
func ( *PhoneCallAccepted) ( bool) {
	if  {
		.Flags.Set(6)
		.Video = true
	} else {
		.Flags.Unset(6)
		.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func ( *PhoneCallAccepted) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// GetID returns value of ID field.
func ( *PhoneCallAccepted) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *PhoneCallAccepted) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *PhoneCallAccepted) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *PhoneCallAccepted) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *PhoneCallAccepted) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

// GetGB returns value of GB field.
func ( *PhoneCallAccepted) () ( []byte) {
	if  == nil {
		return
	}
	return .GB
}

// GetProtocol returns value of Protocol field.
func ( *PhoneCallAccepted) () ( PhoneCallProtocol) {
	if  == nil {
		return
	}
	return .Protocol
}

// PhoneCall represents TL type `phoneCall#967f7c67`.
// Phone call
//
// See https://core.telegram.org/constructor/phoneCall for reference.
type PhoneCall struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether P2P connection to the other peer is allowed
	P2PAllowed bool
	// Whether this is a video call
	Video bool
	// Call ID
	ID int64
	// Access hash
	AccessHash int64
	// Date of creation of the call
	Date int
	// User ID of the creator of the call
	AdminID int64
	// User ID of the other participant in the call
	ParticipantID int64
	// Parameter for key exchange¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end/voice-calls
	GAOrB []byte
	// Key fingerprint¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end/voice-calls
	KeyFingerprint int64
	// Call protocol info to be passed to libtgvoip
	Protocol PhoneCallProtocol
	// List of endpoints the user can connect to to exchange call data
	Connections []PhoneConnectionClass
	// When was the call actually started
	StartDate int
}

// PhoneCallTypeID is TL type id of PhoneCall.
const PhoneCallTypeID = 0x967f7c67

// construct implements constructor of PhoneCallClass.
func ( PhoneCall) () PhoneCallClass { return & }

// Ensuring interfaces in compile-time for PhoneCall.
var (
	_ bin.Encoder     = &PhoneCall{}
	_ bin.Decoder     = &PhoneCall{}
	_ bin.BareEncoder = &PhoneCall{}
	_ bin.BareDecoder = &PhoneCall{}

	_ PhoneCallClass = &PhoneCall{}
)

func ( *PhoneCall) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.P2PAllowed == false) {
		return false
	}
	if !(.Video == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}
	if !(.GAOrB == nil) {
		return false
	}
	if !(.KeyFingerprint == 0) {
		return false
	}
	if !(.Protocol.Zero()) {
		return false
	}
	if !(.Connections == nil) {
		return false
	}
	if !(.StartDate == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneCall) () string {
	if  == nil {
		return "PhoneCall(nil)"
	}
	type  PhoneCall
	return fmt.Sprintf("PhoneCall%+v", (*))
}

// FillFrom fills PhoneCall from given interface.
func ( *PhoneCall) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
	() ( []byte)
	() ( int64)
	() ( PhoneCallProtocol)
	() ( []PhoneConnectionClass)
	() ( int)
}) {
	.P2PAllowed = .()
	.Video = .()
	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
	.GAOrB = .()
	.KeyFingerprint = .()
	.Protocol = .()
	.Connections = .()
	.StartDate = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCall) () uint32 {
	return PhoneCallTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneCall) () string {
	return "phoneCall"
}

// TypeInfo returns info about TL type.
func ( *PhoneCall) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCall",
		ID:   PhoneCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "P2PAllowed",
			SchemaName: "p2p_allowed",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
		{
			Name:       "GAOrB",
			SchemaName: "g_a_or_b",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
		{
			Name:       "Protocol",
			SchemaName: "protocol",
		},
		{
			Name:       "Connections",
			SchemaName: "connections",
		},
		{
			Name:       "StartDate",
			SchemaName: "start_date",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneCall) () {
	if !(.P2PAllowed == false) {
		.Flags.Set(5)
	}
	if !(.Video == false) {
		.Flags.Set(6)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCall#967f7c67 as nil")
	}
	.PutID(PhoneCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCall#967f7c67 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCall#967f7c67: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	.PutBytes(.GAOrB)
	.PutLong(.KeyFingerprint)
	if  := .Protocol.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCall#967f7c67: field protocol: %w", )
	}
	.PutVectorHeader(len(.Connections))
	for ,  := range .Connections {
		if  == nil {
			return fmt.Errorf("unable to encode phoneCall#967f7c67: field connections element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phoneCall#967f7c67: field connections element with index %d: %w", , )
		}
	}
	.PutInt(.StartDate)
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCall#967f7c67 to nil")
	}
	if  := .ConsumeID(PhoneCallTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCall#967f7c67: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCall#967f7c67 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field flags: %w", )
		}
	}
	.P2PAllowed = .Flags.Has(5)
	.Video = .Flags.Has(6)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field g_a_or_b: %w", )
		}
		.GAOrB = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field key_fingerprint: %w", )
		}
		.KeyFingerprint = 
	}
	{
		if  := .Protocol.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field protocol: %w", )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field connections: %w", )
		}

		if  > 0 {
			.Connections = make([]PhoneConnectionClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePhoneConnection()
			if  != nil {
				return fmt.Errorf("unable to decode phoneCall#967f7c67: field connections: %w", )
			}
			.Connections = append(.Connections, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCall#967f7c67: field start_date: %w", )
		}
		.StartDate = 
	}
	return nil
}

// SetP2PAllowed sets value of P2PAllowed conditional field.
func ( *PhoneCall) ( bool) {
	if  {
		.Flags.Set(5)
		.P2PAllowed = true
	} else {
		.Flags.Unset(5)
		.P2PAllowed = false
	}
}

// GetP2PAllowed returns value of P2PAllowed conditional field.
func ( *PhoneCall) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetVideo sets value of Video conditional field.
func ( *PhoneCall) ( bool) {
	if  {
		.Flags.Set(6)
		.Video = true
	} else {
		.Flags.Unset(6)
		.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func ( *PhoneCall) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// GetID returns value of ID field.
func ( *PhoneCall) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *PhoneCall) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *PhoneCall) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *PhoneCall) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *PhoneCall) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

// GetGAOrB returns value of GAOrB field.
func ( *PhoneCall) () ( []byte) {
	if  == nil {
		return
	}
	return .GAOrB
}

// GetKeyFingerprint returns value of KeyFingerprint field.
func ( *PhoneCall) () ( int64) {
	if  == nil {
		return
	}
	return .KeyFingerprint
}

// GetProtocol returns value of Protocol field.
func ( *PhoneCall) () ( PhoneCallProtocol) {
	if  == nil {
		return
	}
	return .Protocol
}

// GetConnections returns value of Connections field.
func ( *PhoneCall) () ( []PhoneConnectionClass) {
	if  == nil {
		return
	}
	return .Connections
}

// GetStartDate returns value of StartDate field.
func ( *PhoneCall) () ( int) {
	if  == nil {
		return
	}
	return .StartDate
}

// MapConnections returns field Connections wrapped in PhoneConnectionClassArray helper.
func ( *PhoneCall) () ( PhoneConnectionClassArray) {
	return PhoneConnectionClassArray(.Connections)
}

// PhoneCallDiscarded represents TL type `phoneCallDiscarded#50ca4de1`.
// Indicates a discarded phone call
//
// See https://core.telegram.org/constructor/phoneCallDiscarded for reference.
type PhoneCallDiscarded struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the server required the user to rate¹ the call
	//
	// Links:
	//  1) https://core.telegram.org/method/phone.setCallRating
	NeedRating bool
	// Whether the server required the client to send¹ the libtgvoip call debug data
	//
	// Links:
	//  1) https://core.telegram.org/method/phone.saveCallDebug
	NeedDebug bool
	// Whether the call was a video call
	Video bool
	// Call ID
	ID int64
	// Why was the phone call discarded
	//
	// Use SetReason and GetReason helpers.
	Reason PhoneCallDiscardReasonClass
	// Duration of the phone call in seconds
	//
	// Use SetDuration and GetDuration helpers.
	Duration int
}

// PhoneCallDiscardedTypeID is TL type id of PhoneCallDiscarded.
const PhoneCallDiscardedTypeID = 0x50ca4de1

// construct implements constructor of PhoneCallClass.
func ( PhoneCallDiscarded) () PhoneCallClass { return & }

// Ensuring interfaces in compile-time for PhoneCallDiscarded.
var (
	_ bin.Encoder     = &PhoneCallDiscarded{}
	_ bin.Decoder     = &PhoneCallDiscarded{}
	_ bin.BareEncoder = &PhoneCallDiscarded{}
	_ bin.BareDecoder = &PhoneCallDiscarded{}

	_ PhoneCallClass = &PhoneCallDiscarded{}
)

func ( *PhoneCallDiscarded) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.NeedRating == false) {
		return false
	}
	if !(.NeedDebug == false) {
		return false
	}
	if !(.Video == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Reason == nil) {
		return false
	}
	if !(.Duration == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneCallDiscarded) () string {
	if  == nil {
		return "PhoneCallDiscarded(nil)"
	}
	type  PhoneCallDiscarded
	return fmt.Sprintf("PhoneCallDiscarded%+v", (*))
}

// FillFrom fills PhoneCallDiscarded from given interface.
func ( *PhoneCallDiscarded) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64)
	() ( PhoneCallDiscardReasonClass,  bool)
	() ( int,  bool)
}) {
	.NeedRating = .()
	.NeedDebug = .()
	.Video = .()
	.ID = .()
	if ,  := .();  {
		.Reason = 
	}

	if ,  := .();  {
		.Duration = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallDiscarded) () uint32 {
	return PhoneCallDiscardedTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneCallDiscarded) () string {
	return "phoneCallDiscarded"
}

// TypeInfo returns info about TL type.
func ( *PhoneCallDiscarded) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallDiscarded",
		ID:   PhoneCallDiscardedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NeedRating",
			SchemaName: "need_rating",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "NeedDebug",
			SchemaName: "need_debug",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Reason",
			SchemaName: "reason",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneCallDiscarded) () {
	if !(.NeedRating == false) {
		.Flags.Set(2)
	}
	if !(.NeedDebug == false) {
		.Flags.Set(3)
	}
	if !(.Video == false) {
		.Flags.Set(6)
	}
	if !(.Reason == nil) {
		.Flags.Set(0)
	}
	if !(.Duration == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneCallDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscarded#50ca4de1 as nil")
	}
	.PutID(PhoneCallDiscardedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscarded#50ca4de1 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phoneCallDiscarded#50ca4de1: field flags: %w", )
	}
	.PutLong(.ID)
	if .Flags.Has(0) {
		if .Reason == nil {
			return fmt.Errorf("unable to encode phoneCallDiscarded#50ca4de1: field reason is nil")
		}
		if  := .Reason.Encode();  != nil {
			return fmt.Errorf("unable to encode phoneCallDiscarded#50ca4de1: field reason: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutInt(.Duration)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscarded#50ca4de1 to nil")
	}
	if  := .ConsumeID(PhoneCallDiscardedTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscarded#50ca4de1 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field flags: %w", )
		}
	}
	.NeedRating = .Flags.Has(2)
	.NeedDebug = .Flags.Has(3)
	.Video = .Flags.Has(6)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(0) {
		,  := DecodePhoneCallDiscardReason()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field reason: %w", )
		}
		.Reason = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field duration: %w", )
		}
		.Duration = 
	}
	return nil
}

// SetNeedRating sets value of NeedRating conditional field.
func ( *PhoneCallDiscarded) ( bool) {
	if  {
		.Flags.Set(2)
		.NeedRating = true
	} else {
		.Flags.Unset(2)
		.NeedRating = false
	}
}

// GetNeedRating returns value of NeedRating conditional field.
func ( *PhoneCallDiscarded) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetNeedDebug sets value of NeedDebug conditional field.
func ( *PhoneCallDiscarded) ( bool) {
	if  {
		.Flags.Set(3)
		.NeedDebug = true
	} else {
		.Flags.Unset(3)
		.NeedDebug = false
	}
}

// GetNeedDebug returns value of NeedDebug conditional field.
func ( *PhoneCallDiscarded) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetVideo sets value of Video conditional field.
func ( *PhoneCallDiscarded) ( bool) {
	if  {
		.Flags.Set(6)
		.Video = true
	} else {
		.Flags.Unset(6)
		.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func ( *PhoneCallDiscarded) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// GetID returns value of ID field.
func ( *PhoneCallDiscarded) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// SetReason sets value of Reason conditional field.
func ( *PhoneCallDiscarded) ( PhoneCallDiscardReasonClass) {
	.Flags.Set(0)
	.Reason = 
}

// GetReason returns value of Reason conditional field and
// boolean which is true if field was set.
func ( *PhoneCallDiscarded) () ( PhoneCallDiscardReasonClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Reason, true
}

// SetDuration sets value of Duration conditional field.
func ( *PhoneCallDiscarded) ( int) {
	.Flags.Set(1)
	.Duration = 
}

// GetDuration returns value of Duration conditional field and
// boolean which is true if field was set.
func ( *PhoneCallDiscarded) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Duration, true
}

// PhoneCallClassName is schema name of PhoneCallClass.
const PhoneCallClassName = "PhoneCall"

// PhoneCallClass represents PhoneCall generic type.
//
// See https://core.telegram.org/type/PhoneCall for reference.
//
// Example:
//
//	g, err := tg.DecodePhoneCall(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PhoneCallEmpty: // phoneCallEmpty#5366c915
//	case *tg.PhoneCallWaiting: // phoneCallWaiting#c5226f17
//	case *tg.PhoneCallRequested: // phoneCallRequested#14b0ed0c
//	case *tg.PhoneCallAccepted: // phoneCallAccepted#3660c311
//	case *tg.PhoneCall: // phoneCall#967f7c67
//	case *tg.PhoneCallDiscarded: // phoneCallDiscarded#50ca4de1
//	default: panic(v)
//	}
type PhoneCallClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PhoneCallClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// Call ID
	GetID() (value int64)

	// AsNotEmpty tries to map PhoneCallClass to NotEmptyPhoneCall.
	AsNotEmpty() (NotEmptyPhoneCall, bool)
}

// AsInput tries to map PhoneCall to InputPhoneCall.
func ( *PhoneCall) () *InputPhoneCall {
	 := new(InputPhoneCall)
	.ID = .GetID()
	.AccessHash = .GetAccessHash()

	return 
}

// NotEmptyPhoneCall represents NotEmpty subset of PhoneCallClass.
type NotEmptyPhoneCall interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PhoneCallClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// Is this a video call
	GetVideo() (value bool)

	// Call ID
	GetID() (value int64)
}

// AsNotEmpty tries to map PhoneCallEmpty to NotEmptyPhoneCall.
func ( *PhoneCallEmpty) () (NotEmptyPhoneCall, bool) {
	,  := (PhoneCallClass()).(NotEmptyPhoneCall)
	return , 
}

// AsNotEmpty tries to map PhoneCallWaiting to NotEmptyPhoneCall.
func ( *PhoneCallWaiting) () (NotEmptyPhoneCall, bool) {
	,  := (PhoneCallClass()).(NotEmptyPhoneCall)
	return , 
}

// AsNotEmpty tries to map PhoneCallRequested to NotEmptyPhoneCall.
func ( *PhoneCallRequested) () (NotEmptyPhoneCall, bool) {
	,  := (PhoneCallClass()).(NotEmptyPhoneCall)
	return , 
}

// AsNotEmpty tries to map PhoneCallAccepted to NotEmptyPhoneCall.
func ( *PhoneCallAccepted) () (NotEmptyPhoneCall, bool) {
	,  := (PhoneCallClass()).(NotEmptyPhoneCall)
	return , 
}

// AsNotEmpty tries to map PhoneCall to NotEmptyPhoneCall.
func ( *PhoneCall) () (NotEmptyPhoneCall, bool) {
	,  := (PhoneCallClass()).(NotEmptyPhoneCall)
	return , 
}

// AsNotEmpty tries to map PhoneCallDiscarded to NotEmptyPhoneCall.
func ( *PhoneCallDiscarded) () (NotEmptyPhoneCall, bool) {
	,  := (PhoneCallClass()).(NotEmptyPhoneCall)
	return , 
}

// DecodePhoneCall implements binary de-serialization for PhoneCallClass.
func ( *bin.Buffer) (PhoneCallClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PhoneCallEmptyTypeID:
		// Decoding phoneCallEmpty#5366c915.
		 := PhoneCallEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", )
		}
		return &, nil
	case PhoneCallWaitingTypeID:
		// Decoding phoneCallWaiting#c5226f17.
		 := PhoneCallWaiting{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", )
		}
		return &, nil
	case PhoneCallRequestedTypeID:
		// Decoding phoneCallRequested#14b0ed0c.
		 := PhoneCallRequested{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", )
		}
		return &, nil
	case PhoneCallAcceptedTypeID:
		// Decoding phoneCallAccepted#3660c311.
		 := PhoneCallAccepted{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", )
		}
		return &, nil
	case PhoneCallTypeID:
		// Decoding phoneCall#967f7c67.
		 := PhoneCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", )
		}
		return &, nil
	case PhoneCallDiscardedTypeID:
		// Decoding phoneCallDiscarded#50ca4de1.
		 := PhoneCallDiscarded{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", bin.NewUnexpectedID())
	}
}

// PhoneCall boxes the PhoneCallClass providing a helper.
type PhoneCallBox struct {
	PhoneCall PhoneCallClass
}

// Decode implements bin.Decoder for PhoneCallBox.
func ( *PhoneCallBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode PhoneCallBox to nil")
	}
	,  := DecodePhoneCall()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.PhoneCall = 
	return nil
}

// Encode implements bin.Encode for PhoneCallBox.
func ( *PhoneCallBox) ( *bin.Buffer) error {
	if  == nil || .PhoneCall == nil {
		return fmt.Errorf("unable to encode PhoneCallClass as nil")
	}
	return .PhoneCall.Encode()
}