export type GetApiV1CollectionsCollectionIdExportArgs = {collectionId: number}; export type GetApiV1CollectionsCollectionIdExportOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export account-level collection's items * * GET /v1/collections/{collectionId}/export * * Also accepts auth: management_key */ export const getApiV1CollectionsCollectionIdExport = async (args: GetApiV1CollectionsCollectionIdExportArgs, options?: GetApiV1CollectionsCollectionIdExportOptions) => { const {baseUrl = "https://yourbaseurl.talon.one", fetch: fetchFn = fetch, managerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/csv") if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/collections/${encodeURIComponent(String(args.collectionId))}/export${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() };