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

// ChannelsExportMessageLinkRequest represents TL type `channels.exportMessageLink#e63fadeb`.
// Get link and embed info of a message in a channel/supergroupĀ¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.exportMessageLink for reference.
type ChannelsExportMessageLinkRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to include other grouped media (for albums)
	Grouped bool
	// Whether to also include a thread ID, if available, inside of the link
	Thread bool
	// Channel
	Channel InputChannelClass
	// Message ID
	ID int
}

// ChannelsExportMessageLinkRequestTypeID is TL type id of ChannelsExportMessageLinkRequest.
const ChannelsExportMessageLinkRequestTypeID = 0xe63fadeb

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

func ( *ChannelsExportMessageLinkRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Grouped == false) {
		return false
	}
	if !(.Thread == false) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsExportMessageLinkRequest from given interface.
func ( *ChannelsExportMessageLinkRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputChannelClass)
	() ( int)
}) {
	.Grouped = .()
	.Thread = .()
	.Channel = .()
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsExportMessageLinkRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.exportMessageLink",
		ID:   ChannelsExportMessageLinkRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Grouped",
			SchemaName: "grouped",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Thread",
			SchemaName: "thread",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsExportMessageLinkRequest) () {
	if !(.Grouped == false) {
		.Flags.Set(0)
	}
	if !(.Thread == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsExportMessageLinkRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.exportMessageLink#e63fadeb as nil")
	}
	.PutID(ChannelsExportMessageLinkRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsExportMessageLinkRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.exportMessageLink#e63fadeb to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.exportMessageLink#e63fadeb: field flags: %w", )
		}
	}
	.Grouped = .Flags.Has(0)
	.Thread = .Flags.Has(1)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.exportMessageLink#e63fadeb: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.exportMessageLink#e63fadeb: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// SetGrouped sets value of Grouped conditional field.
func ( *ChannelsExportMessageLinkRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Grouped = true
	} else {
		.Flags.Unset(0)
		.Grouped = false
	}
}

// GetGrouped returns value of Grouped conditional field.
func ( *ChannelsExportMessageLinkRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetThread sets value of Thread conditional field.
func ( *ChannelsExportMessageLinkRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Thread = true
	} else {
		.Flags.Unset(1)
		.Thread = false
	}
}

// GetThread returns value of Thread conditional field.
func ( *ChannelsExportMessageLinkRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// GetID returns value of ID field.
func ( *ChannelsExportMessageLinkRequest) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

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

// ChannelsExportMessageLink invokes method channels.exportMessageLink#e63fadeb returning error if any.
// Get link and embed info of a message in a channel/supergroupĀ¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//
// See https://core.telegram.org/method/channels.exportMessageLink for reference.
func ( *Client) ( context.Context,  *ChannelsExportMessageLinkRequest) (*ExportedMessageLink, error) {
	var  ExportedMessageLink

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