export type GetApiV1ChannelOrderInvoiceDocumentIdArgs = {documentId: string}; export type GetApiV1ChannelOrderInvoiceDocumentIdOptions = {baseUrl?: string | undefined, ChannelAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Invoice * * GET /v1/channel/order/invoice/{documentId} */ export const getApiV1ChannelOrderInvoiceDocumentId = async (args: GetApiV1ChannelOrderInvoiceDocumentIdArgs, options?: GetApiV1ChannelOrderInvoiceDocumentIdOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, ChannelAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (ChannelAuth !== undefined) headers.set('authorization', `Bearer ${ChannelAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/channel/order/invoice/${encodeURIComponent(String(args.documentId))}${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() };