export type CreateApiUuidDocumentGenerateDocumentViewArgs = {'uuid-document': string, tokenAPI: string, cryptKey: string, body: {with_attachments?: boolean | undefined}}; export type CreateApiUuidDocumentGenerateDocumentViewOptions = {baseUrl?: string | undefined, sec0?: string | undefined, sec1?: string | undefined, fetch?: typeof fetch | undefined}; /** * Visualizar documentos e anexos * * POST /{uuid-document}/generate-document-view */ export const createApiUuidDocumentGenerateDocumentView = async (args: CreateApiUuidDocumentGenerateDocumentViewArgs, options?: CreateApiUuidDocumentGenerateDocumentViewOptions) => { const {baseUrl = "https://sandbox.d4sign.com.br/api/v1", fetch: fetchFn = fetch, sec0, sec1} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.tokenAPI != null) query.append("tokenAPI", String(args.tokenAPI)) if (args.cryptKey != null) query.append("cryptKey", String(args.cryptKey)) if (sec0 !== undefined) query.set("tokenAPI", sec0) if (sec1 !== undefined) query.set("cryptKey", sec1) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args['uuid-document']))}/generate-document-view${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 undefined };