export type GetApiCaApiFileIdTempDownloadUrlArgs = {id: number}; export type GetApiCaApiFileIdTempDownloadUrlOptions = {baseUrl?: string | undefined, knoxApiToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get File Temporary Download URL * * GET /ca/api/file/{id}/temp-download-url */ export const getApiCaApiFileIdTempDownloadUrl = async (args: GetApiCaApiFileIdTempDownloadUrlArgs, options?: GetApiCaApiFileIdTempDownloadUrlOptions) => { const {baseUrl = "https://api.meetcampfire.com", fetch: fetchFn = fetch, knoxApiToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (knoxApiToken !== undefined) headers.set("Authorization", knoxApiToken) const url = `${baseUrl.replace(/\/+$/, '')}/ca/api/file/${encodeURIComponent(String(args.id))}/temp-download-url${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 };