export type GetApiSnapshotsSnapshotIdFilesArgs = {snapshotId: string, path?: string | undefined}; export type GetApiSnapshotsSnapshotIdFilesOptions = {baseUrl?: string | undefined, BoxBearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a file or folder from a snapshot * * GET /snapshots/{snapshotId}/files */ export const getApiSnapshotsSnapshotIdFiles = async (args: GetApiSnapshotsSnapshotIdFilesArgs, options?: GetApiSnapshotsSnapshotIdFilesOptions) => { 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(/\/+$/, '')}/snapshots/${encodeURIComponent(String(args.snapshotId))}/files${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() };