// 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{}
)

// PhoneCreateGroupCallRequest represents TL type `phone.createGroupCall#48cdc6d8`.
// Create a group call or livestream
//
// See https://core.telegram.org/method/phone.createGroupCall for reference.
type PhoneCreateGroupCallRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether RTMP stream support should be enabled: only the group/supergroup/channelĀ¹
	// owner can use this flag.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	RtmpStream bool
	// Associate the group call or livestream to the provided group/supergroup/channelĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Peer InputPeerClass
	// Unique client message ID required to prevent creation of duplicate group calls
	RandomID int
	// Call title
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// For scheduled group call or livestreams, the absolute date when the group call will
	// start
	//
	// Use SetScheduleDate and GetScheduleDate helpers.
	ScheduleDate int
}

// PhoneCreateGroupCallRequestTypeID is TL type id of PhoneCreateGroupCallRequest.
const PhoneCreateGroupCallRequestTypeID = 0x48cdc6d8

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

func ( *PhoneCreateGroupCallRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.RtmpStream == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.ScheduleDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PhoneCreateGroupCallRequest from given interface.
func ( *PhoneCreateGroupCallRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( int)
	() ( string,  bool)
	() ( int,  bool)
}) {
	.RtmpStream = .()
	.Peer = .()
	.RandomID = .()
	if ,  := .();  {
		.Title = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*PhoneCreateGroupCallRequest) () string {
	return "phone.createGroupCall"
}

// TypeInfo returns info about TL type.
func ( *PhoneCreateGroupCallRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.createGroupCall",
		ID:   PhoneCreateGroupCallRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "RtmpStream",
			SchemaName: "rtmp_stream",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ScheduleDate",
			SchemaName: "schedule_date",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneCreateGroupCallRequest) () {
	if !(.RtmpStream == false) {
		.Flags.Set(2)
	}
	if !(.Title == "") {
		.Flags.Set(0)
	}
	if !(.ScheduleDate == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneCreateGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.createGroupCall#48cdc6d8 as nil")
	}
	.PutID(PhoneCreateGroupCallRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCreateGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.createGroupCall#48cdc6d8 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.createGroupCall#48cdc6d8: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode phone.createGroupCall#48cdc6d8: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.createGroupCall#48cdc6d8: field peer: %w", )
	}
	.PutInt(.RandomID)
	if .Flags.Has(0) {
		.PutString(.Title)
	}
	if .Flags.Has(1) {
		.PutInt(.ScheduleDate)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCreateGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.createGroupCall#48cdc6d8 to nil")
	}
	if  := .ConsumeID(PhoneCreateGroupCallRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.createGroupCall#48cdc6d8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCreateGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.createGroupCall#48cdc6d8 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.createGroupCall#48cdc6d8: field flags: %w", )
		}
	}
	.RtmpStream = .Flags.Has(2)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode phone.createGroupCall#48cdc6d8: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phone.createGroupCall#48cdc6d8: field random_id: %w", )
		}
		.RandomID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode phone.createGroupCall#48cdc6d8: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phone.createGroupCall#48cdc6d8: field schedule_date: %w", )
		}
		.ScheduleDate = 
	}
	return nil
}

// SetRtmpStream sets value of RtmpStream conditional field.
func ( *PhoneCreateGroupCallRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.RtmpStream = true
	} else {
		.Flags.Unset(2)
		.RtmpStream = false
	}
}

// GetRtmpStream returns value of RtmpStream conditional field.
func ( *PhoneCreateGroupCallRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetPeer returns value of Peer field.
func ( *PhoneCreateGroupCallRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetRandomID returns value of RandomID field.
func ( *PhoneCreateGroupCallRequest) () ( int) {
	if  == nil {
		return
	}
	return .RandomID
}

// SetTitle sets value of Title conditional field.
func ( *PhoneCreateGroupCallRequest) ( string) {
	.Flags.Set(0)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *PhoneCreateGroupCallRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Title, true
}

// SetScheduleDate sets value of ScheduleDate conditional field.
func ( *PhoneCreateGroupCallRequest) ( int) {
	.Flags.Set(1)
	.ScheduleDate = 
}

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

// PhoneCreateGroupCall invokes method phone.createGroupCall#48cdc6d8 returning error if any.
// Create a group call or livestream
//
// Possible errors:
//
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CREATE_CALL_FAILED: An error occurred while creating the call.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SCHEDULE_DATE_INVALID: Invalid schedule date provided.
//
// See https://core.telegram.org/method/phone.createGroupCall for reference.
func ( *Client) ( context.Context,  *PhoneCreateGroupCallRequest) (UpdatesClass, error) {
	var  UpdatesBox

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return .Updates, nil
}