deno.land / x / gesso@v0.1.2 / src / Files.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420import { BaseApi } from "./BaseApi.ts";import { Configuration } from "./Configuration.ts";import { File, Folder, License, Scope, UsageRights } from "../types/models.ts";import { CopyFileParams, CopyFolderParams, CreateFolderParams, DeleteFileParams, DeleteFolderParams, GetFileParams, GetPublicInlinePreviewUrlParams, ListFilesParams, RemoveUsageRightsParams, SetUsageRightsParams, UpdateFileParams, UpdateFolderParams,} from "../types/params.ts";
export class Files extends BaseApi { constructor(config: Configuration) { super(config); }
public async getQuotaInformation( course_id: string, body?: unknown, ): Promise<unknown> { const endpoint = `/api/v1/courses/${course_id}/files/quota`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as unknown; }
return Promise.reject(response); }
public async listFiles( course_id: string, params?: ListFilesParams, body?: unknown, ): Promise<File[]> { const endpoint = `/api/v1/courses/${course_id}/files`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File[]; }
return Promise.reject(response); }
public async getPublicInlinePreviewUrl( id: string, params?: GetPublicInlinePreviewUrlParams, body?: unknown, ): Promise<Scope> { const endpoint = `/api/v1/files/${id}/public_url`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Scope; }
return Promise.reject(response); }
public async getFile( id: string, params?: GetFileParams, body?: unknown, ): Promise<File> { const endpoint = `/api/v1/files/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File; }
return Promise.reject(response); }
public async translateFileReference( course_id: string, migration_id: string, body?: unknown, ): Promise<File> { const endpoint = `/api/v1/courses/${course_id}/files/file_ref/${migration_id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File; }
return Promise.reject(response); }
public async updateFile( id: string, params?: UpdateFileParams, body?: unknown, ): Promise<File> { const endpoint = `/api/v1/files/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.put(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File; }
return Promise.reject(response); }
public async deleteFile( id: string, params?: DeleteFileParams, body?: unknown, ): Promise<File> { const endpoint = `/api/v1/files/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File; }
return Promise.reject(response); }
public async getIconMetadata(id: string, body?: unknown): Promise<unknown> { const endpoint = `/api/v1/files/${id}/icon_metadata`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as unknown; }
return Promise.reject(response); }
public async resetLinkVerifier(id: string, body?: unknown): Promise<File> { const endpoint = `/api/v1/files/${id}/reset_verifier`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File; }
return Promise.reject(response); }
public async listFolders(id: string, body?: unknown): Promise<Folder[]> { const endpoint = `/api/v1/folders/${id}/folders`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder[]; }
return Promise.reject(response); }
public async listAllFolders( course_id: string, body?: unknown, ): Promise<Folder[]> { const endpoint = `/api/v1/courses/${course_id}/folders`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder[]; }
return Promise.reject(response); }
public async resolvePath( course_id: string, body?: unknown, ): Promise<Folder[]> { const endpoint = `/api/v1/courses/${course_id}/folders/by_path/*full_path`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder[]; }
return Promise.reject(response); }
public async getFolder( course_id: string, id: string, body?: unknown, ): Promise<Folder> { const endpoint = `/api/v1/courses/${course_id}/folders/${id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder; }
return Promise.reject(response); }
public async updateFolder( id: string, params?: UpdateFolderParams, body?: unknown, ): Promise<Folder> { const endpoint = `/api/v1/folders/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.put(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder; }
return Promise.reject(response); }
public async createFolder( course_id: string, params?: CreateFolderParams, body?: unknown, ): Promise<Folder> { const endpoint = `/api/v1/courses/${course_id}/folders`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder; }
return Promise.reject(response); }
public async deleteFolder( id: string, params?: DeleteFolderParams, body?: unknown, ): Promise<Scope> { const endpoint = `/api/v1/folders/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Scope; }
return Promise.reject(response); }
public async uploadFile(folder_id: string, body?: unknown): Promise<Scope> { const endpoint = `/api/v1/folders/${folder_id}/files`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Scope; }
return Promise.reject(response); }
public async copyFile( dest_folder_id: string, params?: CopyFileParams, body?: unknown, ): Promise<File> { const endpoint = `/api/v1/folders/${dest_folder_id}/copy_file`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as File; }
return Promise.reject(response); }
public async copyFolder( dest_folder_id: string, params?: CopyFolderParams, body?: unknown, ): Promise<Folder> { const endpoint = `/api/v1/folders/${dest_folder_id}/copy_folder`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder; }
return Promise.reject(response); }
public async getUploadedMediaFolderForUser( course_id: string, body?: unknown, ): Promise<Folder> { const endpoint = `/api/v1/courses/${course_id}/folders/media`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Folder; }
return Promise.reject(response); }
public async setUsageRights( course_id: string, params?: SetUsageRightsParams, body?: unknown, ): Promise<UsageRights> { const endpoint = `/api/v1/courses/${course_id}/usage_rights`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.put(url, JSON.stringify(body)); if (response.ok) { return await response.json() as UsageRights; }
return Promise.reject(response); }
public async removeUsageRights( course_id: string, params?: RemoveUsageRightsParams, body?: unknown, ): Promise<Scope> { const endpoint = `/api/v1/courses/${course_id}/usage_rights`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Scope; }
return Promise.reject(response); }
public async listLicenses( course_id: string, body?: unknown, ): Promise<License[]> { const endpoint = `/api/v1/courses/${course_id}/content_licenses`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as License[]; }
return Promise.reject(response); }}
Version Info