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

// ChannelsRestrictSponsoredMessagesRequest represents TL type `channels.restrictSponsoredMessages#9ae91519`.
// Disable ads on the specified channel, for all users.
// Available only after reaching at least the boost level »¹ specified in the
// channel_restrict_sponsored_level_min »² config parameter.
//
// Links:
//  1. https://core.telegram.org/api/boost
//  2. https://core.telegram.org/api/config#channel-restrict-sponsored-level-min
//
// See https://core.telegram.org/method/channels.restrictSponsoredMessages for reference.
type ChannelsRestrictSponsoredMessagesRequest struct {
	// The channel.
	Channel InputChannelClass
	// Whether to disable or re-enable ads.
	Restricted bool
}

// ChannelsRestrictSponsoredMessagesRequestTypeID is TL type id of ChannelsRestrictSponsoredMessagesRequest.
const ChannelsRestrictSponsoredMessagesRequestTypeID = 0x9ae91519

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

func ( *ChannelsRestrictSponsoredMessagesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Restricted == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsRestrictSponsoredMessagesRequest from given interface.
func ( *ChannelsRestrictSponsoredMessagesRequest) ( interface {
	() ( InputChannelClass)
	() ( bool)
}) {
	.Channel = .()
	.Restricted = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsRestrictSponsoredMessagesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.restrictSponsoredMessages",
		ID:   ChannelsRestrictSponsoredMessagesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Restricted",
			SchemaName: "restricted",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsRestrictSponsoredMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.restrictSponsoredMessages#9ae91519 as nil")
	}
	.PutID(ChannelsRestrictSponsoredMessagesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsRestrictSponsoredMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.restrictSponsoredMessages#9ae91519 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.restrictSponsoredMessages#9ae91519: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.restrictSponsoredMessages#9ae91519: field channel: %w", )
	}
	.PutBool(.Restricted)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsRestrictSponsoredMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.restrictSponsoredMessages#9ae91519 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.restrictSponsoredMessages#9ae91519: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode channels.restrictSponsoredMessages#9ae91519: field restricted: %w", )
		}
		.Restricted = 
	}
	return nil
}

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

// GetRestricted returns value of Restricted field.
func ( *ChannelsRestrictSponsoredMessagesRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Restricted
}

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

// ChannelsRestrictSponsoredMessages invokes method channels.restrictSponsoredMessages#9ae91519 returning error if any.
// Disable ads on the specified channel, for all users.
// Available only after reaching at least the boost level »¹ specified in the
// channel_restrict_sponsored_level_min »² config parameter.
//
// Links:
//  1. https://core.telegram.org/api/boost
//  2. https://core.telegram.org/api/config#channel-restrict-sponsored-level-min
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.restrictSponsoredMessages for reference.
func ( *Client) ( context.Context,  *ChannelsRestrictSponsoredMessagesRequest) (UpdatesClass, error) {
	var  UpdatesBox

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