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

// ChannelsGetSponsoredMessagesRequest represents TL type `channels.getSponsoredMessages#ec210fbf`.
// Get a list of sponsored messages
//
// See https://core.telegram.org/method/channels.getSponsoredMessages for reference.
type ChannelsGetSponsoredMessagesRequest struct {
	// Peer
	Channel InputChannelClass
}

// ChannelsGetSponsoredMessagesRequestTypeID is TL type id of ChannelsGetSponsoredMessagesRequest.
const ChannelsGetSponsoredMessagesRequestTypeID = 0xec210fbf

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsGetSponsoredMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getSponsoredMessages#ec210fbf as nil")
	}
	.PutID(ChannelsGetSponsoredMessagesRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetSponsoredMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getSponsoredMessages#ec210fbf to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getSponsoredMessages#ec210fbf: field channel: %w", )
		}
		.Channel = 
	}
	return nil
}

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

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

// ChannelsGetSponsoredMessages invokes method channels.getSponsoredMessages#ec210fbf returning error if any.
// Get a list of sponsored messages
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//
// See https://core.telegram.org/method/channels.getSponsoredMessages for reference.
func ( *Client) ( context.Context,  InputChannelClass) (MessagesSponsoredMessagesClass, error) {
	var  MessagesSponsoredMessagesBox

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