// 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#684d214e`.
// 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 PeerColorClass
}

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

// 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 == nil) {
		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)
	() ( PeerColorClass,  bool)
}) {
	.ForProfile = .()
	if ,  := .();  {
		.Color = 
	}

}

// 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),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *AccountUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updateColor#684d214e 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#684d214e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updateColor#684d214e: field flags: %w", )
	}
	if .Flags.Has(2) {
		if .Color == nil {
			return fmt.Errorf("unable to encode account.updateColor#684d214e: field color is nil")
		}
		if  := .Color.Encode();  != nil {
			return fmt.Errorf("unable to encode account.updateColor#684d214e: field color: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updateColor#684d214e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updateColor#684d214e: field flags: %w", )
		}
	}
	.ForProfile = .Flags.Has(1)
	if .Flags.Has(2) {
		,  := DecodePeerColor()
		if  != nil {
			return fmt.Errorf("unable to decode account.updateColor#684d214e: field color: %w", )
		}
		.Color = 
	}
	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) ( PeerColorClass) {
	.Flags.Set(2)
	.Color = 
}

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

// AccountUpdateColor invokes method account.updateColor#684d214e 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.
//	400 DOCUMENT_INVALID: The specified document is invalid.
//	403 PREMIUM_ACCOUNT_REQUIRED: A premium account is required to execute this action.
//
// 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
}