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

// MessagesTranscribedAudio represents TL type `messages.transcribedAudio#cfb9d957`.
// Transcribed text from a voice message »¹
//
// Links:
//  1. https://core.telegram.org/api/transcribe
//
// See https://core.telegram.org/constructor/messages.transcribedAudio for reference.
type MessagesTranscribedAudio struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the transcription is partial because audio transcription is still in progress,
	// if set the user may receive further updateTranscribedAudio¹ updates with the updated
	// transcription.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/updateTranscribedAudio
	Pending bool
	// Transcription ID
	TranscriptionID int64
	// Transcripted text
	Text string
	// For non-Premium¹ users, this flag will be set, indicating the remaining
	// transcriptions in the free trial period.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	//
	// Use SetTrialRemainsNum and GetTrialRemainsNum helpers.
	TrialRemainsNum int
	// For non-Premium¹ users, this flag will be set, indicating the date when the
	// trial_remains_num counter will be reset to the maximum value of
	// transcribe_audio_trial_weekly_number².
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	//  2) https://core.telegram.org/api/config#transcribe-audio-trial-weekly-number
	//
	// Use SetTrialRemainsUntilDate and GetTrialRemainsUntilDate helpers.
	TrialRemainsUntilDate int
}

// MessagesTranscribedAudioTypeID is TL type id of MessagesTranscribedAudio.
const MessagesTranscribedAudioTypeID = 0xcfb9d957

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

func ( *MessagesTranscribedAudio) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pending == false) {
		return false
	}
	if !(.TranscriptionID == 0) {
		return false
	}
	if !(.Text == "") {
		return false
	}
	if !(.TrialRemainsNum == 0) {
		return false
	}
	if !(.TrialRemainsUntilDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesTranscribedAudio from given interface.
func ( *MessagesTranscribedAudio) ( interface {
	() ( bool)
	() ( int64)
	() ( string)
	() ( int,  bool)
	() ( int,  bool)
}) {
	.Pending = .()
	.TranscriptionID = .()
	.Text = .()
	if ,  := .();  {
		.TrialRemainsNum = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*MessagesTranscribedAudio) () string {
	return "messages.transcribedAudio"
}

// TypeInfo returns info about TL type.
func ( *MessagesTranscribedAudio) () tdp.Type {
	 := tdp.Type{
		Name: "messages.transcribedAudio",
		ID:   MessagesTranscribedAudioTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pending",
			SchemaName: "pending",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "TranscriptionID",
			SchemaName: "transcription_id",
		},
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "TrialRemainsNum",
			SchemaName: "trial_remains_num",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "TrialRemainsUntilDate",
			SchemaName: "trial_remains_until_date",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesTranscribedAudio) () {
	if !(.Pending == false) {
		.Flags.Set(0)
	}
	if !(.TrialRemainsNum == 0) {
		.Flags.Set(1)
	}
	if !(.TrialRemainsUntilDate == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesTranscribedAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.transcribedAudio#cfb9d957 as nil")
	}
	.PutID(MessagesTranscribedAudioTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesTranscribedAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.transcribedAudio#cfb9d957 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.transcribedAudio#cfb9d957: field flags: %w", )
	}
	.PutLong(.TranscriptionID)
	.PutString(.Text)
	if .Flags.Has(1) {
		.PutInt(.TrialRemainsNum)
	}
	if .Flags.Has(1) {
		.PutInt(.TrialRemainsUntilDate)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesTranscribedAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.transcribedAudio#cfb9d957 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field flags: %w", )
		}
	}
	.Pending = .Flags.Has(0)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field transcription_id: %w", )
		}
		.TranscriptionID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field text: %w", )
		}
		.Text = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field trial_remains_num: %w", )
		}
		.TrialRemainsNum = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field trial_remains_until_date: %w", )
		}
		.TrialRemainsUntilDate = 
	}
	return nil
}

// SetPending sets value of Pending conditional field.
func ( *MessagesTranscribedAudio) ( bool) {
	if  {
		.Flags.Set(0)
		.Pending = true
	} else {
		.Flags.Unset(0)
		.Pending = false
	}
}

// GetPending returns value of Pending conditional field.
func ( *MessagesTranscribedAudio) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetTranscriptionID returns value of TranscriptionID field.
func ( *MessagesTranscribedAudio) () ( int64) {
	if  == nil {
		return
	}
	return .TranscriptionID
}

// GetText returns value of Text field.
func ( *MessagesTranscribedAudio) () ( string) {
	if  == nil {
		return
	}
	return .Text
}

// SetTrialRemainsNum sets value of TrialRemainsNum conditional field.
func ( *MessagesTranscribedAudio) ( int) {
	.Flags.Set(1)
	.TrialRemainsNum = 
}

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

// SetTrialRemainsUntilDate sets value of TrialRemainsUntilDate conditional field.
func ( *MessagesTranscribedAudio) ( int) {
	.Flags.Set(1)
	.TrialRemainsUntilDate = 
}

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