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

// PhoneToggleGroupCallSettingsRequest represents TL type `phone.toggleGroupCallSettings#74bbb43d`.
// Change group call settings
//
// See https://core.telegram.org/method/phone.toggleGroupCallSettings for reference.
type PhoneToggleGroupCallSettingsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Invalidate existing invite links
	ResetInviteHash bool
	// Group call
	Call InputGroupCall
	// Whether all users will that join this group call are muted by default upon joining the
	// group call
	//
	// Use SetJoinMuted and GetJoinMuted helpers.
	JoinMuted bool
}

// PhoneToggleGroupCallSettingsRequestTypeID is TL type id of PhoneToggleGroupCallSettingsRequest.
const PhoneToggleGroupCallSettingsRequestTypeID = 0x74bbb43d

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

func ( *PhoneToggleGroupCallSettingsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ResetInviteHash == false) {
		return false
	}
	if !(.Call.Zero()) {
		return false
	}
	if !(.JoinMuted == false) {
		return false
	}

	return true
}

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

// FillFrom fills PhoneToggleGroupCallSettingsRequest from given interface.
func ( *PhoneToggleGroupCallSettingsRequest) ( interface {
	() ( bool)
	() ( InputGroupCall)
	() ( bool,  bool)
}) {
	.ResetInviteHash = .()
	.Call = .()
	if ,  := .();  {
		.JoinMuted = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *PhoneToggleGroupCallSettingsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.toggleGroupCallSettings",
		ID:   PhoneToggleGroupCallSettingsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ResetInviteHash",
			SchemaName: "reset_invite_hash",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "JoinMuted",
			SchemaName: "join_muted",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneToggleGroupCallSettingsRequest) () {
	if !(.ResetInviteHash == false) {
		.Flags.Set(1)
	}
	if !(.JoinMuted == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneToggleGroupCallSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.toggleGroupCallSettings#74bbb43d as nil")
	}
	.PutID(PhoneToggleGroupCallSettingsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneToggleGroupCallSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.toggleGroupCallSettings#74bbb43d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.toggleGroupCallSettings#74bbb43d: field flags: %w", )
	}
	if  := .Call.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.toggleGroupCallSettings#74bbb43d: field call: %w", )
	}
	if .Flags.Has(0) {
		.PutBool(.JoinMuted)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PhoneToggleGroupCallSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.toggleGroupCallSettings#74bbb43d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallSettings#74bbb43d: field flags: %w", )
		}
	}
	.ResetInviteHash = .Flags.Has(1)
	{
		if  := .Call.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallSettings#74bbb43d: field call: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallSettings#74bbb43d: field join_muted: %w", )
		}
		.JoinMuted = 
	}
	return nil
}

// SetResetInviteHash sets value of ResetInviteHash conditional field.
func ( *PhoneToggleGroupCallSettingsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.ResetInviteHash = true
	} else {
		.Flags.Unset(1)
		.ResetInviteHash = false
	}
}

// GetResetInviteHash returns value of ResetInviteHash conditional field.
func ( *PhoneToggleGroupCallSettingsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// SetJoinMuted sets value of JoinMuted conditional field.
func ( *PhoneToggleGroupCallSettingsRequest) ( bool) {
	.Flags.Set(0)
	.JoinMuted = 
}

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

// PhoneToggleGroupCallSettings invokes method phone.toggleGroupCallSettings#74bbb43d returning error if any.
// Change group call settings
//
// Possible errors:
//
//	400 GROUPCALL_NOT_MODIFIED: Group call settings weren't modified.
//
// See https://core.telegram.org/method/phone.toggleGroupCallSettings for reference.
func ( *Client) ( context.Context,  *PhoneToggleGroupCallSettingsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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