export type GetApiFilesIdContentsArgs = {id: string, version?: string | undefined}; export type GetApiFilesIdContentsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get a file contents * * GET /files/{id}/contents */ export const getApiFilesIdContents = async (args: GetApiFilesIdContentsArgs, options?: GetApiFilesIdContentsOptions) => { const {baseUrl = "https://api.webscale.com/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/files/${encodeURIComponent(String(args.id))}/contents${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };