export type GetApi10KbInvoicesInvoiceIdHtmlArgs = {invoiceId: string};
export type GetApi10KbInvoicesInvoiceIdHtmlOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined};
/**
* Render an invoice as HTML
*
* GET /1.0/kb/invoices/{invoiceId}/html
*
* Also accepts auth: Killbill_Api_Key, Killbill_Api_Secret
*/
export const getApi10KbInvoicesInvoiceIdHtml = async (args: GetApi10KbInvoicesInvoiceIdHtmlArgs, options: GetApi10KbInvoicesInvoiceIdHtmlOptions) => {
const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {}
const query = new URLSearchParams()
const headers = new Headers()
headers.set('accept', "text/html")
if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`)
const url = `${baseUrl.replace(/\/+$/, '')}/1.0/kb/invoices/${encodeURIComponent(String(args.invoiceId))}/html${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.text()
};