export type CreateApiPreparadorV2PrepararArgs = {Authorization?: string | undefined, body: BodyInit}; export type CreateApiPreparadorV2PrepararOptions = {baseUrl?: string | undefined, JWTAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Preparar documento PDF realizando manipulações com imagem e texto * * POST /preparador/v2/preparar */ export const createApiPreparadorV2Preparar = async (args: CreateApiPreparadorV2PrepararArgs, options?: CreateApiPreparadorV2PrepararOptions) => { const {baseUrl = "https://cloud-hom.bry.com.br", fetch: fetchFn = fetch, JWTAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (JWTAccessToken !== undefined) headers.set("Authorization", JWTAccessToken) const url = `${baseUrl.replace(/\/+$/, '')}/preparador/v2/preparar${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: 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() };