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

// ChannelsViewSponsoredMessageRequest represents TL type `channels.viewSponsoredMessage#beaedb94`.
// Mark a specific sponsored message as read
//
// See https://core.telegram.org/method/channels.viewSponsoredMessage for reference.
type ChannelsViewSponsoredMessageRequest struct {
	// Peer
	Channel InputChannelClass
	// Message ID
	RandomID []byte
}

// ChannelsViewSponsoredMessageRequestTypeID is TL type id of ChannelsViewSponsoredMessageRequest.
const ChannelsViewSponsoredMessageRequestTypeID = 0xbeaedb94

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsViewSponsoredMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.viewSponsoredMessage#beaedb94 as nil")
	}
	.PutID(ChannelsViewSponsoredMessageRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// ChannelsViewSponsoredMessage invokes method channels.viewSponsoredMessage#beaedb94 returning error if any.
// Mark a specific sponsored message as read
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//
// See https://core.telegram.org/method/channels.viewSponsoredMessage for reference.
func ( *Client) ( context.Context,  *ChannelsViewSponsoredMessageRequest) (bool, error) {
	var  BoolBox

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