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

// ChannelsClickSponsoredMessageRequest represents TL type `channels.clickSponsoredMessage#18afbc93`.
// Informs the server that the user has either:
//
// See https://core.telegram.org/method/channels.clickSponsoredMessage for reference.
type ChannelsClickSponsoredMessageRequest struct {
	// Channel where the sponsored message was posted
	Channel InputChannelClass
	// Message ID
	RandomID []byte
}

// ChannelsClickSponsoredMessageRequestTypeID is TL type id of ChannelsClickSponsoredMessageRequest.
const ChannelsClickSponsoredMessageRequestTypeID = 0x18afbc93

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

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

	return true
}

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

// FillFrom fills ChannelsClickSponsoredMessageRequest from given interface.
func ( *ChannelsClickSponsoredMessageRequest) ( interface {
	() ( InputChannelClass)
	() ( []byte)
}) {
	.Channel = .()
	.RandomID = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsClickSponsoredMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.clickSponsoredMessage#18afbc93 as nil")
	}
	.PutID(ChannelsClickSponsoredMessageRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsClickSponsoredMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.clickSponsoredMessage#18afbc93 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.clickSponsoredMessage#18afbc93: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode channels.clickSponsoredMessage#18afbc93: field random_id: %w", )
		}
		.RandomID = 
	}
	return nil
}

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

// GetRandomID returns value of RandomID field.
func ( *ChannelsClickSponsoredMessageRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .RandomID
}

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

// ChannelsClickSponsoredMessage invokes method channels.clickSponsoredMessage#18afbc93 returning error if any.
// Informs the server that the user has either:
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.clickSponsoredMessage for reference.
func ( *Client) ( context.Context,  *ChannelsClickSponsoredMessageRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}