export type GetApiApiShopsDocumentsDownloadArgs = {shop_ids?: string | undefined, document_ids?: string | undefined, type_codes?: string | undefined}; export type GetApiApiShopsDocumentsDownloadOptions = {baseUrl?: string | undefined, FrontBearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * S31 - Download documents for one or multiple shops * * GET /api/shops/documents/download * * Also accepts auth: OAuth-2 */ export const getApiApiShopsDocumentsDownload = async (args: GetApiApiShopsDocumentsDownloadArgs, options?: GetApiApiShopsDocumentsDownloadOptions) => { const {baseUrl = "https://your-instance.mirakl.net", fetch: fetchFn = fetch, FrontBearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.shop_ids != null) query.append("shop_ids", String(args.shop_ids)) if (args.document_ids != null) query.append("document_ids", String(args.document_ids)) if (args.type_codes != null) query.append("type_codes", String(args.type_codes)) if (FrontBearerToken !== undefined) headers.set('authorization', `Bearer ${FrontBearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/shops/documents/download${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() };