export type DeleteApiInvoicesInvoiceIdCreditNotesCreditNoteIdArgs = {invoiceId: string, creditNoteId: string}; export type DeleteApiInvoicesInvoiceIdCreditNotesCreditNoteIdOptions = {baseUrl?: string | undefined, BillerAccessTokenStaging?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cancel an imported credit note * * DELETE /invoices/{invoiceId}/credit_notes/{creditNoteId} * * Also accepts auth: Biller Access Token (Production) */ export const deleteApiInvoicesInvoiceIdCreditNotesCreditNoteId = async (args: DeleteApiInvoicesInvoiceIdCreditNotesCreditNoteIdArgs, options?: DeleteApiInvoicesInvoiceIdCreditNotesCreditNoteIdOptions) => { const {baseUrl = "https://api.adfin.com/api", fetch: fetchFn = fetch, BillerAccessTokenStaging} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (BillerAccessTokenStaging !== undefined) headers.set('authorization', `Bearer ${BillerAccessTokenStaging}`) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/${encodeURIComponent(String(args.invoiceId))}/credit_notes/${encodeURIComponent(String(args.creditNoteId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };