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

// ChannelsUpdateColorRequest represents TL type `channels.updateColor#d8aa3671`.
// Update the accent color and background custom emoji »¹ of a channel.
//
// Links:
//  1. https://core.telegram.org/api/colors
//
// See https://core.telegram.org/method/channels.updateColor for reference.
type ChannelsUpdateColorRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// ForProfile field of ChannelsUpdateColorRequest.
	ForProfile bool
	// Channel whose accent color should be changed.
	Channel InputChannelClass
	// 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
}

// ChannelsUpdateColorRequestTypeID is TL type id of ChannelsUpdateColorRequest.
const ChannelsUpdateColorRequestTypeID = 0xd8aa3671

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

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

	return true
}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsUpdateColorRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.updateColor",
		ID:   ChannelsUpdateColorRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ForProfile",
			SchemaName: "for_profile",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			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 ( *ChannelsUpdateColorRequest) () {
	if !(.ForProfile == false) {
		.Flags.Set(1)
	}
	if !(.Color == 0) {
		.Flags.Set(2)
	}
	if !(.BackgroundEmojiID == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsUpdateColorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.updateColor#d8aa3671 as nil")
	}
	.PutID(ChannelsUpdateColorRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// GetChannel returns value of Channel field.
func ( *ChannelsUpdateColorRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

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

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

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

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

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *ChannelsUpdateColorRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// ChannelsUpdateColor invokes method channels.updateColor#d8aa3671 returning error if any.
// Update the accent color and background custom emoji »¹ of a channel.
//
// Links:
//  1. https://core.telegram.org/api/colors
//
// Possible errors:
//
//	400 BOOSTS_REQUIRED: The specified channel must first be boosted by its users in order to perform this action.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.updateColor for reference.
func ( *Client) ( context.Context,  *ChannelsUpdateColorRequest) (UpdatesClass, error) {
	var  UpdatesBox

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