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

// AccountUpdateColorRequest represents TL type `account.updateColor#7cefa15d`.
// Update the accent color and background custom emoji »¹ of the current account.
//
// Links:
//  1. https://core.telegram.org/api/colors
//
// See https://core.telegram.org/method/account.updateColor for reference.
type AccountUpdateColorRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to change the accent color emoji pattern of the profile page; otherwise, the
	// accent color and emoji pattern of messages will be changed.
	ForProfile bool
	// ID of the accent color palette »¹ to use (not RGB24, see here »² for more info).
	//
	// Links:
	//  1) https://core.telegram.org/api/colors
	//  2) https://core.telegram.org/api/colors
	//
	// Use SetColor and GetColor helpers.
	Color int
	// Custom emoji ID used in the accent color pattern.
	//
	// Use SetBackgroundEmojiID and GetBackgroundEmojiID helpers.
	BackgroundEmojiID int64
}

// AccountUpdateColorRequestTypeID is TL type id of AccountUpdateColorRequest.
const AccountUpdateColorRequestTypeID = 0x7cefa15d

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

func ( *AccountUpdateColorRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ForProfile == false) {
		return false
	}
	if !(.Color == 0) {
		return false
	}
	if !(.BackgroundEmojiID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountUpdateColorRequest from given interface.
func ( *AccountUpdateColorRequest) ( interface {
	() ( bool)
	() ( int,  bool)
	() ( int64,  bool)
}) {
	.ForProfile = .()
	if ,  := .();  {
		.Color = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*AccountUpdateColorRequest) () string {
	return "account.updateColor"
}

// TypeInfo returns info about TL type.
func ( *AccountUpdateColorRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.updateColor",
		ID:   AccountUpdateColorRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ForProfile",
			SchemaName: "for_profile",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Color",
			SchemaName: "color",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "BackgroundEmojiID",
			SchemaName: "background_emoji_id",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountUpdateColorRequest) () {
	if !(.ForProfile == false) {
		.Flags.Set(1)
	}
	if !(.Color == 0) {
		.Flags.Set(2)
	}
	if !(.BackgroundEmojiID == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateColor#7cefa15d as nil")
	}
	.PutID(AccountUpdateColorRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateColor#7cefa15d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updateColor#7cefa15d: field flags: %w", )
	}
	if .Flags.Has(2) {
		.PutInt(.Color)
	}
	if .Flags.Has(0) {
		.PutLong(.BackgroundEmojiID)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updateColor#7cefa15d to nil")
	}
	if  := .ConsumeID(AccountUpdateColorRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.updateColor#7cefa15d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updateColor#7cefa15d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updateColor#7cefa15d: field flags: %w", )
		}
	}
	.ForProfile = .Flags.Has(1)
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateColor#7cefa15d: field color: %w", )
		}
		.Color = 
	}
	if .Flags.Has(0) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateColor#7cefa15d: field background_emoji_id: %w", )
		}
		.BackgroundEmojiID = 
	}
	return nil
}

// SetForProfile sets value of ForProfile conditional field.
func ( *AccountUpdateColorRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.ForProfile = true
	} else {
		.Flags.Unset(1)
		.ForProfile = false
	}
}

// GetForProfile returns value of ForProfile conditional field.
func ( *AccountUpdateColorRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetColor sets value of Color conditional field.
func ( *AccountUpdateColorRequest) ( int) {
	.Flags.Set(2)
	.Color = 
}

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

// SetBackgroundEmojiID sets value of BackgroundEmojiID conditional field.
func ( *AccountUpdateColorRequest) ( int64) {
	.Flags.Set(0)
	.BackgroundEmojiID = 
}

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

// AccountUpdateColor invokes method account.updateColor#7cefa15d returning error if any.
// Update the accent color and background custom emoji »¹ of the current account.
//
// Links:
//  1. https://core.telegram.org/api/colors
//
// Possible errors:
//
//	400 COLOR_INVALID: The specified color palette ID was invalid.
//
// See https://core.telegram.org/method/account.updateColor for reference.
func ( *Client) ( context.Context,  *AccountUpdateColorRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}