ChannelDirectoryClient
ChannelDirectoryClient:
TypedEventEmitter<ChannelDirectoryEvents> &object
Represents the client service for managing folders within a channel.
Type declaration
create()
Creates a new entry in the channel folder.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ChannelDirectoryCreateRequest | The request object containing details for creating a channel folder. |
Returns
Promise<ChannelDirectory>
A promise that resolves to the created ChannelDirectory.
Throws
Will throw an error if the creation fails.
Example
import {
ChannelDirectory,
ChannelDirectoryCreateRequest,
ChannelGuid,
rootServer,
} from "@rootsdk/server-app";
export async function createExample(
channelId: ChannelGuid,
): Promise<ChannelDirectory> {
try {
// Set up the request
const request: ChannelDirectoryCreateRequest = {
channelId: channelId,
name: "MyChannelDirectoryName",
parentDirectoryId: undefined,
};
// Call the API
const directory: ChannelDirectory =
await rootServer.community.channelDirectories.create(request);
return directory;
} catch (error) {
// Detect error
throw error;
}
}
delete()
Deletes a channel folder entry.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ChannelDirectoryDeleteRequest | The request object containing details for deleting a channel folder. |
Returns
Promise<void>
A promise that resolves once the folder entry is deleted.
Throws
Will throw an error if the delete operation fails.
Example
import {
ChannelDirectory,
ChannelDirectoryDeleteRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";
export async function deleteExample(
directoryId: DirectoryGuid,
channelId: ChannelGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelDirectoryDeleteRequest = {
id: directoryId,
channelId: channelId,
};
// Call the API
await rootServer.community.channelDirectories.delete(request);
} catch (error) {
// Detect error
throw error;
}
}
edit()
Edits an existing channel folder entry.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ChannelDirectoryEditRequest | The request object containing details for editing a channel folder. |
Returns
Promise<ChannelDirectoryEditResponse>
A promise that resolves to the edited ChannelDirectory.
Throws
Will throw an error if the editing operation fails.
Example
import {
ChannelDirectory,
ChannelDirectoryEditRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";
export async function editExample(
directoryId: DirectoryGuid,
channelId: ChannelGuid,
): Promise<ChannelDirectory> {
try {
// Set up the request
const request: ChannelDirectoryEditRequest = {
id: directoryId,
channelId: channelId,
name: "MyNewChannelDirectoryName",
};
// Call the API
const directory: ChannelDirectory =
await rootServer.community.channelDirectories.edit(request);
return directory;
} catch (error) {
// Detect error
throw error;
}
}
get()
Retrieves a specific channel folder entry.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ChannelDirectoryGetRequest | The request object containing details for retrieving a channel folder. |
Returns
Promise<ChannelDirectory>
A promise that resolves to a ChannelDirectoryFullResponse containing the retrieved folder entry.
Throws
Will throw an error if the retrieval operation fails.
Example
import {
ChannelDirectory,
ChannelDirectoryGetRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";
export async function getExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
): Promise<ChannelDirectory> {
try {
// Set up the request
const request: ChannelDirectoryGetRequest = {
id: directoryId,
channelId: channelId,
};
// Call the API
const directory: ChannelDirectory =
await rootServer.community.channelDirectories.get(request);
return directory;
} catch (error) {
// Detect error
throw error;
}
}
list()
Parameters
| Parameter | Type |
|---|---|
request | ChannelDirectoryListRequest |
Returns
Promise<ChannelDirectory[]>
Example
import {
ChannelDirectory,
ChannelDirectoryListRequest,
ChannelGuid,
rootServer,
} from "@rootsdk/server-app";
export async function listExample(
channelId: ChannelGuid,
): Promise<ChannelDirectory[]> {
try {
// Set up the request
const request: ChannelDirectoryListRequest = {
channelId: channelId,
};
// Call the API
const response: ChannelDirectory[] =
await rootServer.community.channelDirectories.list(request);
return response;
} catch (error) {
// Detect error
throw error;
}
}
move()
Moves a channel folder entry to a new location.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ChannelDirectoryMoveRequest | The request object containing details for moving the channel folder. |
Returns
Promise<ChannelDirectoryMoveResponse>
A promise that resolves to a ChannelDirectoryMoveResponse containing the result of the move operation.
Throws
Will throw an error if the move operation fails.
Example
import {
ChannelDirectoryMoveRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";
export async function moveExample(
directoryId: DirectoryGuid,
channelId: ChannelGuid,
oldParentDirectoryId: DirectoryGuid,
newParentDirectoryId: DirectoryGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelDirectoryMoveRequest = {
id: directoryId,
channelId: channelId,
oldParentDirectoryId: oldParentDirectoryId,
newParentDirectoryId: newParentDirectoryId,
};
// Call the API
await rootServer.community.channelDirectories.move(request);
} catch (error) {
// Detect error
throw error;
}
}