ChannelFileClient
ChannelFileClient:
TypedEventEmitter<ChannelFileEvents> &object
Type declaration
create()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileCreateRequest |
Returns
Promise<ChannelFile>
Example
import {
ChannelFile,
ChannelFileCreateRequest,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function createExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
uploadToken: string
): Promise<ChannelFile> {
try {
// Set up the request
const request: ChannelFileCreateRequest = {
directoryId: directoryId,
channelId: channelId,
uploadTokenUri: uploadToken
};
// Call the API
const file: ChannelFile =
await rootServer.community.channelFiles.create(request);
return file;
} catch (error) {
// Detect error
throw error;
}
}
delete()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileDeleteRequest |
Returns
Promise<void>
Example
import {
ChannelFile,
ChannelFileDeleteRequest,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function deleteExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
fileId: FileGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelFileDeleteRequest = {
id: fileId,
directoryId: directoryId,
channelId: channelId,
};
// Call the API
await rootServer.community.channelFiles.delete(request);
} catch (error) {
// Detect error
throw error;
}
}
edit()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileEditRequest |
Returns
Promise<ChannelFileEditResponse>
Example
import {
ChannelFile,
ChannelFileEditRequest,
ChannelFileEditResponse,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function editExample(
fileId: FileGuid,
channelId: ChannelGuid,
directoryId: DirectoryGuid,
name: string,
): Promise<ChannelFileEditResponse> {
try {
// Set up the request
const request: ChannelFileEditRequest = {
id: fileId,
channelId: channelId,
directoryId: directoryId,
name: "MyNewFileName",
};
// Call the API
const file: ChannelFileEditResponse =
await rootServer.community.channelFiles.edit(request);
return file;
} catch (error) {
// Detect error
throw error;
}
}
get()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileGetRequest |
Returns
Promise<ChannelFile>
Example
import {
ChannelFile,
ChannelFileGetRequest,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function getExample(
fileId: FileGuid,
channelId: ChannelGuid,
directoryId: DirectoryGuid,
): Promise<ChannelFile> {
try {
// Set up the request
const request: ChannelFileGetRequest = {
id: fileId,
channelId: channelId,
directoryId: directoryId,
};
// Call the API
const response: ChannelFile =
await rootServer.community.channelFiles.get(request);
return response;
} catch (error) {
// Detect error
throw error;
}
}
list()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileListRequest |
Returns
Promise<ChannelFile[]>
Example
import {
ChannelFile,
ChannelFileListRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function listExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
): Promise<ChannelFile[]> {
try {
// Set up the request
const request: ChannelFileListRequest = {
channelId: channelId,
directoryId: directoryId,
};
// Call the API
const files: ChannelFile[] =
await rootServer.community.channelFiles.list(request);
return files;
} catch (error) {
// Detect error
throw error;
}
}
move()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileMoveRequest |
Returns
Promise<ChannelFileMoveResponse>
Example
import {
ChannelFile,
ChannelFileMoveRequest,
ChannelFileMoveResponse,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function moveExample(
fileId: FileGuid,
channelId: ChannelGuid,
oldDirectoryId: DirectoryGuid,
newDirectoryId: DirectoryGuid,
): Promise<ChannelFileMoveResponse> {
try {
// Set up the request
const request: ChannelFileMoveRequest = {
id: fileId,
channelId: channelId,
oldDirectoryId: oldDirectoryId,
newDirectoryId: newDirectoryId,
};
// Call the API
const file: ChannelFileMoveResponse =
await rootServer.community.channelFiles.move(request);
return file;
} catch (error) {
// Detect error
throw error;
}
}
search()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileSearchRequest |
Returns
Promise<ChannelFile[]>
Example
import {
ChannelFile,
ChannelFileSearchRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function searchExample(
channelId: ChannelGuid,
search: string,
): Promise<ChannelFile[]> {
try {
// Set up the request
const request: ChannelFileSearchRequest = {
channelId: channelId,
search: search,
lastFileId: undefined,
};
// Call the API
const response: ChannelFile[] =
await rootServer.community.channelFiles.search(request);
return response;
} catch (error) {
// Detect error
throw error;
}
}
searchCommunity()
Parameters
| Parameter | Type |
|---|---|
request | ChannelFileSearchCommunityRequest |
Returns
Promise<ChannelFileSearchCommunityResponse>
Example
import {
ChannelFile,
ChannelFileSearchCommunityRequest,
ChannelFileSearchCommunityResponse,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function searchCommunityExample(
channelIds: ChannelGuid[],
search: string,
): Promise<ChannelFileSearchCommunityResponse> {
try {
// Set up the request
const request: ChannelFileSearchCommunityRequest = {
channelIds: channelIds,
search: search,
};
// Call the API
const response: ChannelFileSearchCommunityResponse =
await rootServer.community.channelFiles.searchCommunity(request);
return response;
} catch (error) {
// Detect error
throw error;
}
}