export type CreateApiPdfV1PrescricaoArgs = {Authorization?: string | undefined, body: BodyInit}; export type CreateApiPdfV1PrescricaoOptions = {baseUrl?: string | undefined, JWTAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Inserção de metadados para prescrições digitais * * POST /pdf/v1/prescricao */ export const createApiPdfV1Prescricao = async (args: CreateApiPdfV1PrescricaoArgs, options?: CreateApiPdfV1PrescricaoOptions) => { 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(/\/+$/, '')}/pdf/v1/prescricao${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() };