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

// ChannelsUpdatePaidMessagesPriceRequest represents TL type `channels.updatePaidMessagesPrice#4b12327b`.
// Enable or disable paid messages »¹ in this supergroup² or monoforum³.
// Also used to enable or disable monoforums aka direct messages in a channel¹.
// Note that passing the ID of the monoforum itself to channel will return a
// CHANNEL_MONOFORUM_UNSUPPORTED error: pass the ID of the associated channel to edit the
// settings of the associated monoforum, instead.
//
// Links:
//  1. https://core.telegram.org/api/paid-messages
//  2. https://core.telegram.org/api/channel
//  3. https://core.telegram.org/api/monoforum
//  4. https://core.telegram.org/api/monoforum
//
// See https://core.telegram.org/method/channels.updatePaidMessagesPrice for reference.
type ChannelsUpdatePaidMessagesPriceRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Only usable for channels, enables or disables the associated monoforum aka direct
	// messages¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/monoforum
	BroadcastMessagesAllowed bool
	// Pass the supergroup ID for supergroups and the ID of the channel¹ to modify the
	// setting in the associated monoforum.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Channel InputChannelClass
	// Specifies the required amount of Telegram Stars¹ users must pay to send messages to
	// the supergroup or monoforum.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	SendPaidMessagesStars int64
}

// ChannelsUpdatePaidMessagesPriceRequestTypeID is TL type id of ChannelsUpdatePaidMessagesPriceRequest.
const ChannelsUpdatePaidMessagesPriceRequestTypeID = 0x4b12327b

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

func ( *ChannelsUpdatePaidMessagesPriceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.BroadcastMessagesAllowed == false) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.SendPaidMessagesStars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsUpdatePaidMessagesPriceRequest from given interface.
func ( *ChannelsUpdatePaidMessagesPriceRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
	() ( int64)
}) {
	.BroadcastMessagesAllowed = .()
	.Channel = .()
	.SendPaidMessagesStars = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsUpdatePaidMessagesPriceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.updatePaidMessagesPrice",
		ID:   ChannelsUpdatePaidMessagesPriceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BroadcastMessagesAllowed",
			SchemaName: "broadcast_messages_allowed",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "SendPaidMessagesStars",
			SchemaName: "send_paid_messages_stars",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsUpdatePaidMessagesPriceRequest) () {
	if !(.BroadcastMessagesAllowed == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsUpdatePaidMessagesPriceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.updatePaidMessagesPrice#4b12327b as nil")
	}
	.PutID(ChannelsUpdatePaidMessagesPriceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsUpdatePaidMessagesPriceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.updatePaidMessagesPrice#4b12327b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.updatePaidMessagesPrice#4b12327b: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.updatePaidMessagesPrice#4b12327b: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.updatePaidMessagesPrice#4b12327b: field channel: %w", )
	}
	.PutLong(.SendPaidMessagesStars)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsUpdatePaidMessagesPriceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.updatePaidMessagesPrice#4b12327b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.updatePaidMessagesPrice#4b12327b: field flags: %w", )
		}
	}
	.BroadcastMessagesAllowed = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.updatePaidMessagesPrice#4b12327b: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channels.updatePaidMessagesPrice#4b12327b: field send_paid_messages_stars: %w", )
		}
		.SendPaidMessagesStars = 
	}
	return nil
}

// SetBroadcastMessagesAllowed sets value of BroadcastMessagesAllowed conditional field.
func ( *ChannelsUpdatePaidMessagesPriceRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.BroadcastMessagesAllowed = true
	} else {
		.Flags.Unset(0)
		.BroadcastMessagesAllowed = false
	}
}

// GetBroadcastMessagesAllowed returns value of BroadcastMessagesAllowed conditional field.
func ( *ChannelsUpdatePaidMessagesPriceRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetSendPaidMessagesStars returns value of SendPaidMessagesStars field.
func ( *ChannelsUpdatePaidMessagesPriceRequest) () ( int64) {
	if  == nil {
		return
	}
	return .SendPaidMessagesStars
}

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

// ChannelsUpdatePaidMessagesPrice invokes method channels.updatePaidMessagesPrice#4b12327b returning error if any.
// Enable or disable paid messages »¹ in this supergroup² or monoforum³.
// Also used to enable or disable monoforums aka direct messages in a channel¹.
// Note that passing the ID of the monoforum itself to channel will return a
// CHANNEL_MONOFORUM_UNSUPPORTED error: pass the ID of the associated channel to edit the
// settings of the associated monoforum, instead.
//
// Links:
//  1. https://core.telegram.org/api/paid-messages
//  2. https://core.telegram.org/api/channel
//  3. https://core.telegram.org/api/monoforum
//  4. https://core.telegram.org/api/monoforum
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_MONOFORUM_UNSUPPORTED: Monoforums do not support this feature.
//	400 CHAT_NOT_MODIFIED: No changes were made to chat information because the new information you passed is identical to the current information.
//	400 STARS_AMOUNT_INVALID: The specified amount in stars is invalid.
//
// See https://core.telegram.org/method/channels.updatePaidMessagesPrice for reference.
func ( *Client) ( context.Context,  *ChannelsUpdatePaidMessagesPriceRequest) (UpdatesClass, error) {
	var  UpdatesBox

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