export type GetApiBoxesBoxIdArtifactsArgs = {boxId: string, path: string}; export type GetApiBoxesBoxIdArtifactsOptions = {baseUrl?: string | undefined, BoxBearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a Box artifact * * GET /boxes/{boxId}/artifacts */ export const getApiBoxesBoxIdArtifacts = async (args: GetApiBoxesBoxIdArtifactsArgs, options?: GetApiBoxesBoxIdArtifactsOptions) => { const {baseUrl = "https://ascii.dev/api/box/v1", fetch: fetchFn = fetch, BoxBearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.path != null) query.append("path", String(args.path)) if (BoxBearerAuth !== undefined) headers.set('authorization', `Bearer ${BoxBearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/boxes/${encodeURIComponent(String(args.boxId))}/artifacts${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 res.blob() };