export type GetApiApiB2bV3GeneralDocumentClosingDocumentsDownloadArgs = {data: string}; export type GetApiApiB2bV3GeneralDocumentClosingDocumentsDownloadOptions = {baseUrl: string, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download closing documents * * GET /api/b2b/v3/general/document/closing_documents/download */ export const getApiApiB2bV3GeneralDocumentClosingDocumentsDownload = async (args: GetApiApiB2bV3GeneralDocumentClosingDocumentsDownloadArgs, options: GetApiApiB2bV3GeneralDocumentClosingDocumentsDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.data != null) query.append("data", String(args.data)) if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/b2b/v3/general/document/closing_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() };