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

// PhoneJoinGroupCallRequest represents TL type `phone.joinGroupCall#b132ff7b`.
// Join a group call
//
// See https://core.telegram.org/method/phone.joinGroupCall for reference.
type PhoneJoinGroupCallRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the user will be muted by default upon joining.
	Muted bool
	// If set, the user's video will be disabled by default upon joining.
	VideoStopped bool
	// The group call
	Call InputGroupCall
	// Join the group call, presenting yourself as the specified user/channel
	JoinAs InputPeerClass
	// The invitation hash from the invite link »¹, if provided allows speaking in a
	// livestream or muted group chat.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#video-chat-livestream-links
	//
	// Use SetInviteHash and GetInviteHash helpers.
	InviteHash string
	// WebRTC parameters
	Params DataJSON
}

// PhoneJoinGroupCallRequestTypeID is TL type id of PhoneJoinGroupCallRequest.
const PhoneJoinGroupCallRequestTypeID = 0xb132ff7b

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

func ( *PhoneJoinGroupCallRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Muted == false) {
		return false
	}
	if !(.VideoStopped == false) {
		return false
	}
	if !(.Call.Zero()) {
		return false
	}
	if !(.JoinAs == nil) {
		return false
	}
	if !(.InviteHash == "") {
		return false
	}
	if !(.Params.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PhoneJoinGroupCallRequest from given interface.
func ( *PhoneJoinGroupCallRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputGroupCall)
	() ( InputPeerClass)
	() ( string,  bool)
	() ( DataJSON)
}) {
	.Muted = .()
	.VideoStopped = .()
	.Call = .()
	.JoinAs = .()
	if ,  := .();  {
		.InviteHash = 
	}

	.Params = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PhoneJoinGroupCallRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.joinGroupCall",
		ID:   PhoneJoinGroupCallRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Muted",
			SchemaName: "muted",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "VideoStopped",
			SchemaName: "video_stopped",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "JoinAs",
			SchemaName: "join_as",
		},
		{
			Name:       "InviteHash",
			SchemaName: "invite_hash",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Params",
			SchemaName: "params",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneJoinGroupCallRequest) () {
	if !(.Muted == false) {
		.Flags.Set(0)
	}
	if !(.VideoStopped == false) {
		.Flags.Set(2)
	}
	if !(.InviteHash == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneJoinGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.joinGroupCall#b132ff7b as nil")
	}
	.PutID(PhoneJoinGroupCallRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneJoinGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.joinGroupCall#b132ff7b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.joinGroupCall#b132ff7b: field flags: %w", )
	}
	if  := .Call.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.joinGroupCall#b132ff7b: field call: %w", )
	}
	if .JoinAs == nil {
		return fmt.Errorf("unable to encode phone.joinGroupCall#b132ff7b: field join_as is nil")
	}
	if  := .JoinAs.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.joinGroupCall#b132ff7b: field join_as: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.InviteHash)
	}
	if  := .Params.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.joinGroupCall#b132ff7b: field params: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PhoneJoinGroupCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.joinGroupCall#b132ff7b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.joinGroupCall#b132ff7b: field flags: %w", )
		}
	}
	.Muted = .Flags.Has(0)
	.VideoStopped = .Flags.Has(2)
	{
		if  := .Call.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.joinGroupCall#b132ff7b: field call: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode phone.joinGroupCall#b132ff7b: field join_as: %w", )
		}
		.JoinAs = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode phone.joinGroupCall#b132ff7b: field invite_hash: %w", )
		}
		.InviteHash = 
	}
	{
		if  := .Params.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.joinGroupCall#b132ff7b: field params: %w", )
		}
	}
	return nil
}

// SetMuted sets value of Muted conditional field.
func ( *PhoneJoinGroupCallRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Muted = true
	} else {
		.Flags.Unset(0)
		.Muted = false
	}
}

// GetMuted returns value of Muted conditional field.
func ( *PhoneJoinGroupCallRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetVideoStopped sets value of VideoStopped conditional field.
func ( *PhoneJoinGroupCallRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.VideoStopped = true
	} else {
		.Flags.Unset(2)
		.VideoStopped = false
	}
}

// GetVideoStopped returns value of VideoStopped conditional field.
func ( *PhoneJoinGroupCallRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetCall returns value of Call field.
func ( *PhoneJoinGroupCallRequest) () ( InputGroupCall) {
	if  == nil {
		return
	}
	return .Call
}

// GetJoinAs returns value of JoinAs field.
func ( *PhoneJoinGroupCallRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .JoinAs
}

// SetInviteHash sets value of InviteHash conditional field.
func ( *PhoneJoinGroupCallRequest) ( string) {
	.Flags.Set(1)
	.InviteHash = 
}

// GetInviteHash returns value of InviteHash conditional field and
// boolean which is true if field was set.
func ( *PhoneJoinGroupCallRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .InviteHash, true
}

// GetParams returns value of Params field.
func ( *PhoneJoinGroupCallRequest) () ( DataJSON) {
	if  == nil {
		return
	}
	return .Params
}

// PhoneJoinGroupCall invokes method phone.joinGroupCall#b132ff7b returning error if any.
// Join a group call
//
// Possible errors:
//
//	400 DATA_JSON_INVALID: The provided JSON data is invalid.
//	500 GROUPCALL_ADD_PARTICIPANTS_FAILED:
//	403 GROUPCALL_FORBIDDEN: The group call has already ended.
//	400 GROUPCALL_INVALID: The specified group call is invalid.
//	400 GROUPCALL_SSRC_DUPLICATE_MUCH: The app needs to retry joining the group call with a new SSRC value.
//	400 JOIN_AS_PEER_INVALID: The specified peer cannot be used to join a group call.
//
// See https://core.telegram.org/method/phone.joinGroupCall for reference.
func ( *Client) ( context.Context,  *PhoneJoinGroupCallRequest) (UpdatesClass, error) {
	var  UpdatesBox

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