import { HttpMethod, RootAPIHelper } from './root-api'; /** * Passes a body and merge vars to the Root API to generate into a PDF * @param apiKey Root API key with CLI permissions * @param content The unmerged content * @param mergeVars The merge vars to compile into the content * @param merge A flag that indicated whether merge vars should be merged in or not * @returns A base64 PDF document */ export const generateDocument = async (params: { apiKey: string; content: string; mergeVars: any; merge: boolean; host: string; }): Promise => { const { host, apiKey, content, merge, mergeVars } = params; const rootApi = new RootAPIHelper({ host, apiKey, throwResponseErrors: true }); const response = await rootApi.send({ method: HttpMethod.Post, path: `/cli/generate-document`, body: { content, merge_vars: mergeVars, merge, }, }); return response.base64PDF; };