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

// AicomposeUpdateToneRequest represents TL type `aicompose.updateTone#903bcf59`.
//
// See https://core.telegram.org/method/aicompose.updateTone for reference.
type AicomposeUpdateToneRequest struct {
	// Flags field of AicomposeUpdateToneRequest.
	Flags bin.Fields
	// Tone field of AicomposeUpdateToneRequest.
	Tone InputAiComposeToneClass
	// DisplayAuthor field of AicomposeUpdateToneRequest.
	//
	// Use SetDisplayAuthor and GetDisplayAuthor helpers.
	DisplayAuthor bool
	// EmojiID field of AicomposeUpdateToneRequest.
	//
	// Use SetEmojiID and GetEmojiID helpers.
	EmojiID int64
	// Title field of AicomposeUpdateToneRequest.
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// Prompt field of AicomposeUpdateToneRequest.
	//
	// Use SetPrompt and GetPrompt helpers.
	Prompt string
}

// AicomposeUpdateToneRequestTypeID is TL type id of AicomposeUpdateToneRequest.
const AicomposeUpdateToneRequestTypeID = 0x903bcf59

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

func ( *AicomposeUpdateToneRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Tone == nil) {
		return false
	}
	if !(.DisplayAuthor == false) {
		return false
	}
	if !(.EmojiID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Prompt == "") {
		return false
	}

	return true
}

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

// FillFrom fills AicomposeUpdateToneRequest from given interface.
func ( *AicomposeUpdateToneRequest) ( interface {
	() ( InputAiComposeToneClass)
	() ( bool,  bool)
	() ( int64,  bool)
	() ( string,  bool)
	() ( string,  bool)
}) {
	.Tone = .()
	if ,  := .();  {
		.DisplayAuthor = 
	}

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

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

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

}

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

// TypeName returns name of type in TL schema.
func (*AicomposeUpdateToneRequest) () string {
	return "aicompose.updateTone"
}

// TypeInfo returns info about TL type.
func ( *AicomposeUpdateToneRequest) () tdp.Type {
	 := tdp.Type{
		Name: "aicompose.updateTone",
		ID:   AicomposeUpdateToneRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Tone",
			SchemaName: "tone",
		},
		{
			Name:       "DisplayAuthor",
			SchemaName: "display_author",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "EmojiID",
			SchemaName: "emoji_id",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Prompt",
			SchemaName: "prompt",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AicomposeUpdateToneRequest) () {
	if !(.DisplayAuthor == false) {
		.Flags.Set(0)
	}
	if !(.EmojiID == 0) {
		.Flags.Set(1)
	}
	if !(.Title == "") {
		.Flags.Set(2)
	}
	if !(.Prompt == "") {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *AicomposeUpdateToneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode aicompose.updateTone#903bcf59 as nil")
	}
	.PutID(AicomposeUpdateToneRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AicomposeUpdateToneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode aicompose.updateTone#903bcf59 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode aicompose.updateTone#903bcf59: field flags: %w", )
	}
	if .Tone == nil {
		return fmt.Errorf("unable to encode aicompose.updateTone#903bcf59: field tone is nil")
	}
	if  := .Tone.Encode();  != nil {
		return fmt.Errorf("unable to encode aicompose.updateTone#903bcf59: field tone: %w", )
	}
	if .Flags.Has(0) {
		.PutBool(.DisplayAuthor)
	}
	if .Flags.Has(1) {
		.PutLong(.EmojiID)
	}
	if .Flags.Has(2) {
		.PutString(.Title)
	}
	if .Flags.Has(3) {
		.PutString(.Prompt)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AicomposeUpdateToneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode aicompose.updateTone#903bcf59 to nil")
	}
	if  := .ConsumeID(AicomposeUpdateToneRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AicomposeUpdateToneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode aicompose.updateTone#903bcf59 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: field flags: %w", )
		}
	}
	{
		,  := DecodeInputAiComposeTone()
		if  != nil {
			return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: field tone: %w", )
		}
		.Tone = 
	}
	if .Flags.Has(0) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: field display_author: %w", )
		}
		.DisplayAuthor = 
	}
	if .Flags.Has(1) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: field emoji_id: %w", )
		}
		.EmojiID = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(3) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode aicompose.updateTone#903bcf59: field prompt: %w", )
		}
		.Prompt = 
	}
	return nil
}

// GetTone returns value of Tone field.
func ( *AicomposeUpdateToneRequest) () ( InputAiComposeToneClass) {
	if  == nil {
		return
	}
	return .Tone
}

// SetDisplayAuthor sets value of DisplayAuthor conditional field.
func ( *AicomposeUpdateToneRequest) ( bool) {
	.Flags.Set(0)
	.DisplayAuthor = 
}

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

// SetEmojiID sets value of EmojiID conditional field.
func ( *AicomposeUpdateToneRequest) ( int64) {
	.Flags.Set(1)
	.EmojiID = 
}

// GetEmojiID returns value of EmojiID conditional field and
// boolean which is true if field was set.
func ( *AicomposeUpdateToneRequest) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .EmojiID, true
}

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

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

// SetPrompt sets value of Prompt conditional field.
func ( *AicomposeUpdateToneRequest) ( string) {
	.Flags.Set(3)
	.Prompt = 
}

// GetPrompt returns value of Prompt conditional field and
// boolean which is true if field was set.
func ( *AicomposeUpdateToneRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Prompt, true
}

// AicomposeUpdateTone invokes method aicompose.updateTone#903bcf59 returning error if any.
//
// See https://core.telegram.org/method/aicompose.updateTone for reference.
func ( *Client) ( context.Context,  *AicomposeUpdateToneRequest) (AiComposeToneClass, error) {
	var  AiComposeToneBox

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