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

// PhoneToggleGroupCallRecordRequest represents TL type `phone.toggleGroupCallRecord#f128c708`.
// Start or stop recording a group call: the recorded audio and video streams will be
// automatically sent to Saved messages (the chat with ourselves).
//
// See https://core.telegram.org/method/phone.toggleGroupCallRecord for reference.
type PhoneToggleGroupCallRecordRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to start or stop recording
	Start bool
	// Whether to also record video streams
	Video bool
	// The group call or livestream
	Call InputGroupCall
	// Recording title
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// If video stream recording is enabled, whether to record in portrait or landscape mode
	//
	// Use SetVideoPortrait and GetVideoPortrait helpers.
	VideoPortrait bool
}

// PhoneToggleGroupCallRecordRequestTypeID is TL type id of PhoneToggleGroupCallRecordRequest.
const PhoneToggleGroupCallRecordRequestTypeID = 0xf128c708

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

func ( *PhoneToggleGroupCallRecordRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Start == false) {
		return false
	}
	if !(.Video == false) {
		return false
	}
	if !(.Call.Zero()) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.VideoPortrait == false) {
		return false
	}

	return true
}

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

// FillFrom fills PhoneToggleGroupCallRecordRequest from given interface.
func ( *PhoneToggleGroupCallRecordRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputGroupCall)
	() ( string,  bool)
	() ( bool,  bool)
}) {
	.Start = .()
	.Video = .()
	.Call = .()
	if ,  := .();  {
		.Title = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *PhoneToggleGroupCallRecordRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.toggleGroupCallRecord",
		ID:   PhoneToggleGroupCallRecordRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Start",
			SchemaName: "start",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "VideoPortrait",
			SchemaName: "video_portrait",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhoneToggleGroupCallRecordRequest) () {
	if !(.Start == false) {
		.Flags.Set(0)
	}
	if !(.Video == false) {
		.Flags.Set(2)
	}
	if !(.Title == "") {
		.Flags.Set(1)
	}
	if !(.VideoPortrait == false) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *PhoneToggleGroupCallRecordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.toggleGroupCallRecord#f128c708 as nil")
	}
	.PutID(PhoneToggleGroupCallRecordRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneToggleGroupCallRecordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.toggleGroupCallRecord#f128c708 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.toggleGroupCallRecord#f128c708: field flags: %w", )
	}
	if  := .Call.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.toggleGroupCallRecord#f128c708: field call: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.Title)
	}
	if .Flags.Has(2) {
		.PutBool(.VideoPortrait)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PhoneToggleGroupCallRecordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.toggleGroupCallRecord#f128c708 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallRecord#f128c708: field flags: %w", )
		}
	}
	.Start = .Flags.Has(0)
	.Video = .Flags.Has(2)
	{
		if  := .Call.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallRecord#f128c708: field call: %w", )
		}
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallRecord#f128c708: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(2) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode phone.toggleGroupCallRecord#f128c708: field video_portrait: %w", )
		}
		.VideoPortrait = 
	}
	return nil
}

// SetStart sets value of Start conditional field.
func ( *PhoneToggleGroupCallRecordRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Start = true
	} else {
		.Flags.Unset(0)
		.Start = false
	}
}

// GetStart returns value of Start conditional field.
func ( *PhoneToggleGroupCallRecordRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

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

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

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

// SetVideoPortrait sets value of VideoPortrait conditional field.
func ( *PhoneToggleGroupCallRecordRequest) ( bool) {
	.Flags.Set(2)
	.VideoPortrait = 
}

// GetVideoPortrait returns value of VideoPortrait conditional field and
// boolean which is true if field was set.
func ( *PhoneToggleGroupCallRecordRequest) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .VideoPortrait, true
}

// PhoneToggleGroupCallRecord invokes method phone.toggleGroupCallRecord#f128c708 returning error if any.
// Start or stop recording a group call: the recorded audio and video streams will be
// automatically sent to Saved messages (the chat with ourselves).
//
// Possible errors:
//
//	403 GROUPCALL_FORBIDDEN: The group call has already ended.
//	400 GROUPCALL_NOT_MODIFIED: Group call settings weren't modified.
//
// See https://core.telegram.org/method/phone.toggleGroupCallRecord for reference.
func ( *Client) ( context.Context,  *PhoneToggleGroupCallRecordRequest) (UpdatesClass, error) {
	var  UpdatesBox

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