export type ReportRequestParameters = {key: string, value: string}; export type UpdateApiReportingGetReportArgs = {reportPath: string, reportFormat: 'HTML_4_0' | 'CSV' | 'PSV' | 'EXCEL' | 'PDF' | 'XML' | 'IMAGE', body: Array}; export type UpdateApiReportingGetReportOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Run a MarketSuite Report and receive the results in the specified format. * * PUT /reporting/getReport */ export const updateApiReportingGetReport = async (args: UpdateApiReportingGetReportArgs, options?: UpdateApiReportingGetReportOptions) => { const {baseUrl = "https://pm-file-api.apx.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args.reportPath != null) query.append("reportPath", String(args.reportPath)) if (args.reportFormat != null) query.append("reportFormat", String(args.reportFormat)) const url = `${baseUrl.replace(/\/+$/, '')}/reporting/getReport${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };